From 575331295ac036dee6e055d1ea097524ac88857a Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Sun, 1 Sep 2019 22:01:08 +0200
Subject: [PATCH] convert limb variables part 2

---
 src/facilities/nursery/nurseryWidgets.js | 50 ++++++++++++---------
 src/interaction/prostheticConfig.tw      | 56 ++++++++++++------------
 src/js/datatypeCleanupJS.js              |  7 ---
 src/js/surgery.js                        |  3 +-
 4 files changed, 59 insertions(+), 57 deletions(-)

diff --git a/src/facilities/nursery/nurseryWidgets.js b/src/facilities/nursery/nurseryWidgets.js
index 5db47bafdc2..d2d15970be5 100644
--- a/src/facilities/nursery/nurseryWidgets.js
+++ b/src/facilities/nursery/nurseryWidgets.js
@@ -15560,7 +15560,8 @@ App.Facilities.Nursery.infantToChild = function infantToChild(child) {
 	child.addict = 0,
 	child.age = child.actualAge,
 	child.ageImplant = 0,
-	child.amp = 0,
+	child.arm = {left: {type: 1}, right:{type: 1}},
+	child.leg = {left: {type: 1}, right:{type: 1}},
 	child.analArea = 0,
 	child.anus = 0,
 	child.anusPiercing = 0,
@@ -15733,9 +15734,7 @@ App.Facilities.Nursery.infantToChild = function infantToChild(child) {
 	child.makeup = 0,
 	child.markings = "none",
 	child.minorInjury = 0,
-	child.missingArms = 0,
 	child.missingEyes = 0,
-	child.missingLegs = 0,
 	child.mpreg = 0,
 	child.muscles = jsRandom(-10, 10),
 	child.nails = 0,
@@ -17034,17 +17033,34 @@ App.Facilities.Nursery.ChildState = class ChildState {
 			* * 2: advanced interface
 			*/
 		this.PLimb = 0;
+		/*
+		 * legs of the slave
+		 * * type:0: no leg
+		 * * type:1: has leg
+		 * * 2: simple prosthetic
+		 * * 3: artificial leg - Sex
+		 * * 4: artificial leg - Beauty
+		 * * 5: artificial leg - Combat
+		 * * 6: swiss army leg
+		 */
+		this.leg = {
+			left: {type:1},
+			right: {type:1}
+		};
 		/**
-		* is slave amputee
-		* * -5: swiss army limbs
-		* * -4: artificial limbs - Combat
-		* * -3: artificial limbs - Beauty
-		* * -2: artificial limbs - Sex
-		* * -1: artificial limbs
-		* * 0: no;
-		* * 1: yes
-		*/
-		this.amp = 0;
+		 * arms of the slave
+		 * * type:0: no arm
+		 * * type:1: has arm
+		 * * 2: simple prosthetic
+		 * * 3: artificial arm - Sex
+		 * * 4: artificial arm - Beauty
+		 * * 5: artificial arm - Combat
+		 * * 6: swiss army arm
+		 */
+		this.arm = {
+			left: {type:1},
+			right: {type:1}
+		};
 		/** Are heels clipped
 		*
 		* 0: no, 1: yes */
@@ -18645,14 +18661,6 @@ App.Facilities.Nursery.ChildState = class ChildState {
 		*
 		* 0: none; 1: yes, left; 2: yes, right; 3: yes, both */
 		this.missingEyes = 0;
-		/** Are arms missing?
-		*
-		* 0: none; 1: yes, left; 2: yes, right; 3: yes, both */
-		this.missingArms = 0;
-		/** Are legs missing?
-		*
-		* 0: none; 1: yes, left; 2: yes, right; 3: yes, both */
-		this.missingLegs = 0;
 		/** Amount of cash paid to acquire the slave
 		*
 		* accepts negative numbers, 0, or 1.
diff --git a/src/interaction/prostheticConfig.tw b/src/interaction/prostheticConfig.tw
index c24d1f946eb..35d51a0e0d0 100644
--- a/src/interaction/prostheticConfig.tw
+++ b/src/interaction/prostheticConfig.tw
@@ -20,7 +20,7 @@
 <h1>Prosthetic Configuration</h1>
 
 This room is lined with shelves and cabinets, it could be easily mistaken for a storage room if it were not for the examination table in its center.<br>
-<<if $activeSlave.amp != 1>>
+<<if hasBothLegs($activeSlave)>>
 	Your slave $activeSlave.slaveName is obediently waiting for your instructions.
 <<else>>
 	Your slave $activeSlave.slaveName is lying on the table, waiting for your instructions.
@@ -152,14 +152,15 @@ This room is lined with shelves and cabinets, it could be easily mistaken for a
 	<br><br>
 	<<if $activeSlave.fuckdoll != 0>>
 		// A Fuckdoll can't use prosthetic limbs. //
-	<<elseif $activeSlave.amp == 0>>
+	<<elseif hasAnyNaturalLimbs($activeSlave)>>
 		// $He must be a quadruple amputee to attach prosthetic limbs. //
 	<<elseif $activeSlave.PLimb == 0>>
 		// $He must have a prosthetic interface installed to attach prosthetic limbs. //
 	<<else>>
-		<<if $activeSlave.amp < 0>>
+		/* Currently prosthetics are all or nothing; will be changed */
+		<<if getLeftArmID($activeSlave) > 1>>
 			//$He currently has
-			<<switch $activeSlave.amp>>
+			<<switch getLeftArmID($activeSlave)>>
 			<<case -1>> <<= addA(setup.prosthetics.basicL.name)>>
 			<<case -2>> <<= addA(setup.prosthetics.sexL.name)>>
 			<<case -3>> <<= addA(setup.prosthetics.beautyL.name)>>
@@ -168,39 +169,39 @@ This room is lined with shelves and cabinets, it could be easily mistaken for a
 			<</switch>>
 			installed.//<br>
 			<<link "Detach <<= $his>> limbs" "Prosthetics Configuration">>
-				<<set $activeSlave.amp = 1, $activeSlave.missingArms = 3, $activeSlave.missingLegs = 3, $prostheticsConfig = "removeLimbs">>
+				<<set removeLimbs($activeSlave, "all"), $prostheticsConfig = "removeLimbs">>
 			<</link>>
 			<br><br>
 		<</if>>
-		/*TODO save .legsTat and .armsTat / link them to prosthetic*/
-		<<if $activeSlave.amp != -1 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "basicL"}) != -1>>
+		/* TODO save .legsTat and .armsTat / link them to prosthetic*/
+		<<if getLeftArmID($activeSlave) !== 2 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "basicL"}) != -1>>
 			<<link "Attach <<= addA(setup.prosthetics.basicL.name)>>" "Prosthetics Configuration">>
