From 3e991f41ac6bf1e550366614b44e5d7ed0bc9e69 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Wed, 3 Feb 2021 22:20:09 -0500
Subject: [PATCH] setup js cheat

---
 src/005-passages/interactPassages.js |  9 +++
 src/cheats/cheatEditSlave.js         | 88 ++++++++++++++++++++++++++++
 src/interaction/siNavigation.js      |  1 +
 3 files changed, 98 insertions(+)
 create mode 100644 src/cheats/cheatEditSlave.js

diff --git a/src/005-passages/interactPassages.js b/src/005-passages/interactPassages.js
index 558124e4cbb..8cfacc014db 100644
--- a/src/005-passages/interactPassages.js
+++ b/src/005-passages/interactPassages.js
@@ -99,3 +99,12 @@ new App.DomPassage(
 		return App.UI.SlaveInteract.exportSlave(getSlave(V.AS));
 	}, ["jump-from-safe"]
 );
+
+new App.DomPassage(
+	"Cheat Edit JS",
+	() => {
+		V.nextButton = "Cancel";
+		V.nextLink = "Slave Interact";
+		return App.UI.SlaveInteract.cheatEditSlave(getSlave(V.AS));
+	}, ["jump-from-safe"]
+);
diff --git a/src/cheats/cheatEditSlave.js b/src/cheats/cheatEditSlave.js
new file mode 100644
index 00000000000..fa3350726f5
--- /dev/null
+++ b/src/cheats/cheatEditSlave.js
@@ -0,0 +1,88 @@
+/** @param {App.Entity.SlaveState} slave */
+App.UI.SlaveInteract.cheatEditSlave = function(slave) {
+	const el = new DocumentFragment();
+	const r = [];
+	const {His} = getPronouns(slave);
+	const tempSlave = clone(slave);
+
+	/* get all prosthetics that are ready for this slave */
+	if (V.adjustProstheticsCompleted > 0) {
+		V.adjustProsthetics = V.adjustProsthetics.filter(function(p) {
+			if (p.workLeft <= 0 && p.slaveID === V.AS) {
+				addProsthetic(tempSlave, p.id);
+				V.adjustProstheticsCompleted--;
+				return false;
+			}
+			return true;
+		});
+	}
+
+	App.UI.tabBar.handlePreSelectedTab(V.tabChoice.RemoteSurgery);
+	App.UI.DOM.appendNewElement("h1", el, "The Remote Surgery");
+	r.push(`${tempSlave.slaveName} is lying strapped down on the table in your`);
+	if (V.surgeryUpgrade === 1) {
+		r.push(`heavily upgraded and customized`);
+	}
+	r.push(`remote surgery. The surgical equipment reads`);
+	if (tempSlave.health.health < -20) {
+		r.push(App.UI.DOM.makeElement("span", `SLAVE UNHEALTHY, SURGERY NOT RECOMMENDED.`, "red"));
+	} else if (tempSlave.health.health <= 20) {
+		r.push(App.UI.DOM.makeElement("span", `SLAVE HEALTHY, SURGERY SAFE.`, "yellow"));
+	} else {
+		r.push(App.UI.DOM.makeElement("span", `SLAVE HEALTHY, SURGERY ENCOURAGED.`, "green"));
+	}
+	if (V.PC.skill.medicine >= 100) {
+		r.push(`The remote surgery mechanisms that allow a surgeon to be brought in by telepresence are inactive, and the autosurgery is ready for your control inputs. Surgery on your slaves is a challenge and a pleasure you wouldn't dream of sharing.`);
+	}
+	App.Events.addNode(el, r, "div", "scene-intro");
+	if (tempSlave.indentureRestrictions >= 1) {
+		App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["yellow", "note"]);
+	}
+
+	// TODO: move me
+	/**
+	 *
+	 * @param {string} id
+	 * @param {Node} element
+	 * @returns {HTMLSpanElement}
+	 */
+	function makeSpanIded(id, element) {
+		const span = document.createElement("span");
+		span.id = id;
+		span.append(element);
+		return span;
+	}
+
+	const tabCaptions = {
+		"hairAndFace": 'Hair and Face',
+		"upper": 'Upper',
+		"lower": 'Lower',
+		"structural": 'Structural',
+		"exotic": 'Exotic',
+		"extreme": 'Extreme',
+	};
+
+	const tabBar = App.UI.DOM.appendNewElement("div", el, '', "tab-bar");
+	tabBar.append(
+		App.UI.tabBar.tabButton('hair-and-face', tabCaptions.hairAndFace),
+		App.UI.tabBar.tabButton('upper', tabCaptions.upper),
+		App.UI.tabBar.tabButton('lower', tabCaptions.lower),
+		App.UI.tabBar.tabButton('structural', tabCaptions.structural),
+		App.UI.tabBar.tabButton('exotic', tabCaptions.exotic),
+	);
+	if (V.seeExtreme) {
+		tabBar.append(App.UI.tabBar.tabButton('extreme', tabCaptions.extreme));
+	}
+
+	el.append(App.UI.tabBar.makeTab('hair-and-face', makeSpanIded("content-hair-and-face", App.UI.surgeryPassageHairAndFace(tempSlave, true))));
+	el.append(App.UI.tabBar.makeTab('upper', makeSpanIded("content-upperr", App.UI.surgeryPassageUpper(tempSlave, true))));
+	el.append(App.UI.tabBar.makeTab('lower', makeSpanIded("content-lower", App.UI.surgeryPassageLower(tempSlave, true))));
+	el.append(App.UI.tabBar.makeTab('structural', makeSpanIded("content-structural", App.UI.surgeryPassageStructural(tempSlave, true))));
+	el.append(App.UI.tabBar.makeTab('exotic', makeSpanIded("content-exotic", App.UI.surgeryPassageExotic(tempSlave, true))));
+
+	if (V.seeExtreme) {
+		el.append(App.UI.tabBar.makeTab('extreme', makeSpanIded("content-extreme", App.UI.surgeryPassageExtreme(tempSlave, true))));
+	}
+
+	return el;
+};
diff --git a/src/interaction/siNavigation.js b/src/interaction/siNavigation.js
index 78190796d74..68ca74ac55e 100644
--- a/src/interaction/siNavigation.js
+++ b/src/interaction/siNavigation.js
@@ -12,6 +12,7 @@ App.UI.SlaveInteract.navigation = function(slave) {
 	if (V.cheatMode) {
 		linkArray.push(App.UI.DOM.passageLink("Cheat Edit Slave", "MOD_Edit Slave Cheat", () => { V.cheater = 1; }));
 		linkArray.push(App.UI.DOM.passageLink("Cheat Edit Slave Alternative", "MOD_Edit Slave Cheat New", () => { V.cheater = 1; }));
+		linkArray.push(App.UI.DOM.passageLink("Cheat Edit Slave JS", "Cheat Edit JS", () => { V.cheater = 1; }));
 		App.UI.DOM.appendNewElement("div", p, App.UI.DOM.generateLinksStrip(linkArray), "note");
 	}
 
-- 
GitLab