diff --git a/src/js/assayJS.js b/src/js/assayJS.js index 55009b84c12a559aa870626678232398b59f30eb..04cdb5642a576c1354d9f77ded6d8ffff92dbb47 100644 --- a/src/js/assayJS.js +++ b/src/js/assayJS.js @@ -268,12 +268,6 @@ globalThis.addSlave = function(slave) { V.slaveIndices[slave.ID] = V.slaves.push(slave) - 1; }; -globalThis.removeSlave = function(index) { - const ret = V.slaves.deleteAt(index); - V.slaveIndices = slaves2indices(); - return ret; -}; - /** * @param {App.Entity.SlaveState[]} [slaves] * @returns {Object.<number, number>} diff --git a/src/js/removeSlave.js b/src/js/removeSlave.js index 24e83fe1aa7a85541ac49f94ac6b28035e56454f..0bcc1db477512c5727d1c992cc0ca64761c4a1b2 100644 --- a/src/js/removeSlave.js +++ b/src/js/removeSlave.js @@ -244,120 +244,9 @@ globalThis.removeSlave = function(slave) { LENGTH--; V.JobIDMap = makeJobIdMap(); /* need to call this once more to update count of resting slaves*/ } -}; -/** - * @param {App.Entity.SlaveState} removedSlave - */ -globalThis.removeNonNGPSlave = function(removedSlave) { - "use strict"; - const ID = removedSlave.ID; - let LENGTH = V.slaves.length; - const INDEX = V.slaveIndices[ID]; - let missing = false; - - // Only bother if PC is being kept - if (V.freshPC !== 1) { - WombChangeID(V.PC, ID, V.missingParentID); - if (V.PC.pregSource === V.missingParentID) { - missing = true; - } - if (V.PC.mother === ID) { - V.PC.mother = V.missingParentID; - missing = true; - } - if (V.PC.father === ID) { - V.PC.father = V.missingParentID; - missing = true; - } - if (V.PC.sisters > 0) { - if (areSisters(V.PC, removedSlave) > 0) { - V.PC.sisters--; - } - } - if (V.PC.daughters > 0) { - if (removedSlave.father === -1 || removedSlave.mother === -1) { - V.PC.daughters--; - } - } - } - - if (INDEX >= 0 && INDEX < LENGTH) { - V.slaves.forEach(slave => { - if (slave.assignment === Job.IMPORTED) { - WombChangeID(slave, ID, V.missingParentID); /* This check is complex, should be done in JS now, all needed will be done here. */ - WombChangeGeneID(slave, ID, V.missingParentID); - if (slave.pregSource === V.missingParentID) { - missing = true; - } - if (removedSlave.daughters > 0) { - if (slave.mother === ID) { - slave.mother = V.missingParentID; - } - if (slave.father === ID) { - slave.father = V.missingParentID; - } - missing = true; - } - if (slave.milkSource === ID || slave.cumSource === ID) { - deflate(slave); - } - if (slave.ID === removedSlave.relationshipTarget) { - slave.relationship = 0; - slave.relationshipTarget = 0; - } - if (slave.ID === removedSlave.rivalryTarget) { - slave.rivalry = 0; - slave.rivalryTarget = 0; - } - } - }); - - const _geneIndex = V.genePool.findIndex(s => s.ID === ID); - if (_geneIndex !== -1) { - let keep = false; - if (isImpregnatedBy(V.PC, removedSlave)) { - /* did we impregnate the PC */ - keep = true; - } - if (!keep) { - /* avoid going through this loop if possible */ - keep = V.slaves.some(slave => { - /* have we impregnated a slave that is not ourselves? */ - return (slave.ID !== ID && isImpregnatedBy(slave, removedSlave)); - }); - } - if (!keep) { - V.genePool.deleteAt(_geneIndex); - } - } - Object.values(V.missingTable).forEach(s => { - if (s.mother === removedSlave.ID || s.father === removedSlave.ID) { - missing = true; - } - }); - if (missing) { - V.missingTable[V.missingParentID] = { - slaveName: removedSlave.slaveName, - slaveSurname: removedSlave.slaveSurname, - fullName: SlaveFullName(removedSlave), - dick: removedSlave.dick, - vagina: removedSlave.vagina, - ID: V.missingParentID, - mother: removedSlave.mother, - father: removedSlave.father, - inbreedingCoeff: removedSlave.inbreedingCoeff - }; - Object.values(V.missingTable).forEach(s => { - if (s.mother === removedSlave.ID) { - s.mother = V.missingParentID; - } - if (s.father === removedSlave.ID) { - s.father = V.missingParentID; - } - }); - V.missingParentID--; - } - - removeSlave(INDEX); + function removeSlave(index) { + const ret = V.slaves.deleteAt(index); + V.slaveIndices = slaves2indices(); + return ret; } };