From 4798184e80d366e6912464ddad1efa0f0dea6c7b Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Mon, 5 Aug 2019 13:24:20 +0200
Subject: [PATCH] convert limb access in bodyModification.tw

---
 src/uncategorized/bodyModification.tw | 117 +++++++++++++++++---------
 1 file changed, 76 insertions(+), 41 deletions(-)

diff --git a/src/uncategorized/bodyModification.tw b/src/uncategorized/bodyModification.tw
index 32c59fcf449..634878a9b8e 100644
--- a/src/uncategorized/bodyModification.tw
+++ b/src/uncategorized/bodyModification.tw
@@ -34,7 +34,7 @@
 						You really slashed away with your knife, but were careful not to allow $him to bleed out.
 					<</if>>
 				<<default>>
-					The best way to apply scarring to the entire body is with a good old fashioned whip.  $His body is a mess of crisscrossed lines<<if $activeSlave.amp != 1>>, and $his limbs twisted so violently in their restraints that they too have become scarred<</if>>.
+					The best way to apply scarring to the entire body is with a good old fashioned whip.  $His body is a mess of crisscrossed lines<<if hasAnyNaturalLimbs($activeSlave)>>, and $his <<if getLimbCount($activeSlave, 1) > 1>>limbs twisted so violently in their restraints that they too have<<else>>only limb twists so violently in its restraints that it too has<</if>> become scarred<</if>>.
 			<</switch>>
 			No matter how you chose to apply it, scarring so much of $his body has @@.red; hurt $his health.@@
 			<<set $activeSlave.health -= 20>>
@@ -604,14 +604,14 @@ Tattoos:
 <<if $activeSlave.shouldersTat != 0>>							<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "shoulder")>><<set _hasTat = 1>><</if>>
 <<if $activeSlave.lipsTat != 0>>							<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "lips")>><<set _hasTat = 1>><</if>>
 <<if $activeSlave.boobsTat != 0>>							<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "breast")>><<set _hasTat = 1>><</if>>
-<<if $activeSlave.armsTat != 0 && $activeSlave.amp != 1>>	<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "upper arm")>><<set _hasTat = 1>><</if>>
+<<if $activeSlave.armsTat != 0 && hasAnyNaturalArms($activeSlave)>>	<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "upper arm")>><<set _hasTat = 1>><</if>>
 <<if $activeSlave.backTat != 0>>							<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "back")>><<set _hasTat = 1>><</if>>
 <<if $activeSlave.stampTat != 0>>							<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "lower back")>><<set _hasTat = 1>><</if>>
 <<if $activeSlave.buttTat != 0>>							<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "buttock")>><<set _hasTat = 1>><</if>>
 <<if $activeSlave.vaginaTat != 0>>							<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "vagina")>><<set _hasTat = 1>><</if>>
 <<if $activeSlave.dickTat != 0 && $activeSlave.dick > 0>>	<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "dick")>><<set _hasTat = 1>><</if>>
 <<if $activeSlave.anusTat != 0>>							<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "anus")>><<set _hasTat = 1>><</if>>
-<<if $activeSlave.legsTat != 0 && $activeSlave.amp != 1>>	<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "thigh")>><<set _hasTat = 1>><</if>>
+<<if $activeSlave.legsTat != 0 && hasAnyNaturalArms($activeSlave)>>	<br>&nbsp;&nbsp;&nbsp;&nbsp;<<= App.Desc.tattoo($activeSlave, "thigh")>><<set _hasTat = 1>><</if>>
 
 <br>&nbsp;&nbsp;&nbsp;&nbsp;
 Choose a tattoo style:
@@ -712,12 +712,14 @@ Choose a tattoo style:
 				<<set _degradationTemp += 1>>
 			<</if>>
 
-			<<if $activeSlave.amp != 1>>
+			<<if hasAnyNaturalArms($activeSlave)>>
 				<<if $activeSlave.armsTat != $tattooChoice>>
 					<<set $activeSlave.armsTat = $tattooChoice>>
 					<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
 					<<set _degradationTemp += 1>>
 				<</if>>
+			<</if>>
+			<<if hasAnyNaturalLegs($activeSlave)>>
 				<<if $activeSlave.legsTat != $tattooChoice>>
 					<<set $activeSlave.legsTat = $tattooChoice>>
 					<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
