diff --git a/src/005-passages/interactPassages.js b/src/005-passages/interactPassages.js index e931955cf90f3b623f7c4e82f9b11313533789b7..77c353f76a08aed801cfc0af9037059aabd309cf 100644 --- a/src/005-passages/interactPassages.js +++ b/src/005-passages/interactPassages.js @@ -341,3 +341,17 @@ new App.DomPassage("Find Slave", return App.UI.findSlave(); }, ["jump-to-safe", "jump-from-safe"] ); + +new App.DomPassage("Analyze Pregnancy", + () => { + V.nextButton = "Continue"; + return App.UI.analyzePregnancy(); + }, ["jump-from-safe"] +); + +new App.DomPassage("Analyze PC Pregnancy", + () => { + V.nextButton = "Continue"; + return App.UI.analyzePCPregnancy(); + }, ["jump-from-safe"] +); diff --git a/src/facilities/surgery/analyzePlayerPregnancy.js b/src/facilities/surgery/analyzePlayerPregnancy.js new file mode 100644 index 0000000000000000000000000000000000000000..809cadc7cc45064e0c3eb4112683a06521d6b69b --- /dev/null +++ b/src/facilities/surgery/analyzePlayerPregnancy.js @@ -0,0 +1,95 @@ +App.UI.analyzePCPregnancy = function() { + //:: Analyze PC Pregnancy [nobr] + const node = new DocumentFragment(); + + if (lastVisited("Incubator") === 1) { + V.storedLink = "Incubator"; + } else if (lastVisited("Manage Personal Affairs") === 1) { + V.storedLink = "Manage Personal Affairs"; + } + V.nextButton = "Continue"; + V.nextLink = V.storedLink; + + const _WL = V.PC.womb.length; + const _incubatorReservations = WombReserveCount(V.PC, "incubator"); + const _nurseryReservations = WombReserveCount(V.PC, "nursery"); + const _freeTanks = V.incubator.capacity - V.incubator.tanks.length; + const _freeCribs = V.nursery - V.cribs.length; + const _reservedChildren = FetusGlobalReserveCount("incubator"); + const _reservedChildrenNursery = FetusGlobalReserveCount("nursery"); + let linkArray = []; + + if (_WL === 0) { + setTimeout(() => Engine.play("Manage Personal Affairs"), Engine.minDomActionDelay); + } else { + App.UI.DOM.appendNewElement("p", node, `You make yourself comfortable and prep your stomach for examination.`, "scene-intro"); + + App.Events.addParagraph(node, [App.Desc.Player.analyzePreg()]); + + App.UI.DOM.appendNewElement("h2", node, "Furthest developed pregnancy"); + App.UI.DOM.appendNewElement("p", node, `Fetal development week: ${V.PC.preg}`); + + let p = App.UI.DOM.appendNewElement("p", node); + if (V.incubator.capacity > 0 || V.nursery > 0) { + let div = App.UI.DOM.appendNewElement("div", p); + if (V.incubator.capacity > 0) { + if (_incubatorReservations > 0) { + linkArray.push(App.UI.DOM.link( + `Remove all of your children from ${V.incubator.name}`, + () => { + WombChangeReserveType(V.PC, "incubator", ""); + }, + [], + "Analyze PC Pregnancy" + )); + } + if (_incubatorReservations < _WL && (_reservedChildren + _WL - _incubatorReservations <= _freeTanks)) { + linkArray.push(App.UI.DOM.link( + `Keep all of your children in ${V.incubator.name}`, + () => { + WombChangeReserveType(V.PC, "nursery", "incubator"); + WombChangeReserveType(V.PC, "", "incubator"); + }, + [], + "Analyze PC Pregnancy" + )); + } else if (_incubatorReservations < _WL) { + App.UI.DOM.appendNewElement("span", div, `There is not enough free space in ${V.incubator.name} for the rest of your children.`); + } + div.append(App.UI.DOM.generateLinksStrip(linkArray)); + } + + linkArray = []; + div = App.UI.DOM.appendNewElement("div", p); + if (V.nursery > 0) { + if (_nurseryReservations > 0) { + linkArray.push(App.UI.DOM.link( + `Remove all of your children from ${V.nurseryName}`, + () => { + WombChangeReserveType(V.PC, "nursery", ""); + }, + [], + "Analyze Pregnancy" + )); + } + if (_nurseryReservations < _WL && (_reservedChildrenNursery + _WL - _nurseryReservations <= _freeCribs)) { + linkArray.push(App.UI.DOM.link( + `Keep all of your children in ${V.incubator.name}`, + () => { + WombChangeReserveType(V.PC, "incubator", "nursery"); + WombChangeReserveType(V.PC, "", "nursery"); + }, + [], + "Analyze Pregnancy" + )); + } else if (_nurseryReservations < _WL) { + App.UI.DOM.appendNewElement("span", div, `There is not enough free space in ${V.nurseryName} for the rest of your children.`); + } + div.append(App.UI.DOM.generateLinksStrip(linkArray)); + } + } + App.UI.DOM.appendNewElement("h2", node, "Deep scan"); + App.UI.DOM.appendNewElement("p", node, analyzePregnancies(V.PC, false)); + } + return node; +}; diff --git a/src/facilities/surgery/analyzePregnancy.js b/src/facilities/surgery/analyzePregnancy.js index 2a17314c88e6b09fd8939013a6b3b508bc97a0d0..08229f5d8584fef10c42032c9864866e27bf6778 100644 --- a/src/facilities/surgery/analyzePregnancy.js +++ b/src/facilities/surgery/analyzePregnancy.js @@ -240,3 +240,122 @@ globalThis.analyzePregnancies = function(mother, cheat) { } }; +App.UI.analyzePregnancy = function() { + const node = new DocumentFragment(); + if (lastVisited("Incubator") === 1) { + V.storedLink = "Incubator"; + } else if (lastVisited("Slave Interact") === 1) { + V.storedLink = "Slave Interact"; + } + V.nextLink = V.storedLink; + const slave = getSlave(V.AS); + + const _WL = slave.womb.length; + const _incubatorReservations = WombReserveCount(slave, "incubator"); + const _nurseryReservations = WombReserveCount(slave, "nursery"); + const _freeTanks = V.incubator.capacity - V.incubator.tanks.length; + const _freeCribs = V.nursery - V.cribs.length; + const _reservedChildren = FetusGlobalReserveCount("incubator"); + const _reservedChildrenNursery = FetusGlobalReserveCount("nursery"); + let linkArray = []; + + const { + His, He, + his + } = getPronouns(slave); + + App.UI.DOM.appendNewElement("p", node, `${slave.slaveName} is ${(slave.devotion < 20) ? `restrained` : `comfortably reclined`} with ${his} stomach prepped for examination. ${He} shudders slightly at the cold touch of the sensor against ${his} skin.`, "scene-intro"); + + App.Events.addParagraph(node, [App.Desc.pregnancy(slave)]); + + App.UI.DOM.appendNewElement("h2", node, "Overall statistics"); + let p = App.UI.DOM.appendNewElement("p", node); + const _cc = Math.round(slave.bellyPreg); + const _safeCC = Math.round(slave.pregAdaptation * 2000); + if (V.geneticMappingUpgrade > 0) { + App.UI.DOM.appendNewElement("div", p, `Estimated physical degree of pregnancy adaptation: ${num(Math.round(slave.pregAdaptation))}`); + App.UI.DOM.appendNewElement("div", p, `Estimated safe ${(slave.ovaries === 1 || slave.mpreg === 1) ? `womb` : `abdominal`} volume: ${num(_safeCC)}cc`); + } + App.UI.DOM.appendNewElement("div", p, `Current fetal count: ${slave.womb.length}`); + App.Events.addNode(p, [ + `Estimated ${(slave.ovaries === 1 || slave.mpreg === 1) ? `womb` : `abdominal`} volume: ${(_safeCC < _cc && V.geneticMappingUpgrade > 0) ? `<span class="red">${num(_cc)}</span>` : num(_cc)}cc` + ], "div"); + + + if (slave.womb.length > 0) { + App.UI.DOM.appendNewElement("h2", node, "Furthest developed pregnancy"); + App.UI.DOM.appendNewElement("p", node, `Fetal development week: ${Math.trunc(slave.preg * 1000) / 1000}`); + + p = App.UI.DOM.appendNewElement("p", node); + if (V.incubator.capacity > 0 || V.nursery > 0) { + let div = App.UI.DOM.appendNewElement("div", p); + if (V.incubator.capacity > 0) { + if (_incubatorReservations > 0) { + linkArray.push(App.UI.DOM.link( + `Remove all of ${his} children from ${V.incubator.name}`, + () => WombChangeReserveType(slave, "incubator", ""), + [], + "Analyze Pregnancy" + )); + } + if (_incubatorReservations < _WL && (_reservedChildren + _WL - _incubatorReservations <= _freeTanks)) { + linkArray.push(App.UI.DOM.link( + `Keep all of ${his} children in ${V.incubator.name}`, + () => { + WombChangeReserveType(slave, "nursery", "incubator"); + WombChangeReserveType(slave, "", "incubator"); + }, + [], + "Analyze Pregnancy" + )); + } else if (_incubatorReservations < _WL) { + App.UI.DOM.appendNewElement("span", div, `There is not enough free space in ${V.incubator.name} for the rest of ${his} children.`); + } + div.append(App.UI.DOM.generateLinksStrip(linkArray)); + } + + linkArray = []; + div = App.UI.DOM.appendNewElement("div", p); + if (V.nursery > 0) { + if (_nurseryReservations > 0) { + linkArray.push(App.UI.DOM.link( + `Remove all of ${his} children from ${V.nurseryName}`, + () => WombChangeReserveType(slave, "nursery", ""), + [], + "Analyze Pregnancy" + )); + } + if (_nurseryReservations < _WL && (FetusGlobalReserveCount("nursery") + _WL - _nurseryReservations <= _freeCribs)) { + linkArray.push(App.UI.DOM.link( + `Keep all of ${his} children in ${V.incubator.name}`, + () => { + WombChangeReserveType(slave, "incubator", "nursery"); + WombChangeReserveType(slave, "", "nursery"); + }, + [], + "Analyze Pregnancy" + )); + } else if (_nurseryReservations < _WL) { + App.UI.DOM.appendNewElement("span", div, `There is not enough free space in ${V.nurseryName} for the rest of ${his} children.`); + } + div.append(App.UI.DOM.generateLinksStrip(linkArray)); + } + } + App.UI.DOM.appendNewElement("h2", node, "Deep scan"); + App.UI.DOM.appendNewElement("p", node, analyzePregnancies(slave, false)); + } else if (slave.preg === -3) { // special states + App.UI.DOM.appendNewElement("div", node, `Failure to locate any ova. Subject is infertile.`); + } else if (slave.pregWeek < 0) { // special states + App.UI.DOM.appendNewElement("div", node, `Subject is in the postpartum period.`); + } else if (slave.ovaryAge >= 47) { + App.UI.DOM.appendNewElement("div", node, `${His} infertility is due to menopausal ovaries.`); + } else if (slave.ovaries === 0 && slave.mpreg === 0) { + App.UI.DOM.appendNewElement("div", node, `${His} infertility is due to missing ovaries.`); + } else if (slave.preg === -2) { // special states + App.UI.DOM.appendNewElement("div", node, `${His} infertility is due to sterilization; ${his} ovaries could still work.`); + } else if (slave.preg === -1) { // special states + App.UI.DOM.appendNewElement("div", node, `Contraceptive agents detected in subject.`); + } + + return node; +}; diff --git a/src/pregmod/analyzePlayerPregnancy.tw b/src/pregmod/analyzePlayerPregnancy.tw deleted file mode 100644 index 61da9630dbffd60b6f604499b4e9142b1852e403..0000000000000000000000000000000000000000 --- a/src/pregmod/analyzePlayerPregnancy.tw +++ /dev/null @@ -1,76 +0,0 @@ -:: Analyze PC Pregnancy [nobr] - -<<if lastVisited("Incubator") === 1>> - <<set $storedLink = "Incubator">> -<<elseif lastVisited("Manage Personal Affairs") === 1>> - <<set $storedLink = "Manage Personal Affairs">> -<</if>> -<<set $nextButton = "Continue", $nextLink = $storedLink>> - -<<set _WL = $PC.womb.length, _incubatorReservations = WombReserveCount($PC, "incubator"), _nurseryReservations = WombReserveCount($PC, "nursery"), _freeTanks = $incubator.capacity - $incubator.tanks.length, _freeCribs = $nursery - $cribs.length>> -<<set _reservedChildren = FetusGlobalReserveCount("incubator")>> -<<set _reservedChildrenNursery = FetusGlobalReserveCount("nursery")>> - -<<if _WL == 0>> - <<goto "Manage Personal Affairs">> -<<else>> - <p class="scene-intro"> - You make yourself comfortable and prep your stomach for examination. <<= App.Desc.Player.analyzePreg()>> - </p> - - <p> - <h2>Furthest developed pregnancy</h2> - <div class="indent"> - Fetal development week: $PC.preg - </div> - </p> - - <<if $incubator.capacity > 0 || $nursery > 0>> - <p> - <<if $incubator.capacity > 0>> - <<if _incubatorReservations > 0>> - <<link "Remove all of your children from $incubator.name" "Analyze PC Pregnancy">> - <<run WombChangeReserveType($PC, "incubator", "")>> - <<set _reservedChildren -= _incubatorReservations>> - <</link>> | - <</if>> - <<if _incubatorReservations < _WL && (_reservedChildren + _WL - _incubatorReservations <= _freeTanks)>> - <<link "Keep all of your children in $incubator.name" "Analyze PC Pregnancy">> - <<run WombChangeReserveType($PC, "nursery", "incubator")>> - <<run WombChangeReserveType($PC, "", "incubator")>> - <<set _reservedChildrenNursery -= _nurseryReservations>> - <<set _reservedChildren += _WL - _incubatorReservations>> - <</link>> - <<elseif _incubatorReservations < _WL>> - There is not enough free space in <<= $incubator.name>> for the rest of your children. - <</if>> - <</if>> - </p> - - <p> - <<if $nursery > 0>> - <<if _nurseryReservations > 0>> - <<link "Remove all of your children from $nurseryName" "Analyze PC Pregnancy">> - <<run WombChangeReserveType($PC, "nursery", "")>> - <<set _reservedChildrenNursery -= _nurseryReservations>> - <</link>> | - <</if>> - <<if _nurseryReservations < _WL && (_reservedChildrenNursery + _WL - _nurseryReservations <= _freeCribs)>> - <<link "Keep all of your children in $nurseryName" "Analyze PC Pregnancy">> - <<run WombChangeReserveType($PC, "incubator", "nursery")>> - <<run WombChangeReserveType($PC, "", "nursery")>> - <<set _reservedChildren -= _incubatorReservations>> - <<set _reservedChildrenNursery += _WL - _nurseryReservations>> - <</link>> - <<elseif _nurseryReservations < _WL>> - There is not enough free space in $nurseryName for the rest of your children. - <</if>> - <</if>> - </p> - <</if>> - - <p> - <h2>Deep scan</h2> - <<includeDOM analyzePregnancies($PC)>> - </p> -<</if>> diff --git a/src/pregmod/analyzePregnancy.tw b/src/pregmod/analyzePregnancy.tw deleted file mode 100644 index 79f3582c7d326a1097ae698cfb873a72d2684de1..0000000000000000000000000000000000000000 --- a/src/pregmod/analyzePregnancy.tw +++ /dev/null @@ -1,117 +0,0 @@ -:: Analyze Pregnancy [nobr] - -<<if lastVisited("Incubator") === 1>> - <<set $storedLink = "Incubator">> -<<elseif lastVisited("Slave Interact") === 1>> - <<set $storedLink = "Slave Interact">> -<</if>> -<<set $nextButton = "Continue", $nextLink = $storedLink>> -<<run App.Utils.setLocalPronouns(getSlave($AS))>> - -<<set _WL = getSlave($AS).womb.length, _incubatorReservations = WombReserveCount(getSlave($AS), "incubator"), _nurseryReservations = WombReserveCount(getSlave($AS), "nursery"), _freeTanks = $incubator.capacity - $incubator.tanks.length, _freeCribs = $nursery - $cribs.length>> - -<p class="scene-intro"> - <<= getSlave($AS).slaveName>> is <<if getSlave($AS).devotion < 20>>restrained<<else>>comfortably reclined<</if>> with $his stomach prepped for examination. $He shudders slightly at the cold touch of the sensor against $his skin. -</p> - -<<= App.Desc.pregnancy(getSlave($AS))>> - -<p> - <h2>Overall statistics</h2> - <div class="indent"> - <<set _cc = Math.round(getSlave($AS).bellyPreg)>> - <<set _safeCC = Math.round(getSlave($AS).pregAdaptation*2000)>> - <<if $geneticMappingUpgrade > 0>> - <div> - Estimated physical degree of pregnancy adaptation: <<print num(Math.round(getSlave($AS).pregAdaptation))>> - </div> - <div> - Estimated safe - <<if getSlave($AS).ovaries == 1 || getSlave($AS).mpreg == 1>> - womb - <<else>> - abdominal - <</if>> - volume: <<= num(_safeCC)>> cc - </div> - <</if>> - <div> - Current fetal count: <<= getSlave($AS).womb.length>> - </div> - <div> - Estimated - <<if getSlave($AS).ovaries == 1 || getSlave($AS).mpreg == 1>> - womb - <<else>> - abdominal - <</if>> - volume: <<if _safeCC < _cc && $geneticMappingUpgrade > 0>>@@.red;<<= num(_cc)>>@@<<else>><<= num(_cc)>><</if>> cc - </div> - </div> -</p> - -<<if getSlave($AS).womb.length > 0>> - <p> - <h2>Furthest developed pregnancy</h2> - <div class="indent"> - Fetal development week: <<= Math.trunc(getSlave($AS).preg * 1000) / 1000>> - </div> - </p> - - <p> - <<if $incubator.capacity > 0 || $nursery > 0>> - <div> - <<if $incubator.capacity > 0>> - <<if _incubatorReservations > 0>> - <<link "Remove all of $his children from $incubator.name" "Analyze Pregnancy">> - <<run WombChangeReserveType(getSlave($AS), "incubator", "")>> - <</link>> | - <</if>> - <<if _incubatorReservations < _WL && (_reservedChildren + _WL - _incubatorReservations <= _freeTanks)>> - <<link "Keep all of $his children in $incubator.name" "Analyze Pregnancy">> - <<run WombChangeReserveType(getSlave($AS), "nursery", "incubator")>> - <<run WombChangeReserveType(getSlave($AS), "", "incubator")>> - <</link>> - <<elseif _incubatorReservations < _WL>> - There is not enough free space in <<= $incubator.name>> for the rest of $his children. - <</if>> - <</if>> - </div> - - <div> - <<if $nursery > 0>> - <<if _nurseryReservations > 0>> - <<link "Remove all of $his children from $nurseryName" "Analyze Pregnancy">> - <<run WombChangeReserveType(getSlave($AS), "nursery", "")>> - <</link>> | - <</if>> - <<if _nurseryReservations < _WL && (FetusGlobalReserveCount("nursery") + _WL - _nurseryReservations <= _freeCribs)>> - <<link "Keep all of $his children in $nurseryName" "Analyze Pregnancy">> - <<run WombChangeReserveType(getSlave($AS), "incubator", "nursery")>> - <<run WombChangeReserveType(getSlave($AS), "", "nursery")>> - <</link>> - <<elseif _nurseryReservations < _WL>> - There is not enough free space in $nurseryName for the rest of $his children. - <</if>> - <</if>> - </div> - <</if>> - </p> - - <p> - <h2>Deep scan</h2> - <<includeDOM analyzePregnancies(getSlave($AS))>> - </p> -<<elseif getSlave($AS).preg == -3>> /*special states*/ - Failure to locate any ova. Subject is infertile. -<<elseif getSlave($AS).pregWeek < 0>> /*special states*/ - Subject is in the postpartum period. -<<elseif getSlave($AS).ovaryAge >= 47 >> - $His infertility is due to menopausal ovaries. -<<elseif getSlave($AS).ovaries === 0 && getSlave($AS).mpreg === 0>> - $His infertility is due to missing ovaries. -<<elseif getSlave($AS).preg == -2>> /*special states*/ - $His infertility is due to sterilization; $his ovaries could still work. -<<elseif getSlave($AS).preg == -1>> /*special states*/ - Contraceptive agents detected in subject. -<</if>>