From ce99fd11adc9f1c594496fa26083e7bc7d87db49 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sun, 5 Apr 2020 00:58:32 -0700 Subject: [PATCH] Replace <<PlayerFamily>> with App.Desc.family. Also adds $showDistantRelatives support for Personal Affairs page. --- src/descriptions/familySummaries.js | 175 ++++++++++++++++++++- src/pregmod/managePersonalAffairs.tw | 2 +- src/utility/extendedFamilyWidgets.tw | 225 --------------------------- 3 files changed, 173 insertions(+), 229 deletions(-) diff --git a/src/descriptions/familySummaries.js b/src/descriptions/familySummaries.js index b93d1321afb..01ba8e4f569 100644 --- a/src/descriptions/familySummaries.js +++ b/src/descriptions/familySummaries.js @@ -58,11 +58,11 @@ App.Desc.family = (function() { /* PC parentage */ if (slave.ID === V.PC.mother && slave.ID === V.PC.father) { - r.push(`${He} <span class="lightgreen">is both your mother and father;</span> ${he} impregnated ${himself} with you.`); + r.push(`${He} is <span class="lightgreen">both your mother and father;</span> ${he} impregnated ${himself} with you.`); } else if (slave.ID === V.PC.mother) { - r.push(`${He} <span class="lightgreen">is your mother.</span>`); + r.push(`${He} is <span class="lightgreen">your mother.</span>`); } else if (slave.ID === V.PC.father) { - r.push(`${He} <span class="lightgreen">is your father.</span>`); + r.push(`${He} is <span class="lightgreen">your father.</span>`); } if (slave.father === -1 && slave.mother === -1) { @@ -479,6 +479,175 @@ App.Desc.family = (function() { function PCFamilySummary() { let r = []; + r.push(`<br>Your family records show that:`); + + /* Player parents, lists both your parents, or just one. */ + let parents = []; + if (V.showMissingSlaves) { + if (V.PC.mother in V.missingTable) { + parents.push(V.missingTable[V.PC.mother]); + } + if (V.PC.father in V.missingTable && (V.PC.father !== V.PC.mother)) { + parents.push(V.missingTable[V.PC.father]); + } + } + parents.concat(V.slaves.filter((s) => isParentP(V.PC, s))); + + if (parents.length > 1) { + r.push(`<br>Your parents are <span class="lightgreen">${knownSlave(parents[0].ID)} and ${knownSlave(parents[1].ID)}.</span>`); + } else if (parents.length > 0) { + if (V.PC.father === V.PC.mother) { + /* apparently we don't keep pronoun records in the missing parents table??? */ + const himself = jsDef(parents[0].pronoun) ? getPronouns(parents[0]).himself : "herself"; + r.push(`<br>Your parent is <span class="lightgreen">${knownSlave(parents[0].ID)},</span> who impregnated ${himself} with you.`); + } else { + r.push(`<br>You know one of your parents, <span class="lightgreen">${knownSlave(parents[0].ID)}.</span>`); + } + } + + /* Player aunts and uncles */ + if (V.showDistantRelatives) { + const {m: uncles, f: aunts} = splitBySex(V.slaves.filter((s) => isAunt(V.PC, s))); + + if (aunts.length > 0) { + r.push(`<br>You have`); + if (aunts.length > 2) { + r.push(`<span class="lightgreen">many aunts, ${slaveListToText(aunts)}.</span>`); + } else if (aunts.length > 1) { + r.push(`<span class="lightgreen">two aunts, ${slaveListToText(aunts)}.</span>`); + } else { + r.push(`<span class="lightgreen">an aunt, ${slaveListToText(aunts)}.</span>`); + } + } + if (uncles.length > 0) { + r.push(`<br>You have`); + if (uncles.length > 2) { + r.push(`<span class="lightgreen">many uncles, ${slaveListToText(uncles)}.</span>`); + } else if (uncles.length > 1) { + r.push(`<span class="lightgreen">two uncles, ${slaveListToText(uncles)}.</span>`); + } else { + r.push(`<span class="lightgreen">an uncle, ${slaveListToText(uncles)}.</span>`); + } + } + } + + let twins = []; + let sisters = []; + let brothers = []; + let halfSisters = []; + let halfBrothers = []; + let cousins = []; + + for (const s of V.slaves) { + let sisterCheck = areSisters(s, V.PC); + if (sisterCheck === 1) { + twins.push(s); + } + if (sisterCheck === 2) { + (s.genes === "XX" ? sisters : brothers).push(s); + } + if (sisterCheck === 3) { + (s.genes === "XX" ? halfSisters : halfBrothers).push(s); + } + if (V.showDistantRelatives) { + if (areCousins(s, V.PC)) { + cousins.push(s); + } + } + } + + if (twins.length > 1) { + r.push(`<br>You are <span class="lightgreen">twins with ${slaveListToText(twins)}.</span>`); + } else if (twins.length > 0) { + r.push(`<br>Your twin is <span class="lightgreen">${twins[0].slaveName}.</span>`); + } + + if (sisters.length > 1) { + r.push(`<br><span class="lightgreen">${slaveListToText(sisters)}</span> are your sisters.`); + } else if (sisters.length > 0) { + const {sister} = getPronouns(sisters[0]); + r.push(`<br>Your ${sister} is <span class="lightgreen">${sisters[0].slaveName}.</span>`); + } + + if (brothers.length > 1) { + r.push(`<br><span class="lightgreen">${slaveListToText(brothers)}</span> are your brothers.`); + } else if (brothers.length > 0) { + const {sister} = getPronouns(brothers[0]); + r.push(`<br>Your ${sister} is <span class="lightgreen">${brothers[0].slaveName}.</span>`); + } + + if (halfSisters.length > 1) { + r.push(`<br><span class="lightgreen">${slaveListToText(halfSisters)}</span> are your half-sisters.`); + } else if (halfSisters.length > 0) { + const {sister} = getPronouns(halfSisters[0]); + r.push(`<br>You have one half-${sister}, <span class="lightgreen">${halfSisters[0].slaveName}.</span>`); + } + + if (halfBrothers.length > 1) { + r.push(`<br><span class="lightgreen">${slaveListToText(sisters)}</span> are your half-brothers.`); + } else if (halfBrothers.length > 0) { + const {sister} = getPronouns(halfBrothers[0]); + r.push(`<br>You have one half-${sister}, <span class="lightgreen">${halfBrothers[0].slaveName}.</span>`); + } + + if (V.showDistantRelatives) { + if (cousins.length > 1) { + r.push(`<br><span class="lightgreen">${slaveListToText(cousins)}</span> are your cousins.`); + } else if (cousins.length > 0) { + r.push(`<br>You have one cousin, <span class="lightgreen">${cousins[0].slaveName}.</span>`); + } + } + + /* Player nieces and nephews */ + if (V.showDistantRelatives) { + const {m: nephews, f: nieces} = splitBySex(V.slaves.filter((s) => isAunt(s, V.PC))); + + if (nieces.length > 0) { + r.push(`<br>You have`); + if (nieces.length > 2) { + r.push(`<span class="lightgreen">many nieces, ${slaveListToText(nieces)}, who are your slaves.</span>`); + } else if (nieces.length > 1) { + r.push(`<span class="lightgreen">two nieces, ${slaveListToText(nieces)}, who are your slaves.</span>`); + } else { + r.push(`<span class="lightgreen">a niece, ${slaveListToText(nieces)}, who is your slave.</span>`); + } + } + if (nephews.length > 0) { + r.push(`<br>You have`); + if (nephews.length > 2) { + r.push(`<span class="lightgreen">many nephews, ${slaveListToText(nephews)}, who are your slaves.</span>`); + } else if (nephews.length > 1) { + r.push(`<span class="lightgreen">two nephews, ${slaveListToText(nephews)}, who are your slaves.</span>`); + } else { + r.push(`<span class="lightgreen">a nephew, ${slaveListToText(nephews)}, who is your slave.</span>`); + } + } + } + + /* Player is Father, lists children you fathered */ + let children = V.slaves.filter((s) => s.father === V.PC.ID); + if (children.length > 0) { + r.push(`<br>You fathered ${num(children.length)} of your slaves, <span class="lightgreen">${slaveListToText(children)}.</span>`); + } + + /* Player is Mother, lists birthed children */ + children = V.slaves.filter((s) => s.mother === V.PC.ID); + if (children.length > 0) { + r.push(`<br>You gave birth to ${num(children.length)} of your slaves, <span class="lightgreen">${slaveListToText(children)}.</span>`); + } + + /* Player is grandparent */ + if (V.showDistantRelatives) { + children = V.slaves.filter((s) => isGrandparentP(s, V.PC)); + if (children.length > 0) { + r.push(`<br>You have ${num(children.length)} grandchildren as your slaves, <span class="lightgreen">${slaveListToText(children)}.</span>`); + } + } + + if (V.cheatMode) { + r.push(`<br>You have ${numberWithPlural(V.PC.sisters, "sister")} and ${numberWithPlural(V.PC.daughters, "daughter")}.`); + } + return r.join(" "); } diff --git a/src/pregmod/managePersonalAffairs.tw b/src/pregmod/managePersonalAffairs.tw index 4163a2b32e1..eb1818ee712 100644 --- a/src/pregmod/managePersonalAffairs.tw +++ b/src/pregmod/managePersonalAffairs.tw @@ -508,7 +508,7 @@ </span> <<if totalPlayerRelatives($PC) > 0 || ($showMissingSlaves && ($PC.mother in $missingTable || $PC.father in $missingTable))>> <div> - <<PlayerFamily>> + <<= App.Desc.family($PC)>> </div> <</if>> </p> diff --git a/src/utility/extendedFamilyWidgets.tw b/src/utility/extendedFamilyWidgets.tw index 0aef0ec0819..38d3529ddaa 100644 --- a/src/utility/extendedFamilyWidgets.tw +++ b/src/utility/extendedFamilyWidgets.tw @@ -1,230 +1,5 @@ :: extended family widgets [nobr widget] -<<widget PlayerFamily>> - -<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;<<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;<<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;<<if $children[0].ID < 0>>your former slave<</if>> $children[0].slaveName.@@ - <</if>> -<</if>> -<<set $children = []>> - -/*Twins Test with aresisters*/ -<<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $PC.ID>> - <<if areSisters($slaves[$i], $PC) == 1 && areSisters($slaves[$i], $slaves[$i]) == 1>> - <<set $children.push($slaves[$i])>> - <</if>> - <</if>> -<</for>> -<<if $children.length > 2>> - <br>You are @@.lightgreen;twins 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>> - <br>You are twins with @@.lightgreen;$children[0].slaveName and $children[1].slaveName.@@ -<<elseif $children.length > 0>> - <br>Your twin is @@.lightgreen;$children[0].slaveName.@@ -<</if>> -<<set $children = []>> - -/*Sister Test with aresisters*/ -<<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $PC.ID>> - <<if areSisters($PC, $slaves[$i]) === 2 && areSisters($slaves[$i], $PC) === 2>> - <<if $slaves[$i].genes == "XX">> - <<set $children.push($slaves[$i])>> - <</if>> - <</if>> - <</if>> -<</for>> -<<if $children.length > 2>> - <br>@@.lightgreen; - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName - <</if>> - <</for>>@@ - are your sisters. -<<elseif $children.length > 1>> - <br>@@.lightgreen;$children[0].slaveName and $children[1].slaveName@@ are your sisters. -<<elseif $children.length > 0>> - <<setLocalPronouns $children[0]>> - <br>Your $sister is @@.lightgreen;$children[0].slaveName.@@ -<</if>> -<<set $children = []>> - -/*Brother Test with aresisters*/ -<<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $PC.ID>> - <<if areSisters($PC, $slaves[$i]) === 2 && areSisters($slaves[$i], $PC) === 2>> - <<if $slaves[$i].genes == "XY">> - <<set $children.push($slaves[$i])>> - <</if>> - <</if>> - <</if>> -<</for>> -<<if $children.length > 2>> - <br>@@.lightgreen; - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName - <</if>> - <</for>>@@ - are your brothers. -<<elseif $children.length > 1>> - <br>@@.lightgreen;$children[0].slaveName and $children[1].slaveName@@ are your brothers. -<<elseif $children.length > 0>> - <<setLocalPronouns $children[0]>> - <br>Your $sister is @@.lightgreen;$children[0].slaveName.@@ -<</if>> -<<set $children = []>> - -/*Half-Sister Test with aresisters */ -<<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $PC.ID>> - <<if areSisters($slaves[$i], $PC) == 3 && areSisters($PC, $slaves[$i]) == 3>> - <<if $slaves[$i].genes == "XX">> - <<set $children.push($slaves[$i])>> - <</if>> - <</if>> - <</if>> -<</for>> -<<if $children.length > 2>> - <br>@@.lightgreen; - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName. - <</if>> - <</for>>@@ - are your half-sisters. -<<elseif $children.length > 1>> - <br>@@.lightgreen;$children[0].slaveName and $children[1].slaveName@@ are your half-sisters. -<<elseif $children.length > 0>> - <<setLocalPronouns $children[0]>> - <br>You have one half-<<= $sister>>, @@.lightgreen;$children[0].slaveName.@@ -<</if>> -<<set $children = []>> - -/*Half-Brother Test with aresisters */ -<<for $i = 0; $i < $slaves.length; $i++>> - <<if $slaves[$i].ID != $PC.ID>> - <<if areSisters($slaves[$i], $PC) == 3 && areSisters($PC, $slaves[$i]) == 3>> - <<if $slaves[$i].genes == "XY">> - <<set $children.push($slaves[$i])>> - <</if>> - <</if>> - <</if>> -<</for>> -<<if $children.length > 2>> - <br>@@.lightgreen; - <<for $j = 0; $j < $children.length; $j++>> - <<if $j < $children.length-1>> - $children[$j].slaveName, - <<else>> - and $children[$j].slaveName. - <</if>> - <</for>>@@ - are your half-brothers. -<<elseif $children.length > 1>> - <br>@@.lightgreen;$children[0].slaveName and $children[1].slaveName@@ are your half-brothers. -<<elseif $children.length > 0>> - <br>You have one half-brother, @@.lightgreen;$children[0].slaveName.@@ -<</if>> -<<set $children = []>> - -/* -<<if $PC.clone != 0>> - <br>You are a clone of - <<if $activeSlave.cloneID == -1>> - yourself. - <<else>> - $PC.clone. - <</if>> -<</if>> -*/ - -/*Player is Father, lists children you fathered*/ -<<for $i = 0; $i < $slaves.length; $i++>> - <<if $PC.ID == $slaves[$i].father>> - <<set $children.push($slaves[$i])>> - <</if>> -<</for>> -<<if $children.length > 2>> - <br>You are the father of @@.lightgreen; - <<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>> - <br>You are the father of two of your slaves, @@.lightgreen;$children[0].slaveName, and $children[1].slaveName.@@ -<<elseif $children.length > 0>> - <br>You are the father of one of your slaves, @@.lightgreen;$children[0].slaveName.@@ -<</if>> -<<set $children = []>> - -/*Player is Mother, lists birthed children*/ -<<for $i = 0; $i < $slaves.length; $i++>> - <<if $PC.ID == $slaves[$i].mother>> - <<set $children.push($slaves[$i])>> - <</if>> -<</for>> -<<if $children.length > 2>> - <br>You are the mother of@@.lightgreen; - <<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>> - <br>You are the mother of two of your slaves, @@.lightgreen;$children[0].slaveName, and $children[1].slaveName.@@ -<<elseif $children.length > 0>> - <br>You are the mother of one of your slaves, @@.lightgreen;$children[0].slaveName.@@ -<</if>> -<<set $children = []>> - -<<if $cheatMode == 1>> - You have $PC.sisters sister<<if $PC.sisters > 1>>s<</if>>, and $PC.daughters daughter<<if $PC.daughters > 1>>s<</if>>. -<</if>> - -<</widget>> - <<widget "parentName">> <<if $activeSlave[$args[0]] == $PC.ID>> You -- GitLab