diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw index 3b43788d1f0861fec742d67dcac5c5ccc4f8a857..223ae4d27d1c01d0553fd972f0cf12ee24574ae5 100644 --- a/src/init/storyInit.tw +++ b/src/init/storyInit.tw @@ -22,6 +22,12 @@ You should have received a copy of the GNU General Public License along with thi <<if def $slaves>> <<set _SL = $slaves.length>> + <<for _i = 0; _i < _SL; _i++>> + <<if $slaves[_i].assignment != "be imported">> + <<run removeNonNGPSlave($slaves[_i])>> + <<set _i--, _SL-->> + <</if>> + <</for>> <<for _i = 0; _i < _SL; _i++>> <<if $slaves[_i].assignment == "be imported">> <<set $slaves[_i].ID += 1200000>> @@ -76,8 +82,6 @@ You should have received a copy of the GNU General Public License along with thi <<set $slaves[_i].livingRules = "spare">> <<set $slaves[_i].diet = "healthy">> <<set $slaves[_i].pregControl = "none">> - <<else>> - <<set _dump = removeSlave(_i), _i--, _SL-->> <</if>> <</for>> <<set $slaveIndices = slaves2indices()>> diff --git a/src/js/removeActiveSlave.js b/src/js/removeActiveSlave.js index b28dc6a6760416185ae9760f12ebba966443083d..88ff9b9d5dc08e74b1e8547cc33596ce89b9753f 100644 --- a/src/js/removeActiveSlave.js +++ b/src/js/removeActiveSlave.js @@ -243,3 +243,120 @@ window.removeActiveSlave = function removeActiveSlave() { V.activeSlave = 0; } }; + +window.removeNonNGPSlave = function removeNonNGPSlave(removedSlave) { + "use strict"; + + const V = State.variables; + 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 == "be 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.ID === removedSlave.relationTarget) { + slave.relation = 0; + slave.relationTarget = 0; + } + if (slave.milkSource !== 0) { + if (slave.milkSource === ID) { + slave.milkSource = 0; + slave.inflation = 0; + slave.inflationType = "none"; + slave.inflationMethod = 0; + } + } + if (slave.cumSource !== 0) { + if (slave.cumSource === ID) { + slave.cumSource = 0; + slave.inflation = 0; + slave.inflationType = "none"; + slave.inflationMethod = 0; + } + } + 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(function(s) { return 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 ourself? */ + return (slave.ID !== ID && isImpregnatedBy(slave, removedSlave)) + }); + } + if (!keep) { + V.genePool.deleteAt(_geneIndex); + } + } + if (missing) { + V.missingTable[V.missingParentID] = { + slaveName: removedSlave.slaveName, + slaveSurname: removedSlave.slaveSurname, + fullName: SlaveFullName(removedSlave), + dick : removedSlave.dick, + vagina : removedSlave.vagina, + ID : V.missingParentID + }; + V.missingParentID--; + } + + removeSlave(INDEX); + + } +}; \ No newline at end of file