From f2e1a4449c51fbaa53d3f8b7b38f415423f4e3fc Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Sun, 16 Aug 2020 14:29:26 -0400 Subject: [PATCH] incubator workaround to JS --- js/002-config/fc-js-init.js | 1 + src/facilities/incubator/incubatorUtils.js | 23 ++++++++++++++++++++++ src/npc/interaction/passage/birthStorm.tw | 3 +-- src/npc/interaction/passage/csec.tw | 3 +-- src/pregmod/incubatorWorkaround.tw | 18 ----------------- src/pregmod/seBurst.tw | 3 +-- src/pregmod/sePlayerBirth.tw | 6 ++---- src/pregmod/widgets/seBirthWidgets.tw | 3 +-- 8 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 src/facilities/incubator/incubatorUtils.js delete mode 100644 src/pregmod/incubatorWorkaround.tw diff --git a/js/002-config/fc-js-init.js b/js/002-config/fc-js-init.js index 6141ced53d9..e26f28d0aad 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 00000000000..9c04341f013 --- /dev/null +++ b/src/facilities/incubator/incubatorUtils.js @@ -0,0 +1,23 @@ +/** + * Sends a child to the Incubator if it has room + * @param {App.Entity.SlaveState|App.Entity.InfantState} child + */ +App.Facilities.Incubator.newChild = function(child) { + if (V.tanks.length < V.incubator) { + 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/npc/interaction/passage/birthStorm.tw b/src/npc/interaction/passage/birthStorm.tw index e498ac76886..57dc1237641 100644 --- a/src/npc/interaction/passage/birthStorm.tw +++ b/src/npc/interaction/passage/birthStorm.tw @@ -212,8 +212,7 @@ The remote surgery allows the removal of the pregnancy generator through convent <<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 App.Facilities.Incubator.newChild(generateChild($mom, $mom.curBabies[_cb], 1))>> <<run $mom.curBabies.splice($mom.curBabies[_cb], 1)>> <<set _cb--, _curBabies-->> <<elseif $mom.curBabies[_cb].reserve == "nursery">> diff --git a/src/npc/interaction/passage/csec.tw b/src/npc/interaction/passage/csec.tw index e801074869a..bd222891501 100644 --- a/src/npc/interaction/passage/csec.tw +++ b/src/npc/interaction/passage/csec.tw @@ -183,8 +183,7 @@ Performing a cesarean section is trivial for the remote surgery to carry out. << <<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 App.Facilities.Incubator.newChild(generateChild($mom, $mom.curBabies[_cb], 1))>> <<run $mom.curBabies.splice($mom.curBabies[_cb], 1)>> <<set _cb--, _curBabies-->> <<elseif $mom.curBabies[_cb].reserve == "nursery">> diff --git a/src/pregmod/incubatorWorkaround.tw b/src/pregmod/incubatorWorkaround.tw deleted file mode 100644 index ec8ade7be3a..00000000000 --- 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 ba406970fc8..f127e69fe63 100644 --- a/src/pregmod/seBurst.tw +++ b/src/pregmod/seBurst.tw @@ -175,8 +175,7 @@ <<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 App.Facilities.Incubator.newChild(generateChild($slaves[_b], $slaves[_b].curBabies[_cb], 1))>> <<run $slaves[_b].curBabies.splice($slaves[_b].curBabies[_cb], 1)>> <<set _cb--, _curBabies-->> <<elseif $slaves[_b].curBabies[_cb].reserve == "nursery">> diff --git a/src/pregmod/sePlayerBirth.tw b/src/pregmod/sePlayerBirth.tw index 59f461ca149..24c421de65e 100644 --- a/src/pregmod/sePlayerBirth.tw +++ b/src/pregmod/sePlayerBirth.tw @@ -378,8 +378,7 @@ 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">> + <<run App.Facilities.Incubator.newChild(generateChild($PC, $PC.curBabies[0], 1))>> <<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])>> @@ -428,8 +427,7 @@ 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">> + <<run App.Facilities.Incubator.newChild(generateChild($PC, $PC.curBabies[_p], 1))>> <<run $PC.curBabies.splice($PC.curBabies[_p], 1)>> <<set _p--, _curBabies-->> <<elseif $PC.curBabies[_p].reserve == "nursery">> diff --git a/src/pregmod/widgets/seBirthWidgets.tw b/src/pregmod/widgets/seBirthWidgets.tw index 2da2dbffe97..224a0cacd07 100644 --- a/src/pregmod/widgets/seBirthWidgets.tw +++ b/src/pregmod/widgets/seBirthWidgets.tw @@ -896,8 +896,7 @@ All in all, <<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 App.Facilities.Incubator.newChild(generateChild($slaves[$i], $slaves[$i].curBabies[_cb], 1))>> <<run $slaves[$i].curBabies.splice($slaves[$i].curBabies[_cb], 1)>> <<set _cb--, _curBabies-->> <<elseif $slaves[$i].curBabies[_cb].reserve == "nursery">> -- GitLab