@@ -743,7 +745,7 @@ Choose a tattoo style:
 		<<if $activeSlave.shouldersTat != $tattooChoice>> | [[Shoulders|Body Modification][$activeSlave.shouldersTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<<if $activeSlave.lipsTat != $tattooChoice>> | [[Face|Body Modification][$activeSlave.lipsTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<<if $activeSlave.boobsTat != $tattooChoice>> | [[Boobs|Body Modification][$activeSlave.boobsTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
-		<<if $activeSlave.amp != 1>>
+		<<if hasAnyNaturalArms($activeSlave)>>
 			<<if $activeSlave.armsTat != $tattooChoice>> | [[Arms|Body Modification][$activeSlave.armsTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<</if>>
 		<<if $activeSlave.backTat != $tattooChoice>> | [[Upper back|Body Modification][$activeSlave.backTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
@@ -754,7 +756,7 @@ Choose a tattoo style:
 			<<if $activeSlave.dickTat != $tattooChoice>> | [[Dick|Body Modification][$activeSlave.dickTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<</if>>
 		<<if $activeSlave.anusTat != $tattooChoice>> | [[Anus|Body Modification][$activeSlave.anusTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
-		<<if $activeSlave.amp != 1>>
+		<<if hasAnyNaturalLegs($activeSlave)>>
 			<<if $activeSlave.legsTat != $tattooChoice>> | [[Legs|Body Modification][$activeSlave.legsTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<</if>>
 	<<elseif $tattooChoice == "permanent makeup">>
@@ -767,7 +769,7 @@ Choose a tattoo style:
 			<<if $activeSlave.lipsTat != $tattooChoice>> | [[Face|Body Modification][$activeSlave.lipsTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<</if>>
 		<<if $activeSlave.boobsTat != $tattooChoice>> | [[Boobs|Body Modification][$activeSlave.boobsTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
-		<<if $activeSlave.amp != 1>>
+		<<if hasAnyNaturalArms($activeSlave)>>
 			<<if $activeSlave.armsTat != $tattooChoice>> | [[Arms|Body Modification][$activeSlave.armsTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<</if>>
 		<<if $activeSlave.backTat != $tattooChoice>> | [[Upper back|Body Modification][$activeSlave.backTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
@@ -780,7 +782,7 @@ Choose a tattoo style:
 		<<if ($tattooChoice != "Asian art") && ($tattooChoice != "scenes")>>
 			<<if $activeSlave.anusTat != $tattooChoice>> | [[Anus|Body Modification][$activeSlave.anusTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<</if>>
-		<<if $activeSlave.amp != 1>>
+		<<if hasAnyNaturalLegs($activeSlave)>>
 			<<if $activeSlave.legsTat != $tattooChoice>> | [[Legs|Body Modification][$activeSlave.legsTat = $tattooChoice,cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)]]<</if>>
 		<</if>>
 	<</if>>
@@ -869,7 +871,7 @@ Custom Tats:
 	Give $him a custom shoulder tattoo: <<textbox "$activeSlave.shouldersTat" $activeSlave.shouldersTat "Slave Interact">>
 <</if>>
 
-<<if $activeSlave.armsTat == 0 && $activeSlave.amp != 1>>
+<<if $activeSlave.armsTat == 0 && hasAnyNaturalArms($activeSlave)>>
 	<br>&nbsp;&nbsp;&nbsp;&nbsp;
 	Give $him a custom arm tattoo: <<textbox "$activeSlave.armsTat" $activeSlave.armsTat "Slave Interact">>
 <</if>>
@@ -909,7 +911,7 @@ Custom Tats:
 	Give $him a custom anus tattoo: <<textbox "$activeSlave.anusTat" $activeSlave.anusTat "Slave Interact">>
 <</if>>
 
-<<if $activeSlave.legsTat == 0 && $activeSlave.amp != 1>>
+<<if $activeSlave.legsTat == 0 && hasAnyNaturalLegs($activeSlave)>>
 	<br>&nbsp;&nbsp;&nbsp;&nbsp;
 	Give $him a custom leg tattoo: <<textbox "$activeSlave.legsTat" $activeSlave.legsTat "Slave Interact">>
 <</if>>
@@ -1083,7 +1085,7 @@ Choose a site for branding:
 
 /* Arms*/
 | [[Shoulders|Body Modification][$brandTarget.local = "shoulder"]]
-<<if $activeSlave.amp == 0 && $activeSlave.missingArms != 3>>
+<<if hasAnyNaturalArms($activeSlave)>>
 	| [[Arm, upper|Body Modification][$brandTarget.local = "upper arm"]]
 	| [[Arm, lower|Body Modification][$brandTarget.local = "lower arm"]]
 	| [[Wrists|Body Modification][$brandTarget.local = "wrist"]]
@@ -1092,7 +1094,7 @@ Choose a site for branding:
 
 /* Legs */
 | [[Buttocks|Body Modification][$brandTarget.local = "buttock"]]
-<<if $activeSlave.amp == 0 && $activeSlave.missingLegs != 3>>
+<<if hasAnyNaturalLegs($activeSlave)>>
 	| [[Thighs|Body Modification][$brandTarget.local = "thigh"]]
 	| [[Calves|Body Modification][$brandTarget.local = "calf"]]
 	| [[Ankles|Body Modification][$brandTarget.local = "ankle"]]
@@ -1115,21 +1117,34 @@ Or a custom site: <<textbox "$brandTarget.local" $brandTarget.local "Body Modifi
 		$His _rightTarget is already marked with <<print $activeSlave.brand[_rightTarget]>>.
 	<</if>>
 	Brand $him now with ''$brandDesign.local'' on the
-	<<link "left">>
-		<<set $brandApplied = 1>>
-		<<set $activeSlave.brand[_leftTarget] = $brandDesign.local>>
-		<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
-		<<set $degradation += 10>>
-		<<goto "Body Modification">>
-	<</link>>
-	$brandTarget.local, or the
-	<<link "right">>
-		<<set $brandApplied = 1>>
-		<<set $activeSlave.brand[_rightTarget] = $brandDesign.local>>
-		<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
-		<<set $degradation += 10>>
-		<<goto "Body Modification">>
-	<</link>>? //Branding will slightly reduce $his beauty but may slowly increase your reputation.//
+
+	<<if !(["upper arm", "lower arm", "wrist", "hand"].includes($brandTarget.local) && getLeftArmID($activeSlave) !== 1) && !(["tigh", "calf", "ankle", "foot"].includes($brandTarget.local) && getLeftLegID($activeSlave) !== 1)>>
+		<<set _left = 1>> /* make next checks easier */
+		<<link "left">>
+			<<set $brandApplied = 1>>
+			<<set $activeSlave.brand[_leftTarget] = $brandDesign.local>>
+			<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
+			<<set $degradation += 10>>
+			<<goto "Body Modification">>
+		<</link>>
+	<</if>>
+	<<if !(["upper arm", "lower arm", "wrist", "hand"].includes($brandTarget.local) && getRightArmID($activeSlave) !== 1) && !(["tigh", "calf", "ankle", "foot"].includes($brandTarget.local) && getRightLegID($activeSlave) !== 1)>>
+		<<set _right = 1>> /* make next checks easier */
+	<</if>>
+	<<if _left && _right>>
+		$brandTarget.local, or the
+	<</if>>
+	<<if _right>>
+		<<link "right">>
+			<<set $brandApplied = 1>>
+			<<set $activeSlave.brand[_rightTarget] = $brandDesign.local>>
+			<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
+			<<set $degradation += 10>>
+			<<goto "Body Modification">>
+		<</link>>
+	<</if>><<if !_left || !_right>> $brandTarget.local<</if>>?
+
+	//Branding will slightly reduce $his beauty but may slowly increase your reputation.//
 <<else>>
 	<<if $activeSlave.brand[$brandTarget.local] === $brandDesign.local>>
 		$He already has $brandDesign.local on $his $brandTarget.local.
@@ -1219,7 +1234,7 @@ Choose a site for scaring:
 
 	/* Arms*/
 	| [[Shoulders|Body Modification][$scarTarget.local = "shoulder"]]
-	<<if $activeSlave.amp == 0 && $activeSlave.missingArms != 3>>
+	<<if hasAnyNaturalArms($activeSlave)>>
 		| [[Arm, upper|Body Modification][$scarTarget.local = "upper arm"]]
 		| [[Arm, lower|Body Modification][$scarTarget.local = "lower arm"]]
 		| [[Wrists|Body Modification][$scarTarget.local = "wrist"]]
@@ -1228,7 +1243,7 @@ Choose a site for scaring:
 
 	/* Legs */
 	| [[Buttocks|Body Modification][$scarTarget.local = "buttock"]]
-	<<if $activeSlave.amp == 0 && $activeSlave.missingLegs != 3>>
+	<<if hasAnyNaturalLegs($activeSlave)>>
 		| [[Thighs|Body Modification][$scarTarget.local = "thigh"]]
 		| [[Calves|Body Modification][$scarTarget.local = "calf"]]
 		| [[Ankles|Body Modification][$scarTarget.local = "ankle"]]
@@ -1257,15 +1272,26 @@ Or a custom site: <<textbox "$scarTarget.local" $scarTarget.local "Body Modifica
 		$His _rightTarget is already marked with <<= App.Desc.expandScarString($activeSlave, _rightTarget)>>.
 	<</if>>
 	Scar $him now with ''$scarDesign.local'' on the
-	<<link "left">>
-		<<set $scarTarget.local = _leftTarget>>
-		<<set $scarApplied = 1>>
-		<<run App.Medicine.Modification.addScar($activeSlave, _leftTarget, $scarDesign.local)>>
-		<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
-		<<set $degradation += 10>>
-		<<goto "Body Modification">>
-	<</link>>
-	$scarTarget.local, or the
+	<<set _left = 0, _right = 0>> /* overwrite brand */
+
+	<<if !(["upper arm", "lower arm", "wrist", "hand"].includes($scarTarget.local) && getLeftArmID($activeSlave) !== 1) && !(["tigh", "calf", "ankle", "foot"].includes($scarTarget.local) && getLeftLegID($activeSlave) !== 1)>>
+		<<set _left = 1>> /* make next checks easier */
+		<<link "left">>
+			<<set $scarTarget.local = _leftTarget>>
+			<<set $scarApplied = 1>>
+			<<run App.Medicine.Modification.addScar($activeSlave, _leftTarget, $scarDesign.local)>>
+			<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
+			<<set $degradation += 10>>
+			<<goto "Body Modification">>
+		<</link>>
+	<</if>>
+	<<if !(["upper arm", "lower arm", "wrist", "hand"].includes($scarTarget.local) && getRightArmID($activeSlave) !== 1) && !(["tigh", "calf", "ankle", "foot"].includes($scarTarget.local) && getRightLegID($activeSlave) !== 1)>>
+		<<set _right = 1>> /* make next checks easier */
+	<</if>>
+	<<if _left && _right>>
+		$scarTarget.local, or the
+	<</if>>
+	<<if _right>>
 	<<link "right">>
 		<<set $scarTarget.local = _rightTarget>>
 		<<set $scarApplied = 1>>
@@ -1273,7 +1299,7 @@ Or a custom site: <<textbox "$scarTarget.local" $scarTarget.local "Body Modifica
 		<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
 		<<set $degradation += 10>>
 		<<goto "Body Modification">>
-	<</link>>?
+	<</if>><<if !_left || !_right>> $scarTarget.local<</if>>?
 <<else>>
 	<<if $activeSlave.scar.hasOwnProperty($scarTarget.local)>>
 		<<if $activeSlave.scar[$scarTarget.local][$scarDesign.local]>>
@@ -1293,8 +1319,17 @@ Or a custom site: <<textbox "$scarTarget.local" $scarTarget.local "Body Modifica
 			/* Normal entire body scarring */
 			<<if $scarTarget.local === "entire body">>
 				<<set _scarArray = ["left breast", "right breast", "back", "lower back", "left buttock", "right buttock"]>>
-				<<if $activeSlave.amp != 1>>
-					<<set _scarArray.push("left upper arm", "right upper arm", "left thigh", "right thigh")>>
+				<<if getLeftArmID($activeSlave) === 0>>
+					<<set _scarArray.push("left upper arm")>>
+				<</if>>
+				<<if getRightArmID($activeSlave) === 0>>
+					<<set _scarArray.push("right upper arm")>>
+				<</if>>
+				<<if getLeftLegID($activeSlave) === 0>>
+					<<set _scarArray.push("left tigh")>>
+				<</if>>
+				<<if getRightLegID($activeSlave) === 0>>
+					<<set _scarArray.push("right tigh")>>
 				<</if>>
 			/* Single scar */
 			<<else>>
-- 
GitLab