-				<<set $activeSlave.amp = -1, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "basicPLimbs">>
+				<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 2), $prostheticsConfig = "basicPLimbs">>
 			<</link>>
 			<br>
 		<</if>>
-		<<if $activeSlave.amp != -2 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "sexL"}) != -1>>
+		<<if getLeftArmID($activeSlave) !== 3 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "sexL"}) != -1>>
 			<<link "Attach <<= addA(setup.prosthetics.sexL.name)>>" "Prosthetics Configuration">>
-				<<set $activeSlave.amp = -2, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "sexPLimbs">>
+				<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 3), $prostheticsConfig = "sexPLimbs">>
 			<</link>>
 			<br>
 		<</if>>
-		<<if $activeSlave.amp != -3 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "beautyL"}) != -1>>
+		<<if getLeftArmID($activeSlave) !== 4 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "beautyL"}) != -1>>
 			<<link "Attach <<= addA(setup.prosthetics.beautyL.name)>>" "Prosthetics Configuration">>
-				<<set $activeSlave.amp = -3, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "beautyPLimbs">>
+				<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 4), $prostheticsConfig = "beautyPLimbs">>
 			<</link>>
 			<br>
 		<</if>>
-		<<if $activeSlave.amp != -4 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "combatL"}) != -1>>
+		<<if getLeftArmID($activeSlave) !== 5 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "combatL"}) != -1>>
 			<<link "Attach <<= addA(setup.prosthetics.combatL.name)>>" "Prosthetics Configuration">>
-				<<set $activeSlave.amp = -4, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "combatPLimbs">>
+				<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 5), $prostheticsConfig = "combatPLimbs">>
 			<</link>>
 			<br>
 		<</if>>
-		<<if $activeSlave.amp != -5 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "cyberneticL"}) != -1>>
+		<<if getLeftArmID($activeSlave) !== 6 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "cyberneticL"}) != -1>>
 			<<if $activeSlave.PLimb == 2>>
 				<<link "Attach <<= addA(setup.prosthetics.cyberneticL.name)>>" "Prosthetics Configuration">>
