From 41fecae7afb687db6a30c9a1ee169236e8992621 Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Mon, 21 Dec 2020 21:47:10 -0500 Subject: [PATCH] workaround to js --- src/005-passages/interactPassages.js | 9 +++ src/js/bodySwap/bodySwap.js | 68 +++++++++++++++++++++ src/js/bodySwap/slaveSlaveSwapWorkaround.tw | 22 ------- 3 files changed, 77 insertions(+), 22 deletions(-) delete mode 100644 src/js/bodySwap/slaveSlaveSwapWorkaround.tw diff --git a/src/005-passages/interactPassages.js b/src/005-passages/interactPassages.js index df3b388188c..9508caa88c7 100644 --- a/src/005-passages/interactPassages.js +++ b/src/005-passages/interactPassages.js @@ -30,3 +30,12 @@ new App.DomPassage("Fat Grafting", return App.UI.SlaveInteract.fatGraft(getSlave(V.AS)); } ); + +new App.DomPassage( + "Slave Slave Swap Workaround", + () => { + V.nextButton = "Abort Operation"; + V.nextLink = "Main"; + return bodySwapSelection(getSlave(V.AS)); + } +); diff --git a/src/js/bodySwap/bodySwap.js b/src/js/bodySwap/bodySwap.js index 4a7432b1c1e..023a818ac3a 100644 --- a/src/js/bodySwap/bodySwap.js +++ b/src/js/bodySwap/bodySwap.js @@ -256,3 +256,71 @@ globalThis.bodySwapName = function(soul, body) { soul.origBodyOwner = body.origBodyOwner; } }; + +/** + * + * @param {App.Entity.SlaveState} soul + * @returns {DocumentFragment} + */ +globalThis.bodySwapSelection = function(soul) { + const {him} = getPronouns(soul); + const el = new DocumentFragment(); + const cost = 10000; + App.UI.DOM.appendNewElement("div", el, `The surgeon awaits the pair of slaves to be strapped into the surgery. So far only ${soul.slaveName} is prepped:`, "scene-intro"); + App.UI.DOM.appendNewElement("div", el, `Select ${(V.seeExtreme) ? `Select an eligible slave (any slave who is not a fuckdoll)` : `a slave`} who will be trading bodies with ${him}. This operation will cost ${cashFormat(cost)}.`); + + for (const body of V.slaves) { + const slaveDiv = document.createElement("div"); + slaveDiv.append( + App.UI.DOM.link( + body.slaveName, + () => { + V.swappingSlave = body; + cashX(forceNeg(cost), "slaveSurgery", body); + }, + [], + "Slave Slave Swap" + ) + ); + const relTerm = relativeTerm(soul, body); + if (relTerm) { + slaveDiv.append(` ${relTerm}`); + } + if (body.relationshipTarget === soul.ID) { + const {wife} = getPronouns(body); + switch (body.relationship) { + case 1: + slaveDiv.append(` friends`); + break; + case 2: + slaveDiv.append(` best friends`); + break; + case 3: + slaveDiv.append(` friends with benefits`); + break; + case 4: + slaveDiv.append(` lover`); + break; + case 5: + slaveDiv.append(` soul${wife}`); + break; + } + } + if (body.rivalryTarget === soul.ID) { + switch (body.relationship) { + case 1: + slaveDiv.append(`dislikes`); + break; + case 2: + slaveDiv.append(`rival`); + break; + case 3: + slaveDiv.append(`bitterly hates`); + break; + } + } + el.append(slaveDiv); + } + + return el; +}; diff --git a/src/js/bodySwap/slaveSlaveSwapWorkaround.tw b/src/js/bodySwap/slaveSlaveSwapWorkaround.tw deleted file mode 100644 index 72ee529f98f..00000000000 --- a/src/js/bodySwap/slaveSlaveSwapWorkaround.tw +++ /dev/null @@ -1,22 +0,0 @@ -:: Slave Slave Swap Workaround [nobr] - -<<set $nextButton = "Abort Operation", $nextLink = "Main">> - -The surgeon awaits the pair of slaves to be strapped into the surgery. So far only <<= getSlave($AS).slaveName>> is prepped: -<br> -//Select the slave who will be trading bodies with $him. 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 ($slaves[_i].ID != $AS)>> - <<set _name = SlaveFullName($slaves[_i])>> - <br>[[_name|Slave Slave Swap][$swappingSlave = $slaves[_i], cashX(-10000, "slaveSurgery", $slaves[_i])]] - <</if>> - <</if>> - <</if>> - <</capture>> -<</for>> \ No newline at end of file -- GitLab