diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt index ff009d2b75ffb833722d7b9f256d047eca7317a0..dab782f1b8e33c36c4794bf9dae0e6c398f0e6ca 100644 --- a/devNotes/twine JS.txt +++ b/devNotes/twine JS.txt @@ -811,6 +811,20 @@ window.ngUpdateGenePool = function(genePool) { }); } +window.ngUpdateMissingTable = function(missingTable) { + var newTable = {}; + + (State.variables.slaves || []) + .forEach(s => ([s.pregSource+1200000,s.mother+1200000,s.father+1200000] + .filter(i => (i in missingTable)) + .forEach(i => { + newTable[i-1200000] = missingTable[i]; + newTable[i-1200000].ID -= 1200000; + }))); + + return newTable; +}; + window.toJson = function(obj) { var jsontext = JSON.stringify(obj); jsontext = jsontext.replace(/^{/,""); @@ -9794,6 +9808,14 @@ window.WombZeroID = function(actor, id) { WombNormalizePreg(actor); }; +window.WombChangeID = function(actor, fromID, toID) { + WombInit(actor); + actor.womb + .filter(ft => ft.fatherID === fromID) + .forEach(ft => ft.fatherID = toID); + WombNormalizePreg(actor); +}; + /* Sorts the womb object by age with oldest and thus soonest to be born, first. This will be needed in the future once individual fertilization is a possibility.*/ window.WombSort = function(actor) { actor.womb.sort((a, b) => { return b.age - a.age; }); @@ -11862,10 +11884,16 @@ window.buildFamilyTree = function(slaves = State.variables.slaves, filterID) { } var mom = character.mother; if(mom < -6) { - if(typeof outmoms[mom] == 'undefined') { - outmoms[mom] = []; + if (mom in State.variables.missingTable && State.variables.showMissingSlaves) { + node_lookup[mom] = family_graph.nodes.length; + var missing = State.variables.missingTable[mom]; + charList.push({ID: mom, mother: 0, father: 0, is_mother: true, dick: missing.dick, vagina: missing.vagina, slaveName: missing.slaveName}); + } else { + if(typeof outmoms[mom] == 'undefined') { + outmoms[mom] = []; + } + outmoms[mom].push(character.slaveName); } - outmoms[mom].push(character.slaveName); } else if(mom < 0 && typeof node_lookup[mom] == 'undefined' && typeof preset_lookup[mom] != 'undefined') { node_lookup[mom] = family_graph.nodes.length; charList.push({ID: mom, mother: 0, father: 0, is_father: true, dick: 0, vagina: 1, slaveName: preset_lookup[mom]}); @@ -11873,10 +11901,16 @@ window.buildFamilyTree = function(slaves = State.variables.slaves, filterID) { var dad = character.father; if(dad < -6) { - if(typeof outdads[dad] == 'undefined') { - outdads[dad] = []; + if (dad in State.variables.missingTable && State.variables.showMissingSlaves) { + node_lookup[dad] = family_graph.nodes.length; + var missing = State.variables.missingTable[dad]; + charList.push({ID: dad, mother: 0, father: 0, is_father: true, dick: missing.dick, vagina: missing.vagina, slaveName: missing.slaveName}); + } else { + if(typeof outdads[dad] == 'undefined') { + outdads[dad] = []; + } + outdads[dad].push(character.slaveName); } - outdads[dad].push(character.slaveName); } else if(dad < 0 && typeof node_lookup[dad] == 'undefined' && typeof preset_lookup[dad] != 'undefined') { node_lookup[dad] = family_graph.nodes.length; charList.push({ID: dad, mother: 0, father: 0, is_father: true, dick: 1, vagina: -1, slaveName: preset_lookup[dad]}); @@ -23162,6 +23196,8 @@ window.SlaveSummaryUncached = (function(){ handled = 1; } r += " "; + } else if (slave.mother in V.missingTable && V.showMissingSlavesSD && V.showMissingSlaves) { + r += `${V.missingTable[slave.mother].fullName}'s daughter `; } if (slave.father > 0 && slave.father !== slave.mother) { let _ssj = V.slaves.findIndex(function(s) { @@ -23195,6 +23231,8 @@ window.SlaveSummaryUncached = (function(){ handled = 1; } r += " "; + } else if (slave.father in V.missingTable && slave.father !== slave.mother && V.showMissingSlavesSD && V.showMissingSlaves) { + r += `${V.missingTable[slave.father].fullName}'s daughter`; } if (slave.daughters === 1) { let _ssj = V.slaves.findIndex(function(s) { @@ -23422,6 +23460,8 @@ window.SlaveSummaryUncached = (function(){ } else { r += `<span class="lightgreen">daughter.</span> `; } + } else if (slave.mother in V.missingTable && V.showMissingSlavesSD && V.showMissingSlaves) { + r += `${V.missingTable[slave.mother].fullName}'s <span class="lightgreen">daughter.</span> `; } if (slave.father > 0 && slave.father !== slave.mother) { let _ssj = V.slaves.findIndex(function(s) { @@ -23456,6 +23496,8 @@ window.SlaveSummaryUncached = (function(){ } else { r += `<span class="lightgreen">daughter.</span> `; } + } else if (slave.father in V.missingTable && slave.father !== slave.mother && V.showMissingSlavesSD && V.showMissingSlaves) { + r += `${V.missingTable[slave.father].fullName}'s <span class="lightgreen">daughter.</span> `; } if (slave.daughters === 1) { let _ssj = V.slaves.findIndex(function(s) { @@ -24101,7 +24143,10 @@ window.removeActiveSlave = function removeActiveSlave() { const INDEX = V.slaveIndices[AS_ID]; let missing = false; - WombZeroID(V.PC, AS_ID); + WombChangeID(V.PC, AS_ID, V.missingParentID); + if (V.PC.pregSource === V.missingParentID) { + missing = true; + } if (V.activeSlave.reservedChildren > 0) { V.reservedChildren -= V.activeSlave.reservedChildren; } @@ -24138,7 +24183,10 @@ window.removeActiveSlave = function removeActiveSlave() { }); } V.slaves.forEach(slave => { - WombZeroID(slave, AS_ID); /* This check is complex, should be done in JS now, all needed will be done here. */ + WombChangeID(slave, AS_ID, V.missingParentID); /* This check is complex, should be done in JS now, all needed will be done here. */ + if (slave.pregSource === V.missingParentID) { + missing = true; + } if (V.activeSlave.daughters > 0) { if (slave.mother === AS_ID) { slave.mother = V.missingParentID; @@ -24286,13 +24334,19 @@ window.removeActiveSlave = function removeActiveSlave() { } } - removeSlave(INDEX); - LENGTH--; - V.activeSlave = 0; - if (missing) { + V.missingTable[V.missingParentID] = { slaveName: V.activeSlave.slaveName, + slaveSurname: V.activeSlave.slaveSurname, + fullName: SlaveFullName(V.activeSlave), + dick : V.activeSlave.dick, + vagina : V.activeSlave.vagina, + ID : V.missingParentID }; V.missingParentID--; } + + removeSlave(INDEX); + LENGTH--; + V.activeSlave = 0; } };