-					<<set $activeSlave.amp = -5, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "cyberPLimbs">>
+					<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 6), $prostheticsConfig = "cyberPLimbs">>
 				<</link>>
 			<<else>>
 				// $He must have <<= addA(setup.prosthetics.interfaceP2.name)>> installed to attach <<= addA(setup.prosthetics.cyberneticL.name)>>. //
@@ -329,7 +330,7 @@ Fit prosthetics to $him:
 
 <<case "eyeColor">>
 	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
-	<<if $activeSlave.amp != 1>>You have $him lie down and<<else>>You<</if>> use a speculum to keep $his eyes open while you disengage $his lenses remotely and swap them out with $his new $activeSlave.eyeColor lenses<<if $activeSlave.pupil != "circular" || $activeSlave.sclerae != "white">> with <<if $activeSlave.pupil != "circular" >>$activeSlave.pupil pupils<</if>><<if $activeSlave.pupil != "circular" && $activeSlave.sclerae != "white">> and <</if>><<if $activeSlave.sclerae != "white" >>$activeSlave.sclerae sclerae<</if>><</if>>.
+	<<if hasBothLegs($activeSlave)>>You have $him lie down and<<else>>You<</if>> use a speculum to keep $his eyes open while you disengage $his lenses remotely and swap them out with $his new $activeSlave.eyeColor lenses<<if $activeSlave.pupil != "circular" || $activeSlave.sclerae != "white">> with <<if $activeSlave.pupil != "circular" >>$activeSlave.pupil pupils<</if>><<if $activeSlave.pupil != "circular" && $activeSlave.sclerae != "white">> and <</if>><<if $activeSlave.sclerae != "white" >>$activeSlave.sclerae sclerae<</if>><</if>>.
 
 <<case "eyes">>
 	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
@@ -409,7 +410,6 @@ Fit prosthetics to $him:
 
 <<case "removeLimbs">>
 	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
-	<<set $activeSlave.amp = 1, $activeSlave.missingArms = 3, $activeSlave.missingLegs = 3>>
 	Due to built-in safeties it is necessary to remove each limb separately, first releasing the lock and then waiting for automated seal release.<br>
 	<<if ($activeSlave.devotion > 20)>>
 		You instruct $him to lie down on the table and proceed to remove $his limbs. $He <<if canSee($activeSlave)>>watches<<elseif canHear($activeSlave)>>listens<<else>>waits<</if>> with interest as you work.<<if ($activeSlave.devotion > 50)>> As you remove the last limb $he playfully wiggles $his stumps at you.<</if>>
@@ -463,58 +463,58 @@ Fit prosthetics to $him:
 	<span id="attach">
 	<<set _first = 1>>
 	/*TODO save .legsTat and .armsTat / link them to prosthetic*/
-	<<if $activeSlave.amp != -1 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "basicL"}) != -1>>
+	<<if getLeftArmID($activeSlave) !== 2 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "basicL"}) != -1>>
 		<<if _first>>
 			<br><br>Since you already have prepared limbs for $him you might as well attach them while you are working on $him:<br>
 			<<set _first = 0>>
 		<</if>>
 		<<link "Attach <<= addA(setup.prosthetics.basicL.name)>>">>
-			<<set $activeSlave.amp = -1, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "basicPLimbs">>
+			<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 2), $prostheticsConfig = "basicPLimbs">>
 			<<replace #attach>><br><br><<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
 		<</link>>
 		<br>
 	<</if>>
-	<<if $activeSlave.amp != -2 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "sexL"}) != -1>>
+	<<if getLeftArmID($activeSlave) !== 3 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "sexL"}) != -1>>
 		<<if _first>>
 			<br><br>Since you already have prepared limbs for $him you might as well attach them while you are working on $him:<br>
 			<<set _first = 0>>
 		<</if>>
 		<<link "Attach <<= addA(setup.prosthetics.sexL.name)>>">>
-			<<set $activeSlave.amp = -2, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "sexPLimbs">>
+			<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 3), $prostheticsConfig = "sexPLimbs">>
 			<<replace #attach>><br><br><<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
 		<</link>>
 		<br>
 	<</if>>
-	<<if $activeSlave.amp != -3 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "beautyL"}) != -1>>
+	<<if getLeftArmID($activeSlave) !== 4 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "beautyL"}) != -1>>
 		<<if _first>>
 			<br><br>Since you already have prepared limbs for $him you might as well attach them while you are working on $him:<br>
 			<<set _first = 0>>
 		<</if>>
 		<<link "Attach <<= addA(setup.prosthetics.beautyL.name)>>">>
