diff --git a/src/facilities/nursery/childInteract.tw b/src/facilities/nursery/childInteract.tw index 5e516713c9acd17c8b836d1ca93aa98d6c72d1b2..b860288de259908e8cbe259198fbb1b9cee9ad6f 100644 --- a/src/facilities/nursery/childInteract.tw +++ b/src/facilities/nursery/childInteract.tw @@ -347,41 +347,28 @@ FIXME: <</link>> <<if $seeIncest == 1>> <<if $familyTesting == 1>> - <<for $i = 0; $i < _SL; $i++>> - <<if $activeChild.mother == $slaves[$i].ID>> - <<if isSlaveAvailable($slaves[$i])>> - | <<link "Fuck $him with $his mother">> - <<replace "#miniscene">> - <<set $partner = "mother">> - <<include "FRelation">><br> <</replace>> - <</link>> - <<else>> - //$His mother, $slaves[$i].slaveName, is unavailable// - <</if>> - <</if>> - /* - <<if $activeChild.father == $slaves[$i].ID>> - <<if isSlaveAvailable($slaves[$i])>> - | <<link "Fuck $him with $his father">> - <<replace "#miniscene">> - <<set $partner = "father">> - <<include "FRelation">><br> <</replace>> - <</link>> - <<else>> - //$His father, $slaves[$i].slaveName, is unavailable// - <</if>> - <</if>> - */ - <</for>> + <<set _availRelatives = availableRelatives($activeChild)>> + <<if _availRelatives.mother>> + | <<link "Fuck $him with $his mother">> + <<replace "#miniscene">> + <<set $partner = "mother">> + <<include "FRelation">><br> <</replace>> + <</link>> + <<elseif _availRelatives.motherName !== null>> + //$His mother, _availRelatives.motherName, is unavailable// + <</if>> + /* + <<if _availRelatives.father>> + | <<link "Fuck $him with $his father">> + <<replace "#miniscene">><<set $partner = "father">> + <<include "FRelation">><br> <</replace>> + <</link>> + <<elseif _availRelatives.fatherName !== null>> + //$His father, _availRelatives.fatherName, is unavailable// + <</if>> + */ <<if $activeChild.sisters > 0>> - <<set $relation = 0>> - <<for $i = 0; $i < _SL; $i++>> - <<setLocalPronouns $slaves[$i] 2>> - <<if areSisters($activeChild, $slaves[$i]) > 0 && !isSlaveAvailable($slaves[$i])>> - <<set $relation++>> - <</if>> - <</for>> - <<if $relation == $activeChild.sisters>> + <<if _availRelatives.sisters == 0>> <<if $activeChild.sisters == 1>> //$His _sister2 is unavailable// <<else>> @@ -1538,21 +1525,6 @@ Hormones: <b><span id="hormones">$activeChild.hormones</span>.</b> <</link>> <br><br>__Behavior__:<br> -<<set $dormitoryPopulation = 0, $roomsPopulation = 0>> -<<for $i = 0; $i < _SL; $i++>> - <<if $slaves[$i].assignmentVisible && ($slaves[$i].assignment != "be your Head Girl" || $HGSuite != 1) && ($slaves[$i].assignment != "guard you" || $dojo <= 1)>> - <<if $slaves[$i].rules.living == "luxurious">> - <<if $slaves[$i].relationship >= 4>> - <<set $roomsPopulation += 0.5>> - <<else>> - <<set $roomsPopulation++>> - <</if>> - <<else>> - <<set $dormitoryPopulation++>> - <</if>> - <</if>> -<</for>> - Living standard: <b><span id="livingRules">$activeChild.rules.living</span>.</b> //$His living conditions are managed by $nurseryName's décor.// diff --git a/src/facilities/nursery/nurseryWidgets.js b/src/facilities/nursery/nurseryWidgets.js index 22e086137b3af376f979b35bda1f0316d2bab640..5dd5ff352ce37e1b09964a0753e1f179811426d6 100644 --- a/src/facilities/nursery/nurseryWidgets.js +++ b/src/facilities/nursery/nurseryWidgets.js @@ -2165,133 +2165,80 @@ App.Facilities.Nursery.LongInfantDescription = function(child) { } } - // aunts - for (let i = 0; i < V.slaves.length; i++) { - if (V.slaves[i] === mother || V.slaves[i] === father) { - for (let j = 0; j < V.slaves.length; j++) { - if (V.slaves[j].genes === "XX") { - if (areSisters(V.slaves[i], V.slaves[j]) === 1 || areSisters(V.slaves[i], V.slaves[j] === 2)) { - V.children.push(V.slaves[j]); - } - } - } + // aunts and uncles + let aunts = [], uncles = []; + let momsiblings = V.slaves.filter((s) => { const sis = areSisters(s, child.mother); return sis === 1 || sis === 2; }); + let dadsiblings = V.slaves.filter((s) => { const sis = areSisters(s, child.father); return sis === 1 || sis === 2; }); + for (let i = 0; i < momsiblings.length; i++) { + if (momsiblings[i].genes === "XX") { + aunts.push(momsiblings[i]); + } else { + uncles.push(momsiblings[i]); } } - - if (V.children.length > 0) { - r += `${He} `; - if (V.children.length > 2) { - r += `has <span class="lightgreen">many aunts, `; - for (j = 0; j < V.children.length; j++) { - if (j < V.children.length - 1) { - r += `${V.children[j].slaveName}, `; - } else { - r += `and ${V.children[j].slaveName}.</span> `; - } - } - } else if (V.children.length === 2) { - r += `has <span class="lightgreen">two aunts, ${V.children[0].slaveName}, and ${V.children[1].slaveName}.</span> `; + for (let i = 0; i < dadsiblings.length; i++) { + if (dadsiblings[i].genes === "XX") { + aunts.push(dadsiblings[i]); } else { - r += `has <span class="lightgreen">an aunt, ${V.children[0].slaveName}.</span> `; + uncles.push(dadsiblings[i]); } } - V.children = []; - // uncles - for (let i = 0; i < V.slaves.length; i++) { - if (V.slaves[i] === mother || V.slaves[i] === father) { - for (let j = 0; j < V.slaves.length; j++) { - if (V.slaves[j].genes === "XY") { - if (areSisters(V.slaves[i], V.slaves[j]) === 1 || areSisters(V.slaves[i], V.slaves[j] === 2)) { - V.children.push(V.slaves[j]); - } - } - } + if (aunts.length > 0) { + r += `${He} `; + if (aunts.length > 2) { + r += `has <span class="lightgreen">many aunts, ${aunts.reduce(function(res, ch, i, arr) { + return (res.slaveName || res) + (i === arr.length - 1 ? ` and ` : `, `) + ch.slaveName; + })}</span> `; + } else if (aunts.length === 2) { + r += `has <span class="lightgreen">two aunts, ${aunts[0].slaveName}, and ${aunts[1].slaveName}.</span> `; + } else { + r += `has <span class="lightgreen">an aunt, ${aunts[0].slaveName}.</span> `; } } - if (V.children.length > 0) { + if (uncles.length > 0) { r += `${He} `; - if (V.children.length > 2) { - r += `has <span class="lightgreen">many uncles, `; - for (j = 0; j < V.children.length; j++) { - if (j < V.children.length - 1) { - r += `${V.children[j].slaveName}, `; - } else { - r += `and ${V.children[j].slaveName}.</span> `; - } - } - } else if (V.children.length === 2) { - r += `has <span class="lightgreen">two uncles, ${V.children[0].slaveName}, and ${V.children[1].slaveName}.</span> `; + if (uncles.length > 2) { + r += `has <span class="lightgreen">many uncles, ${uncles.reduce(function(res, ch, i, arr) { + return (res.slaveName || res) + (i === arr.length - 1 ? ` and ` : `, `) + ch.slaveName; + })}</span> `; + } else if (uncles.length === 2) { + r += `has <span class="lightgreen">two uncles, ${uncles[0].slaveName}, and ${uncles[1].slaveName}.</span> `; } else { - r += `has <span class="lightgreen">an uncle, ${V.children[0].slaveName}.</span> `; + r += `has <span class="lightgreen">an uncle, ${uncles[0].slaveName}.</span> `; } } - V.children = []; - // nieces - for (let i = 0; i < V.slaves.length; i++) { - if (areSisters(V.slaves[i], child) === 1 || areSisters(V.slaves[i], child) === 2) { - for (let j = 0; j < V.slaves.length; j++) { - if (V.slaves[i].ID !== V.slaves[j].ID && V.slaves[j].genes === "XX") { - if (V.slaves[i].ID === V.slaves[j].mother || V.slaves[i].ID === V.slaves[j].father) { - V.children.push(V.slaves[j]); - } - } - } - } - } + // nieces and nephews + let nieces = $slaves.filter((s) => { return (isAunt(s, $activeSlave) && (s.genes === "XX")); }); + let nephews = $slaves.filter((s) => { return (isAunt(s, $activeSlave) && (s.genes === "XY")); }); - if (V.children.length > 0) { + if (nieces.length > 0) { r += `${He} `; - if (V.children.length > 2) { - r += `has <span class="lightgreen">many nieces, `; - for (j = 0; j < V.children.length; j++) { - if (j < V.children.length - 1) { - r += `${V.children[j].slaveName}, `; - } else { - r += `and ${V.children[j].slaveName}.</span> `; - } - } - } else if (V.children.length === 2) { - r += `has <span class="lightgreen">two nieces, ${V.children[0].slaveName}, and ${V.children[1].slaveName}.</span> `; + if (nieces.length > 2) { + r += `has <span class="lightgreen">many nieces, ${nieces.reduce(function(res, ch, i, arr) { + return (res.slaveName || res) + (i === arr.length - 1 ? ` and ` : `, `) + ch.slaveName; + })}</span> `; + } else if (nieces.length === 2) { + r += `has <span class="lightgreen">two nieces, ${nieces[0].slaveName}, and ${nieces[1].slaveName}.</span> `; } else { - r += `has <span class="lightgreen">a niece, ${V.children[0].slaveName}.</span> `; + r += `has <span class="lightgreen">a niece, ${nieces[0].slaveName}.</span> `; } } - V.children = []; - // nephews - for (let i = 0; i < V.slaves.length; i++) { - if (areSisters(V.slaves[i], child) === 1 || areSisters(V.slaves[i], child) === 2) { - for (let j = 0; j < V.slaves.length; j++) { - if (V.slaves[i].ID !== V.slaves[j].ID && V.slaves[j].genes === "XY") { - if (V.slaves[i].ID === V.slaves[j].mother || V.slaves[i].ID === V.slaves[j].father) { - V.children.push(V.slaves[j]); - } - } - } - } - } - - if (V.children.length > 0) { + if (nephews.length > 0) { r += `${He} `; - if (V.children.length > 2) { - r += `has <span class="lightgreen">many nephews, `; - for (j = 0; j < V.children.length; j++) { - if (j < V.children.length - 1) { - r += `${V.children[j].slaveName}, `; - } else { - r += `and ${V.children[j].slaveName}.</span> `; - } - } - } else if (V.children.length === 2) { - r += `has <span class="lightgreen">two nephews, ${V.children[0].slaveName}, and ${V.children[1].slaveName}.</span> `; + if (nephews.length > 2) { + r += `has <span class="lightgreen">many nephews, ${nephews.reduce(function(res, ch, i, arr) { + return (res.slaveName || res) + (i === arr.length - 1 ? ` and ` : `, `) + ch.slaveName; + })}</span> `; + } else if (nephews.length === 2) { + r += `has <span class="lightgreen">two nephews, ${nephews[0].slaveName}, and ${nephews[1].slaveName}.</span> `; } else { - r += `has <span class="lightgreen">a nephew, ${V.children[0].slaveName}.</span> `; + r += `has <span class="lightgreen">a nephew, ${nephews[0].slaveName}.</span> `; } } - V.children = []; let twins = [], diff --git a/src/js/extendedFamilyModeJS.js b/src/js/extendedFamilyModeJS.js index b9000e4042ce64623f8a4d034fd33311557ef59d..44f1bb4c4c128f8f068fac442ca46c596b339fe0 100644 --- a/src/js/extendedFamilyModeJS.js +++ b/src/js/extendedFamilyModeJS.js @@ -31,7 +31,7 @@ window.isGrandfatherP = function isGrandfatherP(granddaughter, grandfather) { }; window.isGrandparentP = function isGrandparentP(granddaughter, grandparent) { - return isGrandmotherP(daughter, parent) || isGrandfatherP(daughter, parent); + return isGrandmotherP(granddaughter, grandparent) || isGrandfatherP(granddaughter, grandparent); }; window.sameDad = function(slave1, slave2) { @@ -369,6 +369,41 @@ window.randomAvailableParent = function(slave) { }); }; +/** + * @param {App.Entity.SlaveState} slave + * @returns {Object} + */ +window.availableRelatives = function(slave) { + let avail = { + mother: false, motherName: null, father: false, fatherName: null, sisters: 0, daughters: 0 + }; + + V.slaves.forEach((other) => { + if (slave.mother === other.ID) { + avail.motherName = other.slaveName; + } + if (slave.father === other.ID) { + avail.fatherName = other.slaveName; + } + if (isSlaveAvailable(other)) { + if (slave.mother === other.ID) { + avail.mother = true; + } + if (slave.father === other.ID) { + avail.father = true; + } + if (slave.ID === other.mother || slave.ID === other.father) { + avail.daughters++; + } + if (areSisters(slave, other) > 0) { + avail.sisters++; + } + } + }); + + return avail; +}; + window.totalPlayerRelatives = function(pc) { let relatives = 0; if (pc.mother > 0) { diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw index 68e1e121b2478f95b050df3182c2b0560eba6817..587b7fb41ccebe289c488e78d2822ec7ea24a96a 100644 --- a/src/uncategorized/slaveInteract.tw +++ b/src/uncategorized/slaveInteract.tw @@ -243,33 +243,21 @@ | <<link "Abuse $him">><<replace "#miniscene">><<include "FAbuse">><</replace>><</link>> <<if $seeIncest == 1>> <<if $familyTesting == 1>> - <<for $i = 0; $i < _SL; $i++>> - <<if $activeSlave.mother == $slaves[$i].ID>> - <<if isSlaveAvailable($slaves[$i])>> - | <<link "Fuck $him with $his mother">><<replace "#miniscene">><<set $partner = "mother">><<include "FRelation">><br> <</replace>><</link>> - <<else>> - //$His mother, $slaves[$i].slaveName, is unavailable// - <</if>> - <</if>> - /* - <<if $activeSlave.father == $slaves[$i].ID>> - <<if isSlaveAvailable($slaves[$i])>> - | <<link "Fuck $him with $his father">><<replace "#miniscene">><<set $partner = "father">><<include "FRelation">><br> <</replace>><</link>> - <<else>> - //$His father, $slaves[$i].slaveName, is unavailable// - <</if>> - <</if>> - */ - <</for>> + <<set _availRelatives = availableRelatives($activeSlave)>> + <<if _availRelatives.mother>> + | <<link "Fuck $him with $his mother">><<replace "#miniscene">><<set $partner = "mother">><<include "FRelation">><br> <</replace>><</link>> + <<elseif _availRelatives.motherName !== null>> + //$His mother, _availRelatives.motherName, is unavailable// + <</if>> + /* + <<if _availRelatives.father>> + | <<link "Fuck $him with $his father">><<replace "#miniscene">><<set $partner = "father">><<include "FRelation">><br> <</replace>><</link>> + <<elseif _availRelatives.fatherName !== null>> + //$His father, _availRelatives.fatherName, is unavailable// + <</if>> + */ <<if $activeSlave.daughters > 0>> - <<set $relation = 0>> - <<for $i = 0; $i < _SL; $i++>> - <<setLocalPronouns $slaves[$i] 2>> - <<if ($activeSlave.ID == $slaves[$i].father || $activeSlave.ID == $slaves[$i].mother) && !isSlaveAvailable($slaves[$i])>> - <<set $relation++>> - <</if>> - <</for>> - <<if $relation == $activeSlave.daughters>> + <<if _availRelatives.daughters == 0>> <<if $activeSlave.daughters == 1>> //$His _daughter2 is unavailable// <<else>> @@ -281,22 +269,15 @@ <<else>> | <<link "Fuck $him with one of $his daughters">><<replace "#miniscene">><<set $partner = "daughter">><<include "FRelation">><br> <</replace>><</link>> <</if>> + /* + <<if _availRelatives.daughters > 1>> + | <<link "Fuck $him with $his daughters">><<replace "#miniscene">><<set $partner = "daughters">><<include "FRelation">><br> <</replace>><</link>> + <</if>> + */ <</if>> <</if>> - /* - <<if $activeSlave.daughters > 1>> - | <<link "Fuck $him with $his daughters">><<replace "#miniscene">><<set $partner = "daughters">><<include "FRelation">><br> <</replace>><</link>> - <</if>> - */ <<if $activeSlave.sisters > 0>> - <<set $relation = 0>> - <<for $i = 0; $i < _SL; $i++>> - <<setLocalPronouns $slaves[$i] 2>> - <<if areSisters($activeSlave, $slaves[$i]) > 0 && !isSlaveAvailable($slaves[$i])>> - <<set $relation++>> - <</if>> - <</for>> - <<if $relation == $activeSlave.sisters>> + <<if _availRelatives.sisters == 0>> <<if $activeSlave.sisters == 1>> //$His _sister2 is unavailable// <<else>> @@ -308,13 +289,13 @@ <<else>> | <<link "Fuck $him with one of $his sisters">><<replace "#miniscene">><<set $partner = "sister">><<include "FRelation">><br> <</replace>><</link>> <</if>> + /* + <<if _availRelatives.sisters > 1>> + | <<link "Fuck $him with $his sisters">><<replace "#miniscene">><<set $partner = "sisters">><<include "FRelation">><br> <</replace>><</link>> + <</if>> + */ <</if>> <</if>> - /* - <<if $activeSlave.sisters > 1>> - | <<link "Fuck $him with $his sisters">><<replace "#miniscene">><<set $partner = "sisters">><<include "FRelation">><br> <</replace>><</link>> - <</if>> - */ <<else>> <<if ($activeSlave.relation != 0)>> <<set _assayedSlave = getSlave($activeSlave.relationTarget)>> @@ -1527,20 +1508,10 @@ Hormones: <strong><span id="hormones"> <<if $activeSlave.fuckdoll > 0>> //Rules have little meaning for living sex toys// <<else>> - <<set $dormitoryPopulation = 0, $roomsPopulation = 0>> - <<for $i = 0; $i < _SL; $i++>> - <<if $slaves[$i].assignmentVisible == 1 && ($slaves[$i].assignment != "be your Head Girl" || $HGSuite != 1) && ($slaves[$i].assignment != "guard you" || $dojo <= 1)>> - <<if $slaves[$i].rules.living == "luxurious">> - <<if $slaves[$i].relationship >= 4>> - <<set $roomsPopulation += 0.5>> - <<else>> - <<set $roomsPopulation++>> - <</if>> - <<else>> - <<set $dormitoryPopulation++>> - <</if>> - <</if>> - <</for>> + <<set _visibleSlaves = $slaves.filter(s => s.assignmentVisible == 1 && (s.assignment != "be your Head Girl" || $HGSuite != 1) && (s.assignment != "guard you" || $dojo <= 1)), + $dormitoryPopulation = _visibleSlaves.filter(s => s.rules.living != "luxurious").length, + $roomsPopulation = $slavesVisible - $dormitoryPopulation - _visibleSlaves.filter(s => s.rules.living == "luxurious" && s.relationship >= 4).length * 0.5>> + Living standard: ''<span id="livingRules">$activeSlave.rules.living</span>.'' <<if setup.facilityCareers.includes($activeSlave.assignment)>> //$His living conditions are managed by $his assignment.// diff --git a/src/utility/extendedFamilyWidgets.tw b/src/utility/extendedFamilyWidgets.tw index b66d4b481b166fb02a44df974056520ba89ef065..1872c453e6cf96a6c989495720a804ed36c65605 100644 --- a/src/utility/extendedFamilyWidgets.tw +++ b/src/utility/extendedFamilyWidgets.tw @@ -46,14 +46,7 @@ <<set _children = $slaves.filter(function(s) { return $activeSlave.ID == s.father; })>> <<if _children.length > 2>> - $He @@.lightgreen;fathered - <<for _efw = 0; _efw < _children.length; _efw++>> - <<if _efw < _children.length-1>> - _children[_efw].slaveName, - <<else>> - and _children[_efw].slaveName.@@ - <</if>> - <</for>> + $He @@.lightgreen;fathered <<print _children.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ <<elseif _children.length > 1>> $He @@.lightgreen;fathered a pair of your slaves: _children[0].slaveName, and _children[1].slaveName.@@ <<elseif _children.length > 0>> @@ -62,14 +55,7 @@ <<set _children = $slaves.filter(function(s) { return $activeSlave.ID == s.mother; })>> <<if _children.length > 2>> - $He @@.lightgreen;gave birth to - <<for _efw = 0; _efw < _children.length; _efw++>> - <<if _efw < _children.length-1>> - _children[_efw].slaveName, - <<else>> - and _children[_efw].slaveName.@@ - <</if>> - <</for>> + $He @@.lightgreen;gave birth to <<print _children.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ <<elseif _children.length > 1>> $He @@.lightgreen;gave birth to a pair of your slaves: _children[0].slaveName, and _children[1].slaveName.@@ <<elseif _children.length > 0>> @@ -178,388 +164,160 @@ <</if>> /*testtest grandchild passage - determines how many grandchildren the current slave has*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if $activeSlave.ID == $slaves[$i].mother || $activeSlave.ID == $slaves[$i].father>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$i].ID != $slaves[$j].ID>> - <<if $slaves[$i].ID == $slaves[$j].mother || $slaves[$i].ID == $slaves[$j].father>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</for>> - <</if>> - <</if>> - <</for>> + <<set $children = $slaves.filter((s) => { return isGrandparentP(s, $activeSlave); });>> <<if $children.length > 0>> $He <<if $children.length > 2>> - has @@.lightgreen;many grandchildren, - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName amongst your slaves.@@ - <</if>> - <</for>> + has @@.lightgreen;many grandchildren, <<print $children.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>, amongst your slaves.@@ <<elseif $children.length > 1>> has @@.lightgreen;two grandchildren, $children[0].slaveName, and $children[1].slaveName as your slaves.@@ - <<elseif $children.length > 0>> + <<else>> has a @@.lightgreen;grandchild, $children[0].slaveName as your slave.@@ <</if>> <</if>> <<set $children = []>> - /*testtest PC aunt passage - determines how many aunts you have*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if areSisters($slaves[$i], $activeSlave) == 1 || areSisters($slaves[$i], $activeSlave) == 2>> - <<if $slaves[$i].ID == $PC.mother || $slaves[$i].ID == $PC.father>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$i].ID != $slaves[$j].ID>> - <<if $slaves[$j].genes == "XX">> - <<if areSisters($slaves[$j], $activeSlave) == 1 || areSisters($slaves[$j], $activeSlave) == 2>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</if>> - <</for>> + /*testtest PC aunt and uncle passage - determines how many aunts and uncles you have*/ + <<set _aunts = [], _uncles = []>> + <<if isAunt($PC, $activeSlave)>> + <<set _momsiblings = $slaves.filter((s) => { const sis = areSisters(s, $PC.mother); return sis == 1 || sis == 2; }), + _dadsiblings = $slaves.filter((s) => { const sis = areSisters(s, $PC.father); return sis == 1 || sis == 2; })>> + <<for $i = 0; $i < _momsiblings.length; $i++>> + <<if _momsiblings[$i].ID != $activeSlave.ID>> + <<if _momsiblings[$i].genes == "XX">> + <<set _aunts.push(_momsiblings[$i])>> + <<else>> + <<set _uncles.push(_momsiblings[$i])>> <</if>> <</if>> - <</if>> - <</for>> - <<if $activeSlave.genes == "XX" && $children.length > 0>> - $He - <<if $children.length > 2>> - is @@.lightgreen;your aunt along with - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, + <</for>> + <<for $i = 0; $i < _dadsiblings.length; $i++>> + <<if _dadsiblings[$i].ID != $activeSlave.ID>> + <<if _dadsiblings[$i].genes == "XX">> + <<set _aunts.push(_dadsiblings[$i])>> <<else>> - and $children[$j].slaveName.@@ + <<set _uncles.push(_dadsiblings[$i])>> <</if>> - <</for>> - <<elseif $children.length > 1>> - is @@.lightgreen;your aunt along with $children[0].slaveName.@@ - <<elseif $children.length > 0>> - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID && $activeSlave.genes == "XX">> - <<if areSisters($slaves[$i], $activeSlave) == 1 || areSisters($slaves[$i], $activeSlave) == 2>> - <<if $slaves[$i].ID == $PC.mother || $slaves[$i].ID == $PC.father>> - $He is @@.lightgreen;your aunt.@@ - <</if>> - <</if>> - <</if>> - <</for>> - <</if>> - <</if>> - <<set $children = []>> + <</if>> + <</for>> - /*testtest PC uncle passage - determines how many uncles you have*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if areSisters($slaves[$i], $activeSlave) == 1 || areSisters($slaves[$i], $activeSlave) == 2>> - <<if $slaves[$i].ID == $PC.mother || $slaves[$i].ID == $PC.father>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$i].ID != $slaves[$j].ID && $slaves[$j].dick > 0 && $slaves[$j].genes == "XY">> - <<if areSisters($slaves[$j], $activeSlave) == 1 || areSisters($slaves[$j], $activeSlave) == 2>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</for>> - <</if>> + <<if $activeSlave.genes == "XX">> + $He + <<if _aunts.length > 1>> + is @@.lightgreen;your aunt along with <<print _aunts.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ + <<elseif _aunts.length > 0>> + is @@.lightgreen;your aunt along with _aunts[0].slaveName.@@ + <<else>> + is @@.lightgreen;your aunt.@@ + <</if>> + <<else>> + $He + <<if _uncles.length > 1>> + is @@.lightgreen;your uncle along with <<print _uncles.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ + <<elseif _uncles.length > 0>> + is @@.lightgreen;your uncle along with _uncles[0].slaveName.@@ + <<else>> + is @@.lightgreen;your uncle.@@ <</if>> - <</if>> - <</for>> - <<if $activeSlave.genes == "XY" && $children.length > 0>> - $He - <<if $children.length > 2>> - is @@.lightgreen;your uncle along with - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName.@@ - <</if>> - <</for>> - <<elseif $children.length > 1>> - is @@.lightgreen;your uncle along with $children[0].slaveName.@@ - <<elseif $children.length > 0>> - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID && $activeSlave.genes == "XY">> - <<if areSisters($slaves[$i], $activeSlave) == 1 || areSisters($slaves[$i], $activeSlave) == 2>> - <<if $slaves[$i].ID == $PC.mother || $slaves[$i].ID == $PC.father>> - $He is @@.lightgreen;your uncle.@@ - <</if>> - <</if>> - <</if>> - <</for>> <</if>> <</if>> - <<set $children = []>> - /*testtest aunt passage - determines how many aunts a slave has*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if $slaves[$i].ID == $activeSlave.mother || $slaves[$i].ID == $activeSlave.father>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$j].genes == "XX">> - <<if areSisters($slaves[$j], $slaves[$i]) == 1 || areSisters($slaves[$j], $slaves[$i]) == 2>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</for>> - <</if>> + /*testtest aunt and uncle passage - determines how many aunts and uncles a slave has*/ + <<set _aunts = [], _uncles = []>> + <<set _momsiblings = $slaves.filter((s) => { const sis = areSisters(s, $activeSlave.mother); return sis == 1 || sis == 2; }), + _dadsiblings = $slaves.filter((s) => { const sis = areSisters(s, $activeSlave.father); return sis == 1 || sis == 2; })>> + <<for $i = 0; $i < _momsiblings.length; $i++>> + <<if _momsiblings[$i].genes == "XX">> + <<set _aunts.push(_momsiblings[$i])>> + <<else>> + <<set _uncles.push(_momsiblings[$i])>> <</if>> <</for>> - <<if $children.length > 0>> - $He - <<if $children.length > 2>> - has @@.lightgreen;many aunts, - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName.@@ - <</if>> - <</for>> - <<elseif $children.length > 1>> - has @@.lightgreen;two aunts, $children[0].slaveName, and $children[1].slaveName.@@ - <<elseif $children.length > 0>> - has @@.lightgreen;an aunt, $children[0].slaveName.@@ - <</if>> - <</if>> - <<set $children = []>> - - /*testtest uncle passage - determines how many uncles a slave has*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if $slaves[$i].ID == $activeSlave.mother || $slaves[$i].ID == $activeSlave.father>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$j].genes == "XY">> - <<if areSisters($slaves[$j], $slaves[$i]) == 1 || areSisters($slaves[$j], $slaves[$i]) == 2>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</for>> - <</if>> + <<for $i = 0; $i < _dadsiblings.length; $i++>> + <<if _dadsiblings[$i].genes == "XX">> + <<set _aunts.push(_dadsiblings[$i])>> + <<else>> + <<set _uncles.push(_dadsiblings[$i])>> <</if>> <</for>> - <<if $children.length > 0>> + + <<if _aunts.length > 0>> $He - <<if $children.length > 2>> - has @@.lightgreen;many uncles, - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName.@@ - <</if>> - <</for>> - <<elseif $children.length > 1>> - has @@.lightgreen;two uncles, $children[0].slaveName, and $children[1].slaveName.@@ - <<elseif $children.length > 0>> - has @@.lightgreen;an uncle, $children[0].slaveName.@@ + <<if _aunts.length > 2>> + has @@.lightgreen;many aunts, <<print _aunts.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ + <<elseif _aunts.length > 1>> + has @@.lightgreen;two aunts, _aunts[0].slaveName, and _aunts[1].slaveName.@@ + <<else>> + has @@.lightgreen;an aunt, _aunts[0].slaveName.@@ <</if>> <</if>> - <<set $children = []>> - - /*testtest PC niece passage - determines how many nieces you have*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if areSisters($slaves[$i], $PC) == 1 || areSisters($slaves[$i], $PC) == 2>> - <<if $slaves[$i].ID == $activeSlave.mother || $slaves[$i].ID == $activeSlave.father>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$i].ID != $slaves[$j].ID && $slaves[$j].ID != $activeSlave.ID && $slaves[$j].genes == "XX">> - <<if $slaves[$i].ID == $slaves[$j].mother || $slaves[$i].ID == $slaves[$j].father>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</for>> - <</if>> - <</if>> - <</if>> - <</for>> - <<if $activeSlave.genes == "XX" && $children.length > 0>> + <<if _uncles.length > 0>> $He - <<if $children.length > 2>> - is @@.lightgreen;your niece along with - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName.@@ - <</if>> - <</for>> - <<elseif $children.length > 1>> - is @@.lightgreen;your niece along with $children[0].slaveName.@@ - <<elseif $children.length > 0>> - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID && $activeSlave.genes == "XX">> - <<if areSisters($slaves[$i], $PC) == 1 || areSisters($slaves[$i], $PC) == 2>> - <<if $slaves[$i].ID == $activeSlave.mother || $slaves[$i].ID == $activeSlave.father>> - is @@.lightgreen;your niece.@@ - <</if>> - <</if>> - <</if>> - <</for>> + <<if _uncles.length > 2>> + has @@.lightgreen;many uncles, <<print _uncles.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ + <<elseif _uncles.length > 1>> + has @@.lightgreen;two uncles, _uncles[0].slaveName, and _uncles[1].slaveName.@@ + <<else>> + has @@.lightgreen;an uncle, _uncles[0].slaveName.@@ <</if>> <</if>> - <<set $children = []>> - /* testtest niece passage - determines how many nieces a slave has*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if areSisters($slaves[$i], $activeSlave) == 1 || areSisters($slaves[$i], $activeSlave) == 2>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$i].ID != $slaves[$j].ID && $slaves[$j].ID != $activeSlave.ID && $slaves[$j].genes == "XX">> - <<if $slaves[$i].ID == $slaves[$j].mother || $slaves[$i].ID == $slaves[$j].father>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</for>> + /*testtest PC niece and nephew passage - determines how many nieces and nephews you have*/ + <<set _nieces = [], _nephews = []>> + <<if isAunt($activeSlave, $PC)>> + <<set _nieces = $slaves.filter((s) => { return (isAunt(s, $PC) && (s.genes == "XX")); })>> + <<set _nephews = $slaves.filter((s) => { return (isAunt(s, $PC) && (s.genes == "XY")); })>> + + <<if $activeSlave.genes == "XX">> + $He + <<if _nieces.length > 1>> + is @@.lightgreen;your niece along with <<print _nieces.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ + <<elseif _nieces.length > 0>> + is @@.lightgreen;your niece along with _nieces[0].slaveName.@@ + <<else>> + is @@.lightgreen;your niece.@@ + <</if>> + <<else>> + $He + <<if _nephews.length > 1>> + is @@.lightgreen;your nephew along with <<print _nephews.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ + <<elseif _nephews.length > 0>> + is @@.lightgreen;your nephew along with _nephews[0].slaveName.@@ + <<else>> + is @@.lightgreen;your nephew.@@ <</if>> - <</if>> - <</for>> - <<if $children.length > 0>> - $He - <<if $children.length > 2>> - has @@.lightgreen;many nieces, - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName, who are your slaves.@@ - <</if>> - <</for>> - <<elseif $children.length > 1>> - has @@.lightgreen;two nieces, $children[0].slaveName, and $children[1].slaveName, who are your slaves.@@ - <<elseif $children.length > 0>> - has @@.lightgreen;a niece, $children[0].slaveName, who is your slave.@@ <</if>> <</if>> - <<set $children = []>> - /*testtest PC nephew passage - determines how many nephews you have*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if areSisters($slaves[$i], $PC) == 1 || areSisters($slaves[$i], $PC) == 2>> - <<if $slaves[$i].ID == $activeSlave.mother || $slaves[$i].ID == $activeSlave.father>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$i].ID != $slaves[$j].ID && $slaves[$j].ID != $activeSlave.ID && $slaves[$i].genes == "XY">> - <<if $slaves[$i].ID == $slaves[$j].mother || $slaves[$i].ID == $slaves[$j].father>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</for>> - <</if>> - <</if>> - <</if>> - <</for>> - <<if $activeSlave.genes == "XY" && $children.length > 0>> + /* testtest niece and nephew passage - determines how many nieces and nephews a slave has*/ + <<set _nieces = $slaves.filter((s) => { return( (s.ID != $activeSlave.ID) && (isAunt(s, $activeSlave)) && (s.genes == "XX")); })>> + <<set _nephews = $slaves.filter((s) => { return( (s.ID != $activeSlave.ID) && (isAunt(s, $activeSlave)) && (s.genes == "XY")); })>> + + <<if _nieces.length > 0>> $He - <<if $children.length > 2>> - is @@.lightgreen;your nephew along with - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName.@@ - <</if>> - <</for>> - <<elseif $children.length > 1>> - is @@.lightgreen;your nephew along with $children[0].slaveName.@@ - <<elseif $children.length > 0>> - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID && $activeSlave.genes == "XY">> - <<if areSisters($slaves[$i], $PC) == 1 || areSisters($slaves[$i], $PC) == 2>> - <<if $slaves[$i].ID == $activeSlave.mother || $slaves[$i].ID == $activeSlave.father>> - is @@.lightgreen;your nephew.@@ - <</if>> - <</if>> - <</if>> - <</for>> + <<if _nieces.length > 2>> + has @@.lightgreen;many nieces, <<print _nieces.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>, who are your slaves.@@ + <<elseif _nieces.length > 1>> + has @@.lightgreen;two nieces, _nieces[0].slaveName, and _nieces[1].slaveName, who are your slaves.@@ + <<else>> + has @@.lightgreen;a niece, _nieces[0].slaveName, who is your slave.@@ <</if>> <</if>> - <<set $children = []>> - /* testtest nephew passage - determines how many nephews a slave has*/ - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if areSisters($slaves[$i], $activeSlave) == 1 || areSisters($slaves[$i], $activeSlave) == 2>> - <<for $j = 0; $j < $slaves.length; $j++>> - <<if $slaves[$i].ID != $slaves[$j].ID && $slaves[$j].ID != $activeSlave.ID && $slaves[$j].genes == "XY">> - <<if $slaves[$i].ID == $slaves[$j].mother || $slaves[$i].ID == $slaves[$j].father>> - <<set $children.push($slaves[$j])>> - <</if>> - <</if>> - <</for>> - <</if>> - <</if>> - <</for>> - <<if $children.length > 0>> + <<if _nephews.length > 0>> $He - <<if $children.length > 2>> - has @@.lightgreen;many nephews, - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName, who are your slaves.@@ - <</if>> - <</for>> - <<elseif $children.length > 1>> - has @@.lightgreen;two nephews, $children[0].slaveName, and $children[1].slaveName, who are your slaves.@@ - <<elseif $children.length > 0>> - has @@.lightgreen;a nephew, $children[0].slaveName, who is your slave.@@ + <<if _nephews.length > 2>> + has @@.lightgreen;many nephews, <<print _nephews.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>, who are your slaves.@@ + <<elseif _nephews.length > 1>> + has @@.lightgreen;two nephews, _nephews[0].slaveName, and _nephews[1].slaveName, who are your slaves.@@ + <<else>> + has @@.lightgreen;a nephew, _nephews[0].slaveName, who is your slave.@@ <</if>> <</if>> <<set $children = []>> <</if>> /* end distant relatives toggle check */ -/*testtest PC sibling passages - determines how many siblings you have -<<set $children = []>> -<<set _rel_num = areSisters($activeSlave, $PC)>> -<<if(_rel_num > 0)>> - <<if ($activeSlave.genes == "XX")>> - <<set _rel_type = "sister">> - <<else>> - <<set _rel_type = "brother">> - <</if>> - <<if (_rel_num == 1)>> - <<set _rel_desc = "your twin">> - <<elseif _rel_num == 2>> - <<set _rel_desc = "your ">> - <<elseif _rel_num == 3>> - <<set _rel_desc = "your half-">> - <</if>> - <<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $activeSlave.ID>> - <<if _rel_num == areSisters($activeSlave, $slaves[$i]) && ($activeSlave.vagina > -1) == ($slaves[$i].vagina > -1)>> - <<set console.log('sisters', $slaves[$i].birthName)>> - <<set $children.push($slaves[$i])>> - <</if>> - <</if>> - <</for>> - $He - <<if $children.length > 1>> - @@.lightgreen;is _rel_desc _rel_type along with - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName.@@ - <</if>> - <</for>> - <<elseif $children.length > 0>> - is @@.lightgreen;_rel_desc _rel_type with $children[0].slaveName.@@ - <<else>> - is @@.lightgreen;_rel_desc _rel_type.@@ - <</if>> -<</if>> -<<set $children = []>> -*/ - +/*testtest PC sibling passages - determines how many siblings you have*/ <<set _twins = [], _sisters = [], _brothers = [], _halfsisters = [], _halfbrothers = [], _cousins = []>> <<for _efw = 0; _efw < $slaves.length; _efw++>> <<set _sisterCheck = areSisters($slaves[_efw], $activeSlave)>> @@ -573,8 +331,7 @@ <<run ($slaves[_efw].genes == 'XX' ? _halfsisters : _halfbrothers).push($slaves[_efw])>> <</if>> <<if (def $showDistantRelatives) && $showDistantRelatives == 1>> - <<set _cousinCheck = areCousins($slaves[_efw], $activeSlave)>> - <<if _cousinCheck == true>> + <<if areCousins($slaves[_efw], $activeSlave) == true>> <<run _cousins.push($slaves[_efw])>> <</if>> <</if>> @@ -675,15 +432,7 @@ /*testtest half-sister - determines how many half-sisters a slave has*/ <<set _children = $slaves.filter(function(s) { return s.ID != $activeSlave.ID && areSisters($activeSlave, s) == 3 && s.genes == "XX"; })>> <<if _children.length > 2>> - @@.lightgreen; - <<for _efw = 0; _efw < _children.length; _efw++>> - <<if _efw < _children.length-1>> - _children[_efw].slaveName, - <<else>> - and _children[_efw].slaveName - <</if>> - <</for>> - are half-sisters to $him.@@ + @@.lightgreen;<<print _children.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>> are half-sisters to $him.@@ <<elseif _children.length > 1>> @@.lightgreen;_children[0].slaveName and _children[1].slaveName are half-sisters to $him.@@ <<elseif _children.length > 0>> @@ -694,15 +443,7 @@ /*testtest half-brother - determines how many half-brothers a slave has*/ <<set _children = $slaves.filter(function(s) { return s.ID != $activeSlave.ID && areSisters($activeSlave, s) == 3 && s.genes == "XY"; })>> <<if _children.length > 2>> - @@.lightgreen; - <<for _efw = 0; _efw < _children.length; _efw++>> - <<if _efw < _children.length-1>> - _children[_efw].slaveName, - <<else>> - and _children[_efw].slaveName - <</if>> - <</for>> - are half-brothers to $him.@@ + @@.lightgreen;<<print _children.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>> are half-brothers to $him.@@ <<elseif _children.length > 1>> @@.lightgreen;_children[0].slaveName and _children[1].slaveName are half-brothers to $him.@@ <<elseif _children.length > 0>> @@ -716,7 +457,7 @@ <<if _cousins.length > 1>> @@.lightgreen;is your cousin along with <<print _cousins.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>>.@@ <<elseif _cousins.length > 0>> - is @@.lightgreen;your cousin along with _sisters[0].slaveName.@@ + is @@.lightgreen;your cousin along with _cousins[0].slaveName.@@ <<else>> is @@.lightgreen;your cousin.@@ <</if>> @@ -725,15 +466,7 @@ /*testtest cousin - determines how many cousins a slave has*/ <<set _children = $slaves.filter(function(s) { return s.ID != $activeSlave.ID && areCousins($activeSlave, s)})>> <<if _children.length > 2>> - @@.lightgreen; - <<for _efw = 0; _efw < _children.length; _efw++>> - <<if _efw < _children.length-1>> - _children[_efw].slaveName, - <<else>> - and _children[_efw].slaveName - <</if>> - <</for>> - are cousins to $him.@@ + @@.lightgreen;<<print _children.reduce(function(res, ch, i, arr) { return (res.slaveName || res) + (i == arr.length - 1 ? ' and ' : ', ') + ch.slaveName; })>> are cousins to $him.@@ <<elseif _children.length > 1>> @@.lightgreen;_children[0].slaveName and _children[1].slaveName are cousins to $him.@@ <<elseif _children.length > 0>>