From ce487d98a77bc91468b663fceb01f5017fb20de1 Mon Sep 17 00:00:00 2001 From: Empress Sela <empresssela@cock.li> Date: Thu, 4 Oct 2018 19:01:53 -0700 Subject: [PATCH] Add $missingTable for storing names of slaves --- src/init/storyInit.tw | 8 ++++ src/js/familyTree.tw | 24 ++++++++--- src/js/removeActiveSlave.tw | 24 ++++++++--- src/js/slaveSummaryWidgets.tw | 8 ++++ src/js/storyJS.tw | 16 +++++++- src/js/wombJS.tw | 9 +++++ src/pregmod/managePersonalAffairs.tw | 2 +- src/pregmod/widgets/seBirthWidgets.tw | 2 + src/uncategorized/BackwardsCompatibility.tw | 10 +++++ src/uncategorized/options.tw | 7 ++++ src/uncategorized/summaryOptions.tw | 5 +++ src/utility/descriptionWidgetsFlesh.tw | 2 + src/utility/extendedFamilyWidgets.tw | 44 +++++++++++++++------ src/utility/optionsWidgets.tw | 25 ++++++++++++ 14 files changed, 160 insertions(+), 26 deletions(-) diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw index 9ae8c0cc7f1..5c8eed11347 100644 --- a/src/init/storyInit.tw +++ b/src/init/storyInit.tw @@ -97,6 +97,11 @@ You should have received a copy of the GNU General Public License along with thi <</if>> <</for>> <<set $genePool = ngUpdateGenePool($genePool)>> + <<if ndef $missingTable>> + <<set $missingTable = {}>> + <<else>> + <<set $missingTable = ngUpdateMissingTable($missingTable)>> + <</if>> /* <<for $i = 0; $i < $genePool.length; $i++>> <<for $k = 0; $k < $slaves.length; $k++>> @@ -244,6 +249,9 @@ You should have received a copy of the GNU General Public License along with thi <<set $slavesOriginal = []>> /* not used by pregmod */ <<set $genePool = []>> <<set $slaveIndices = slaves2indices()>> + <<set $missingTable = {}>> + <<set $showMissingSlaves = false>> + <<set $showMissingSlavesSD = false>> <</if>> <<set $organs = []>> diff --git a/src/js/familyTree.tw b/src/js/familyTree.tw index 4a8fbfec0a2..74a03a79a19 100644 --- a/src/js/familyTree.tw +++ b/src/js/familyTree.tw @@ -265,10 +265,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]}); @@ -276,10 +282,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]}); diff --git a/src/js/removeActiveSlave.tw b/src/js/removeActiveSlave.tw index 889349a420f..4c69f001ed0 100644 --- a/src/js/removeActiveSlave.tw +++ b/src/js/removeActiveSlave.tw @@ -9,7 +9,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; } @@ -46,7 +49,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; @@ -197,12 +203,18 @@ 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; } }; diff --git a/src/js/slaveSummaryWidgets.tw b/src/js/slaveSummaryWidgets.tw index 112722f5b5c..4be562ce181 100644 --- a/src/js/slaveSummaryWidgets.tw +++ b/src/js/slaveSummaryWidgets.tw @@ -3673,6 +3673,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) { @@ -3706,6 +3708,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) { @@ -3933,6 +3937,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) { @@ -3967,6 +3973,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) { diff --git a/src/js/storyJS.tw b/src/js/storyJS.tw index 7dc0173b5f3..a8c5102c7d5 100644 --- a/src/js/storyJS.tw +++ b/src/js/storyJS.tw @@ -808,6 +808,20 @@ window.ngUpdateGenePool = function(genePool) { }); } +window.ngUpdateMissingTable = function(missingTable) { + var newTable = {}; + + (State.variables.slaves || []) + .forEach(s => ([s.pregSource,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(/^{/,""); @@ -953,4 +967,4 @@ window.SoftenSexualFlaw = function SoftenSexualFlaw(slave) { break; } slave.sexualFlaw = "none"; -}; \ No newline at end of file +}; diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw index ea9fc9d33e4..ca6a44655a6 100644 --- a/src/js/wombJS.tw +++ b/src/js/wombJS.tw @@ -276,6 +276,15 @@ 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; }); diff --git a/src/pregmod/managePersonalAffairs.tw b/src/pregmod/managePersonalAffairs.tw index 08e48ab8cda..3eeff1bdd2e 100644 --- a/src/pregmod/managePersonalAffairs.tw +++ b/src/pregmod/managePersonalAffairs.tw @@ -358,7 +358,7 @@ __Rumors__ <</link>> </span> */ - <<if totalPlayerRelatives($PC) > 0>> + <<if totalPlayerRelatives($PC) > 0 || ($showMissingSlaves && ($PC.mother in $missingTable || $PC.father in $missingTable))>> <<PlayerFamily>> <</if>> <</if>> diff --git a/src/pregmod/widgets/seBirthWidgets.tw b/src/pregmod/widgets/seBirthWidgets.tw index b208f1aef2c..214577f730e 100644 --- a/src/pregmod/widgets/seBirthWidgets.tw +++ b/src/pregmod/widgets/seBirthWidgets.tw @@ -338,6 +338,8 @@ <<set _getFather = $slaves.find(function(s) { return s.ID == $slaves[$i].pregSource; })>> <<if def _getFather>> <<set $daddy = _getFather.slaveName>> +<<elseif $slaves[$i].pregSource in $missingTable && $showMissingSlaves>> + <<set $daddy = $missingTable[$slaves[$i].pregSource].slaveName>> <<else>> <<set $daddy = "some unknown father">> <</if>> diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw index 3ca616c3223..bcf1c498c1d 100644 --- a/src/uncategorized/BackwardsCompatibility.tw +++ b/src/uncategorized/BackwardsCompatibility.tw @@ -3437,6 +3437,16 @@ Done! <<set $brothelAdsSpending = 0>> <</if>> +<<if ndef $missingTable>> + <<set $missingTable = {}>> +<</if>> +<<if ndef $showMissingSlaves>> + <<set $showMissingSlaves = false>> +<</if>> +<<if ndef $showMissingSlavesSD>> + <<set $showMissingSlavesSD = false>> +<</if>> + <<for _bci = 0; _bci < $defaultRules.length; _bci++>> <<set _rule = $defaultRules[_bci].set>> <<if !([true, false, "no default setting"].includes(_rule.preg))>> diff --git a/src/uncategorized/options.tw b/src/uncategorized/options.tw index b54111b9499..fe994fdb72c 100644 --- a/src/uncategorized/options.tw +++ b/src/uncategorized/options.tw @@ -405,6 +405,13 @@ Male slave names are currently @@.red;FORBIDDEN@@. [[Allow|Options][$allowMaleSl <</if>> //This only affects slave generation and not your ability to name your slaves.// +<br> +<<if $showMissingSlaves>> +Missing slave names are currently @@.cyan;SHOWN@@. [[Hide|Options][$showMissingSlaves = 0]] +<<else>> +Missing slave names are currently @@.red;HIDDEN@@. [[Show|Options][$showMissingSlaves = 1]] +<</if>> + <br><br> ''INTERSECTING MECHANICS'' <br> diff --git a/src/uncategorized/summaryOptions.tw b/src/uncategorized/summaryOptions.tw index a3ba75c1c55..8cad7e4ec01 100644 --- a/src/uncategorized/summaryOptions.tw +++ b/src/uncategorized/summaryOptions.tw @@ -73,6 +73,11 @@ <br> <span id="OptionAbbreviateOrigins"><<OptionAbbreviateOrigins>></span> +<<if $showMissingSlaves>> +<br> +<span id="OptionAbbreviateMissing"><<OptionAbbreviateMissing>></span> +<</if>> + <br><br> //[[FC Dev's preferred options|Summary Options][$seeDesk = 0, $seeFCNN = 0, $sortSlavesBy = "devotion",$sortSlavesOrder = "descending",$sortSlavesMain = 0,$rulesAssistantMain = 1,$abbreviateDevotion = 1,$abbreviateRules = 1,$abbreviateClothes = 2,$abbreviateHealth = 1,$abbreviateDiet = 1,$abbreviateDrugs = 1,$abbreviateRace = 1,$abbreviateGenitalia = 1,$abbreviatePhysicals = 1,$abbreviateSkills = 1,$abbreviateMental = 1,$abbreviateSidebar = 1]]// diff --git a/src/utility/descriptionWidgetsFlesh.tw b/src/utility/descriptionWidgetsFlesh.tw index 1f9d61f314b..dd525f9535d 100644 --- a/src/utility/descriptionWidgetsFlesh.tw +++ b/src/utility/descriptionWidgetsFlesh.tw @@ -13715,6 +13715,8 @@ $He has <<else>> <<set _daddy = "partner">> <</if>> +<<elseif $activeSlave.pregSource in $missingTable && $showMissingSlaves>> + <<set _daddy = $missingTable[$activeSlave.pregSource].fullName>> <</if>> <<if ($activeSlave.preg == -2) && ($activeSlave.vagina < 0) && ($activeSlave.mpreg == 0)>> diff --git a/src/utility/extendedFamilyWidgets.tw b/src/utility/extendedFamilyWidgets.tw index 5555c84e79a..9a91f9927e5 100644 --- a/src/utility/extendedFamilyWidgets.tw +++ b/src/utility/extendedFamilyWidgets.tw @@ -13,23 +13,35 @@ <<if $activeSlave.father == -1 && $activeSlave.mother == -1>> $He's @@.lightgreen;your child;@@ you knocked yourself up and gave birth to $him. -<<elseif $activeSlave.father > 0 && $activeSlave.mother > 0 && $activeSlave.father == $activeSlave.mother>> - <<set _efw = $slaveIndices[$activeSlave.father]>> - $He was @@.lightgreen;both fathered and mothered by $slaves[_efw].slaveName.@@ +<<elseif $activeSlave.father == $activeSlave.mother && ($activeSlave.father > 0 || ($activeSlave.father in $missingTable && $showMissingSlaves))>> + <<if $activeSlave.father > 0>> + <<set _pName = $slaves[$slaveIndices[$activeSlave.father]].slaveName>> + <<else>> + <<set _pName = "your former slave "+$missingTable[$activeSlave.father].slaveName>> + <</if>> + $He was @@.lightgreen;both fathered and mothered by _pName.@@ <</if>> <<if $activeSlave.father == -1 && $activeSlave.mother != -1>> $He's @@.lightgreen;your child;@@ you knocked $his mother up. -<<elseif $activeSlave.father > 0 && $activeSlave.father != $activeSlave.mother>> - <<set _efw = $slaveIndices[$activeSlave.father]>> - $He was @@.lightgreen;fathered by $slaves[_efw].slaveName's@@ virile dick. +<<elseif ($activeSlave.father > 0 || ($activeSlave.father in $missingTable && $showMissingSlaves)) && $activeSlave.father != $activeSlave.mother>> + <<if $activeSlave.father > 0>> + <<set _pName = $slaves[$slaveIndices[$activeSlave.father]].slaveName>> + <<else>> + <<set _pName = "your former slave "+$missingTable[$activeSlave.father].slaveName>> + <</if>> + $He was @@.lightgreen;fathered by _pName's@@ virile dick. <</if>> <<if $activeSlave.father != -1 && $activeSlave.mother == -1>> $He's @@.lightgreen;your child;@@ you gave birth to $him. -<<elseif $activeSlave.mother > 0 && $activeSlave.father != $activeSlave.mother>> - <<set _efw = $slaveIndices[$activeSlave.mother]>> - $He was @@.lightgreen;born from $slaves[_efw].slaveName's@@ fertile womb. +<<elseif ($activeSlave.mother > 0 || ($activeSlave.mother in $missingTable && $showMissingSlaves)) && $activeSlave.father != $activeSlave.mother>> + <<if $activeSlave.mother > 0>> + <<set _pName = $slaves[$slaveIndices[$activeSlave.mother]].slaveName>> + <<else>> + <<set _pName = "your former slave "+$missingTable[$activeSlave.mother].slaveName>> + <</if>> + $He was @@.lightgreen;born from _pName's@@ fertile womb. <</if>> <<set _children = $slaves.filter(function(s) { return $activeSlave.ID == s.father; })>> @@ -698,18 +710,26 @@ <br><br>Your present family includes: /*Player parents, lists both your parents, or just one.*/ +<<if $showMissingSlaves>> + <<if $PC.mother in $missingTable>> + <<set $children.push($missingTable[$PC.mother])>> + <</if>> + <<if $PC.father in $missingTable && !($PC.father == $PC.mother)>> + <<set $children.push($missingTable[$PC.father])>> + <</if>> +<</if>> <<for $i = 0; $i < $slaves.length; $i++>> <<if $slaves[$i].ID == $PC.father || $slaves[$i].ID == $PC.mother>> <<set $children.push($slaves[$i])>> <</if>> <</for>> <<if $children.length > 1>> - <br>Your parents are @@.lightgreen;$children[0].slaveName and $children[1].slaveName@@. + <br>Your parents are @@.lightgreen;<<if $children[0].ID < 0>>your former slave<<if $children[1].ID < 0>>s<</if>><</if>> $children[0].slaveName and <<if $children[1].ID < 0 && $children[0].ID > 0>>your former slave<</if>> $children[1].slaveName@@. <<elseif $children.length > 0>> <<if $PC.father == $PC.mother>> - <br>Your parent is @@.lightgreen;$children[0].slaveName@@, who impregnated $himself with you. + <br>Your parent is @@.lightgreen;<<if $children[0].ID < 0>>your former slave<</if>> $children[0].slaveName@@, who impregnated $himself with you. <<else>> - <br>You know one of your parents, @@.lightgreen;$children[0].slaveName@@. + <br>You know one of your parents, @@.lightgreen;<<if $children[0].ID < 0>>your former slave<</if>> $children[0].slaveName@@. <</if>> <</if>> <<set $children = []>> diff --git a/src/utility/optionsWidgets.tw b/src/utility/optionsWidgets.tw index da0c8265dcd..c19abdd471a 100644 --- a/src/utility/optionsWidgets.tw +++ b/src/utility/optionsWidgets.tw @@ -790,3 +790,28 @@ Facilities in the sidebar are <</link>>// <</if>> <</widget>> + +/% + Call as <<OptionAbbreviateMissing>> + Should be placed in a <span> with id = "OptionAbbreviateMissing" +%/ +<<widget "OptionAbbreviateMissing">> +Missing slave parents are +<<if $showMissingSlavesSD>> + @@.cyan;SHOWN.@@ + //<<link 'Hide'>> + <<set $showMissingSlavesSD = false>> + <<replace '#OptionAbbreviateMissing'>> + <<OptionAbbreviateMissing>> + <</replace>> + <</link>>// +<<else>> + @@.red;HIDDEN.@@ + //<<link 'Show'>> + <<set $showMissingSlavesSD = true>> + <<replace '#OptionAbbreviateMissing'>> + <<OptionAbbreviateMissing>> + <</replace>> + <</link>>// +<</if>> +<</widget>> -- GitLab