-			<<set $activeSlave.amp = -3, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "beautyPLimbs">>
+			<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 4), $prostheticsConfig = "beautyPLimbs">>
 			<<replace #attach>><br><br><<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
 		<</link>>
 		<br>
 	<</if>>
-	<<if $activeSlave.amp != -4 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "combatL"}) != -1>>
+	<<if getLeftArmID($activeSlave) !== 5 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "combatL"}) != -1>>
 		<<if _first>>
 			<br><br>Since you already have prepared limbs for $him you might as well attach them while you are working on $him:<br>
 			<<set _first = 0>>
 		<</if>>
 		<<link "Attach <<= addA(setup.prosthetics.combatL.name)>>">>
-			<<set $activeSlave.amp = -4, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "combatPLimbs">>
+			<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 5), $prostheticsConfig = "combatPLimbs">>
 			<<replace #attach>><br><br><<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
 		<</link>>
 		<br>
 	<</if>>
-	<<if $activeSlave.amp != -5 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "cyberneticL"}) != -1>>
+	<<if getLeftArmID($activeSlave) !== 6 && $activeSlave.readyProsthetics.findIndex(function(p) {return p.id == "cyberneticL"}) != -1>>
 		<<if $activeSlave.PLimb == 2>>
 			<<if _first>>
 				<br><br>Since you already have prepared limbs for $him you might as well attach them while you are working on $him:<br>
 				<<set _first = 0>>
 			<</if>>
 			<<link "Attach <<= addA(setup.prosthetics.cyberneticL.name)>>" "Prosthetics Configuration">>
-				<<set $activeSlave.amp = -5, $activeSlave.missingArms = 0, $activeSlave.missingLegs = 0, $prostheticsConfig = "cyberPLimbs">>
+				<<set removeLimbs($activeSlave, "all"), attachProsthetic($activeSlave, "all", 6), $prostheticsConfig = "cyberPLimbs">>
 				<<replace #attach>><br><br><<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
 			<</link>>
 		<</if>>
diff --git a/src/js/datatypeCleanupJS.js b/src/js/datatypeCleanupJS.js
index 29f262e8d63..6340c6670ea 100644
--- a/src/js/datatypeCleanupJS.js
+++ b/src/js/datatypeCleanupJS.js
@@ -978,11 +978,6 @@ window.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 			slave.earwear = "none";
 		}
 		slave.heels = Math.clamp(+slave.heels, 0, 1) || 0;
-		slave.amp = Math.clamp(+slave.amp, -5, 1) || 0;
-		if (slave.amp == 1) {
-			slave.missingArms = 3;
-			slave.missingLegs = 3;
-		}
 		slave.PLimb = Math.clamp(+slave.PLimb, 0, 1) || 0;
 		if (slave.voice !== 0) {
 			slave.voice = Math.clamp(+slave.voice, 0, 3) || 1;
@@ -990,8 +985,6 @@ window.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 		slave.electrolarynx = Math.clamp(+slave.electrolarynx, 0, 1) || 0;
 		slave.accent = Math.clamp(+slave.accent, 0, 3) || 0;
 		slave.missingEyes = Math.clamp(+slave.missingEyes, 0, 3) || 0;
-		slave.missingArms = Math.clamp(+slave.missingArms, 0, 3) || 0;
-		slave.missingLegs = Math.clamp(+slave.missingLegs, 0, 3) || 0;
 		if (typeof slave.ballType !== "string") {
 			slave.ballType = "human";
 		}
diff --git a/src/js/surgery.js b/src/js/surgery.js
index 0a5f3eca603..812402f9863 100644
--- a/src/js/surgery.js
+++ b/src/js/surgery.js
@@ -590,13 +590,14 @@ window.removeLimbs = function(slave, limb) {
 
 
 /**
- * Will overwrite existing limbs.
+ * Expects amputated limbs. Will overwrite existing limbs.
  *
  * Allowed values for limb:
  * left arm, right arm, left leg, right arm, all
  *
  * @param {App.Entity.SlaveState} slave
  * @param {string} limb
+ * @param {number} id
  */
 window.attachProsthetic = function(slave, limb, id) {
 	// TODO: add support for body mods
-- 
GitLab