diff --git a/js/002-config/fc-js-init.js b/js/002-config/fc-js-init.js index 6141ced53d9bf02b955a9cb84d686eb01cbfaffc..e26f28d0aaddc8eeb43c1ce630275db8d1ca1c3c 100644 --- a/js/002-config/fc-js-init.js +++ b/js/002-config/fc-js-init.js @@ -40,6 +40,7 @@ App.Facilities.Club = {}; App.Facilities.Dairy = {}; App.Facilities.Farmyard = {}; App.Facilities.HGSuite = {}; +App.Facilities.Incubator = {}; App.Facilities.MasterSuite = {}; App.Facilities.Nursery = {}; App.Facilities.Schoolroom = {}; diff --git a/src/facilities/incubator/incubatorUtils.js b/src/facilities/incubator/incubatorUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..2765e9e43e2f09f77072fb68dd89c0ed88ff8c82 --- /dev/null +++ b/src/facilities/incubator/incubatorUtils.js @@ -0,0 +1,21 @@ +/** + * Sends a child to the Incubator if it has room + * @param {App.Entity.SlaveState|App.Entity.InfantState} child + */ +App.Facilities.Incubator.newChild = function(child) { + let fullAdapt; + child.growTime = Math.trunc(V.targetAge * 52); + child.incubatorPregAdaptationPower = V.incubatorPregAdaptationPower; + if (V.incubatorPregAdaptationPower === 1) { + fullAdapt = 45000 / 2000; + } else if (V.incubatorPregAdaptationPower === 2) { + fullAdapt = 100000 / 2000; + } else if (V.incubatorPregAdaptationPower === 3) { + fullAdapt = 150000 / 2000; + } else { + fullAdapt = 15000 / 2000; + } + child.incubatorPregAdaptationInWeek = (fullAdapt - child.pregAdaptation) / child.growTime; + V.tanks.push(child); + V.incubatorSlaves++; +}; diff --git a/src/facilities/nursery/nurseryWorkaround.tw b/src/facilities/nursery/nurseryWorkaround.tw deleted file mode 100644 index 1dc4c83a65df47a0bb389fadfeed62485d4973a4..0000000000000000000000000000000000000000 --- a/src/facilities/nursery/nurseryWorkaround.tw +++ /dev/null @@ -1,6 +0,0 @@ -:: Nursery Workaround [nobr] - -<<if $cribs.length < $nursery>> - <<run App.Facilities.Nursery.newChild($activeChild)>> - /*<<= App.Facilities.Nursery.nameChild($activeChild)>>*/ -<</if>> \ No newline at end of file diff --git a/src/js/birth.js b/src/js/birth.js new file mode 100644 index 0000000000000000000000000000000000000000..2d7666b525bf062b92606397e95476b465866a8c --- /dev/null +++ b/src/js/birth.js @@ -0,0 +1,25 @@ +/** + * Sends newborns to incubator or nursery + * @param {App.Entity.SlaveState} mom + */ +globalThis.sendNewbornsToFacility = function(mom) { + let curBabies = mom.curBabies.length; + for (let cb = 0; cb < curBabies; cb++) { + // if there is no reserved children, code in loop will not trigger + if (mom.curBabies[cb].reserve === "incubator") { + if (V.tanks.length < V.incubator) { + App.Facilities.Incubator.newChild(generateChild(mom, mom.curBabies[cb], true)); + } + mom.curBabies.splice(mom.curBabies[cb], 1); + cb--; + curBabies--; + } else if (mom.curBabies[cb].reserve === "nursery") { + if (V.cribs.length < V.nursery) { + App.Facilities.Nursery.newChild(generateChild(mom, mom.curBabies[cb])); + } + mom.curBabies.splice(mom.curBabies[cb], 1); + cb--; + curBabies--; + } + } +}; diff --git a/src/npc/generate/generateGenetics.js b/src/npc/generate/generateGenetics.js index 926149aeee78590f5a7c01759f9cae315f5e884b..87b1229a1a91f5f60249273a5f55b1a5237b11df 100644 --- a/src/npc/generate/generateGenetics.js +++ b/src/npc/generate/generateGenetics.js @@ -1143,9 +1143,10 @@ globalThis.generateGenetics = (function() { */ globalThis.generateChild = function(mother, ovum, incubator=false) { let genes = ovum.genetics; // TODO: maybe just argument this? We'll see. - let child = {}; + let child; if (!incubator) { // does extra work for the incubator if defined, otherwise builds a simple object + child = {}; child.genes = genes.gender; setSlaveName(child, genes); setSurname(child, genes); diff --git a/src/npc/interaction/passage/birthStorm.tw b/src/npc/interaction/passage/birthStorm.tw index e498ac768869c65fca14594d1541a38e46d912f2..8b796a8500b7a9387793ae1010615df8681095ee 100644 --- a/src/npc/interaction/passage/birthStorm.tw +++ b/src/npc/interaction/passage/birthStorm.tw @@ -208,21 +208,8 @@ The remote surgery allows the removal of the pregnancy generator through convent <<set _nursed = 1>> <</if>> - <<set $mom = getSlave($AS)>> <<if _cToIncub > 0 || _cToNursery > 0>> - <<for _cb = 0; _cb < _curBabies; _cb++>> /* if there is no reserved children, code in loop will not trigger */ - <<if $mom.curBabies[_cb].reserve == "incubator">> - <<set $activeChild = generateChild($mom, $mom.curBabies[_cb], 1)>> - <<include "Incubator Workaround">> - <<run $mom.curBabies.splice($mom.curBabies[_cb], 1)>> - <<set _cb--, _curBabies-->> - <<elseif $mom.curBabies[_cb].reserve == "nursery">> - <<set $activeChild = generateChild($mom, $mom.curBabies[_cb])>> - <<include "Nursery Workaround">> - <<run $mom.curBabies.splice($mom.curBabies[_cb], 1)>> - <<set _cb--, _curBabies-->> - <</if>> - <</for>> + <<run sendNewbornsToFacility(getSlave($AS))>> <</if>> <<else>> diff --git a/src/npc/interaction/passage/csec.tw b/src/npc/interaction/passage/csec.tw index e801074869aeb3ee2e5f6364ed814a9f1bbfae78..eda9862a2c6c6df361d894ecded20afba99495a4 100644 --- a/src/npc/interaction/passage/csec.tw +++ b/src/npc/interaction/passage/csec.tw @@ -179,23 +179,9 @@ Performing a cesarean section is trivial for the remote surgery to carry out. << <<set _nursed = 1>> <</if>> - <<set $mom = getSlave($AS)>> <<if _cToIncub > 0 || _cToNursery > 0>> - <<for _cb = 0; _cb < _curBabies; _cb++>> /* if there is no reserved children, code in loop will not trigger */ - <<if $mom.curBabies[_cb].reserve == "incubator">> - <<set $activeChild = generateChild($mom, $mom.curBabies[_cb], 1)>> - <<include "Incubator Workaround">> - <<run $mom.curBabies.splice($mom.curBabies[_cb], 1)>> - <<set _cb--, _curBabies-->> - <<elseif $mom.curBabies[_cb].reserve == "nursery">> - <<set $activeChild = generateChild($mom, $mom.curBabies[_cb])>> - <<include "Nursery Workaround">> - <<run $mom.curBabies.splice($mom.curBabies[_cb], 1)>> - <<set _cb--, _curBabies-->> - <</if>> - <</for>> + <<run sendNewbornsToFacility(getSlave($AS))>> <</if>> - <<set $AS = $mom.ID>> <<else>> /*No live babies. Placeholder */ diff --git a/src/pregmod/incubatorWorkaround.tw b/src/pregmod/incubatorWorkaround.tw deleted file mode 100644 index ec8ade7be3a57b3e0022a2ce59f07167307d2ee7..0000000000000000000000000000000000000000 --- a/src/pregmod/incubatorWorkaround.tw +++ /dev/null @@ -1,18 +0,0 @@ -:: Incubator Workaround [nobr] - -<<if $tanks.length < $incubator>> - <<set $activeChild.growTime = Math.trunc($targetAge*52)>> - <<set $activeChild.incubatorPregAdaptationPower = $incubatorPregAdaptationPower>> - <<if $incubatorPregAdaptationPower == 1>> - <<set _fullAdapt = 45000 / 2000>> - <<elseif $incubatorPregAdaptationPower == 2>> - <<set _fullAdapt = 100000 / 2000>> - <<elseif $incubatorPregAdaptationPower == 3>> - <<set _fullAdapt = 150000 / 2000>> - <<else>> - <<set _fullAdapt = 15000 / 2000>> - <</if>> - <<set $activeChild.incubatorPregAdaptationInWeek = (_fullAdapt - $activeChild.pregAdaptation) / $activeChild.growTime>> - <<set $tanks.push($activeChild)>> - <<set $incubatorSlaves++>> -<</if>> \ No newline at end of file diff --git a/src/pregmod/seBurst.tw b/src/pregmod/seBurst.tw index ba406970fc8b9919fe2ece54d5995edaec480d54..801b01f28780caf78c05223e519a077213de3a28 100644 --- a/src/pregmod/seBurst.tw +++ b/src/pregmod/seBurst.tw @@ -173,19 +173,7 @@ <</if>> <<if _cToIncub > 0 || _cToNursery > 0>> - <<for _cb = 0; _cb < _curBabies; _cb++>> /* if there is no reserved children, code in loop will not trigger */ - <<if $slaves[_b].curBabies[_cb].reserve == "incubator">> - <<set $activeChild = generateChild($slaves[_b], $slaves[_b].curBabies[_cb], 1)>> - <<include "Incubator Workaround">> - <<run $slaves[_b].curBabies.splice($slaves[_b].curBabies[_cb], 1)>> - <<set _cb--, _curBabies-->> - <<elseif $slaves[_b].curBabies[_cb].reserve == "nursery">> - <<set $activeChild = generateChild($slaves[_b], $slaves[_b].curBabies[_cb])>> - <<include "Nursery Workaround">> - <<run $slaves[_b].curBabies.splice($slaves[_b].curBabies[_cb], 1)>> - <<set _cb--, _curBabies-->> - <</if>> - <</for>> + <<run sendNewbornsToFacility($slaves[_b])>> <</if>> <<else>> life and <<if _curBabies <= 1>>that of $his child<<else>>those of $his children<</if>>. diff --git a/src/pregmod/sePlayerBirth.tw b/src/pregmod/sePlayerBirth.tw index 59f461ca1492d0e339e30ff0a6537cf0ea62af26..c9a587cbbe9219a7505e7dce49ff6bc22109a4f0 100644 --- a/src/pregmod/sePlayerBirth.tw +++ b/src/pregmod/sePlayerBirth.tw @@ -378,12 +378,14 @@ You arrange yourself to give birth, relaxing until your body urges you to begin <<if $PC.curBabies[0].reserve === "incubator">> @@.pink;You set <<if _gender == "XX">>her<<else>>him<</if>> aside for incubation.@@ - <<set $activeChild = generateChild($PC, $PC.curBabies[0], 1)>> - <<include "Incubator Workaround">> + <<if $tanks.length < $incubator>> + <<run App.Facilities.Incubator.newChild(generateChild($PC, $PC.curBabies[0], true))>> + <</if>> <<elseif $PC.curBabies[0].reserve === "nursery">> @@.pink;You set <<if _gender == "XX">>her<<else>>him<</if>> aside for incubation.@@ - <<set $activeChild = generateChild($PC, $PC.curBabies[0])>> - <<include "Nursery Workaround">> + <<if $cribs.length < $nursery>> + <<run App.Facilities.Nursery.newChild(generateChild($PC, $PC.curBabies[0]))>> + <</if>> <</if>> <<set $PC.curBabies.shift()>> @@ -428,14 +430,16 @@ You arrange yourself to give birth, relaxing until your body urges you to begin <</if>> <<if $PC.curBabies[_p].reserve == "incubator">> @@.pink;You set <<if $PC.curBabies[_p].genetics.gender == "XX">>her<<else>>him<</if>> aside for incubation.@@ - <<set $activeChild = generateChild($PC, $PC.curBabies[_p], 1)>> - <<include "Incubator Workaround">> + <<if $tanks.length < $incubator>> + <<run App.Facilities.Incubator.newChild(generateChild($PC, $PC.curBabies[_p], true))>> + <</if>> <<run $PC.curBabies.splice($PC.curBabies[_p], 1)>> <<set _p--, _curBabies-->> <<elseif $PC.curBabies[_p].reserve == "nursery">> @@.pink;You set <<if $PC.curBabies[_p].genetics.gender == "XX">>her<<else>>him<</if>> aside to be raised in the penthouse.@@ - <<set $activeChild = generateChild($PC, $PC.curBabies[_p])>> - <<include "Nursery Workaround">> + <<if $cribs.length < $nursery>> + <<run App.Facilities.Nursery.newChild(generateChild($PC, $PC.curBabies[_p]))>> + <</if>> <<run $PC.curBabies.splice($PC.curBabies[_p], 1)>> <<set _p--, _curBabies-->> <</if>> diff --git a/src/pregmod/widgets/seBirthWidgets.tw b/src/pregmod/widgets/seBirthWidgets.tw index 2da2dbffe97fef29e9db8190885aa5642f34dd40..1fd091c6899123a7e12bae52342f49276df7393d 100644 --- a/src/pregmod/widgets/seBirthWidgets.tw +++ b/src/pregmod/widgets/seBirthWidgets.tw @@ -894,19 +894,7 @@ All in all, <br><br> <<if _curBabies > 1>>Of $his _curBabies child<<if _curBabies > 1>>ren<</if>>,<<else>>$His child<</if>> <<if _cToIncub > 0>><<if _curBabies > 1>>_cToIncub <</if>><<if _cToIncub === 1>>was<<else>>were<</if>> taken to $incubatorName<<if _cToNursery > 0>> and <</if>><</if>><<if _cToNursery > 0>><<if _curBabies > 1>>_cToNursery <</if>><<if _cToNursery === 1>>was<<else>>were<</if>> taken to $nurseryName<</if>>. <<if _cToIncub + _cToNursery > 0>> - <<for _cb = 0; _cb < _curBabies; _cb++>> /* if there are no reserved children, code in loop will not trigger */ - <<if $slaves[$i].curBabies[_cb].reserve == "incubator">> - <<set $activeChild = generateChild($slaves[$i], $slaves[$i].curBabies[_cb], 1)>> - <<include "Incubator Workaround">> - <<run $slaves[$i].curBabies.splice($slaves[$i].curBabies[_cb], 1)>> - <<set _cb--, _curBabies-->> - <<elseif $slaves[$i].curBabies[_cb].reserve == "nursery">> - <<set $activeChild = generateChild($slaves[$i], $slaves[$i].curBabies[_cb])>> - <<include "Nursery Workaround">> - <<run $slaves[$i].curBabies.splice($slaves[$i].curBabies[_cb], 1)>> - <<set _cb--, _curBabies-->> - <</if>> - <</for>> + <<run sendNewbornsToFacility($slaves[$i])>> <</if>> <<set _curBabies = $slaves[$i].curBabies.length>>