From d131edd958ea19ec2527613225fde9d1423ebc74 Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Tue, 22 Dec 2020 12:56:02 -0500 Subject: [PATCH] Convert husk slave swap as well --- src/005-passages/interactPassages.js | 15 +++++++ .../incubator/incubatorRetrievalWorkaround.tw | 4 +- src/js/bodySwap/bodySwap.js | 43 +++++++++++++++++++ src/pregmod/huskSlaveSwapWorkaround.tw | 34 --------------- src/pregmod/seHuskSlaveDelivery.tw | 2 +- 5 files changed, 61 insertions(+), 37 deletions(-) delete mode 100644 src/pregmod/huskSlaveSwapWorkaround.tw diff --git a/src/005-passages/interactPassages.js b/src/005-passages/interactPassages.js index 9508caa88c7..f462029f608 100644 --- a/src/005-passages/interactPassages.js +++ b/src/005-passages/interactPassages.js @@ -39,3 +39,18 @@ new App.DomPassage( return bodySwapSelection(getSlave(V.AS)); } ); + +new App.DomPassage( + "Husk Slave Swap Workaround", + () => { + V.nextButton = "Abort Operation"; + if (V.activeSlave.tankBaby !== 3) { + V.nextLink = "Scheduled Event"; + V.returnTo = "Scheduled Event"; + } else { + V.nextLink = "Main"; + V.returnTo = "Incubator"; + } + return bodySwapSelection(getSlave(V.AS)); + } +); diff --git a/src/facilities/incubator/incubatorRetrievalWorkaround.tw b/src/facilities/incubator/incubatorRetrievalWorkaround.tw index ba3b56c0f25..b5b886d376c 100644 --- a/src/facilities/incubator/incubatorRetrievalWorkaround.tw +++ b/src/facilities/incubator/incubatorRetrievalWorkaround.tw @@ -25,14 +25,14 @@ <</if>> <<includeDOM App.UI.newChildIntro($readySlave)>> <<else>> - <<set $activeSlave = $readySlave>> /* $activeSlave is used by husk Slave Swap Workaround */ + <<set $activeSlave = $readySlave>> /* $activeSlave is used by Husk Slave Swap Workaround */ A husk is ready to be used. <br> //As expected, $he is a complete vegetable, but that is what you wanted after all. You lack the facilities to care for $him in this state, so you should do what you are planning quickly. Or you could sell $him to the Flesh Heap.// <<set _price = Math.trunc(slaveCost($readySlave)/3)>> <span id="result"> <<if $cash >= $surgeryCost>> - <br>[[Contact the bodyswap surgeon.|husk Slave Swap Workaround]] //Will significantly increase the selected slave's upkeep.// + <br>[[Contact the bodyswap surgeon.|Husk Slave Swap Workaround]] //Will significantly increase the selected slave's upkeep.// <br>[[Sell the husk to Flesh Heap.|Main][cashX(_price, "slaveTransfer")]] //This body can be bought by the Flesh Heap for <<print cashFormat(_price)>>//. <<else>> diff --git a/src/js/bodySwap/bodySwap.js b/src/js/bodySwap/bodySwap.js index d1c4e345493..6ddecdcff22 100644 --- a/src/js/bodySwap/bodySwap.js +++ b/src/js/bodySwap/bodySwap.js @@ -316,3 +316,46 @@ globalThis.bodySwapSelection = function(soul) { return el; }; + +/** + * + * @param {App.Entity.SlaveState} body + * @returns {DocumentFragment} + */ +globalThis.huskSwapSelection = function(body) { + const el = new DocumentFragment(); + const cost = 10000; + App.UI.DOM.appendNewElement("div", el, `"This operation is neither simple nor is it perfected. There are extreme health risks involved and no guarantee of success. Strap a slave into your remote surgery to consent to the operation. Indentured servants${(V.incubator > 0) || (V.nurseryChildren) ? `and slaves with reserved children`:``} are not eligible." + `, "scene-intro"); + App.UI.DOM.appendNewElement("div", el, `Select the slave whose mind will be transferred into the waiting husk. Amputated slaves must not be wearing prosthetics. This operation will cost ${cashFormat(cost)}.`); + + for (const soul of V.slaves) { + if (isSlaveAvailable(soul)) { + if (soul.fuckdoll === 0) { + if (!hasAnyProstheticLimbs(soul)) { + if (soul.indenture === -1) { + if (soul.breedingMark === 0 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset") { + if (WombReserveCount(soul) === 0) { + if (soul.ID !== body.ID) { + App.UI.DOM.appendNewElement("div", el, + App.UI.DOM.link( + soul.slaveName, + () => { + V.swappingSlave = soul; + cashX(forceNeg(cost), "slaveSurgery", soul); + }, + [], + "Husk Slave Swap" + ) + ); + } + } + } + } + } + } + } + } + + return el; +}; diff --git a/src/pregmod/huskSlaveSwapWorkaround.tw b/src/pregmod/huskSlaveSwapWorkaround.tw deleted file mode 100644 index 112c4ccb092..00000000000 --- a/src/pregmod/huskSlaveSwapWorkaround.tw +++ /dev/null @@ -1,34 +0,0 @@ -:: husk Slave Swap Workaround [nobr] - -<<if $activeSlave.tankBaby != 3>> - <<set $nextButton = "Abort Operation", $nextLink = "Scheduled Event", $returnTo = "Scheduled Event">> -<<else>> - <<set $nextButton = "Abort Operation", $nextLink = "Main", $returnTo = "Incubator">> -<</if>> - -"This operation is neither simple nor is it perfected. There are extreme health risks involved and no guarantee of success. Strap a slave into your remote surgery to consent to the operation. Indentured servants<<if ($incubator > 0) || ($nurseryChildren)>> and slaves with reserved children<</if>> are not eligible." -<br> -//Select the slave whose mind will be transferred into the waiting husk. Amputated slaves must not be wearing prosthetics. This operation will cost <<print cashFormat(10000)>>.// - -<br><br> -__Select an eligible slave:__ -<<for _i = 0; _i < $slaves.length; _i++>> - <<capture _i>> - <<if isSlaveAvailable($slaves[_i])>> - <<if $slaves[_i].fuckdoll == 0>> - <<if !hasAnyProstheticLimbs($slaves[_i])>> - <<if $slaves[_i].indenture == -1>> - <<if $slaves[_i].breedingMark == 0 || $propOutcome == 0 || $eugenicsFullControl == 1 || $arcologies[0].FSRestart == "unset">> - <<if WombReserveCount($slaves[_i]) == 0>> - <<if $slaves[_i].ID != $AS>> - <<set _name = SlaveFullName($slaves[_i])>> - <br>[[_name|Husk Slave Swap][$swappingSlave = $slaves[_i], cashX(-10000, "slaveSurgery", $slaves[_i])]] - <</if>> - <</if>> - <</if>> - <</if>> - <</if>> - <</if>> - <</if>> - <</capture>> -<</for>> diff --git a/src/pregmod/seHuskSlaveDelivery.tw b/src/pregmod/seHuskSlaveDelivery.tw index 59a79704dd4..2d8d2c36028 100644 --- a/src/pregmod/seHuskSlaveDelivery.tw +++ b/src/pregmod/seHuskSlaveDelivery.tw @@ -73,7 +73,7 @@ A slave came in fitting the description you provided. <<if $cash >= $surgeryCost>> <<link "Accept the offered slave and contact the bodyswap surgeon.">> <<set $activeSlave = _husk>> - <<goto "husk Slave Swap Workaround">> + <<goto "Husk Slave Swap Workaround">> <</link>> //Will significantly increase the selected slave's upkeep.// <<else>> -- GitLab