From 477e67b06364bd73a856720a799028083a67b59c Mon Sep 17 00:00:00 2001
From: klorpa <30924131+klorpa@users.noreply.github.com>
Date: Thu, 28 Mar 2019 22:12:55 -0500
Subject: [PATCH] UnErrored

---
 src/cheats/mod_editSlaveCheatNew.tw           |   4 +-
 .../nursery/longChildDescription.tw           |   2 +-
 src/js/utilJS.js                              | 120 +++++++++---------
 src/npc/startingGirls/startingGirls.tw        |   2 +-
 src/uncategorized/RESS.tw                     |   2 +-
 src/uncategorized/longSlaveDescription.tw     |   2 +-
 src/uncategorized/resFailure.tw               |   2 +-
 src/uncategorized/salon.tw                    |  14 +-
 src/utility/descriptionWidgetsFlesh.tw        |  12 +-
 src/utility/slaveCreationWidgets.tw           |   2 +-
 10 files changed, 85 insertions(+), 77 deletions(-)

diff --git a/src/cheats/mod_editSlaveCheatNew.tw b/src/cheats/mod_editSlaveCheatNew.tw
index ff8b3f533c4..b773651d491 100644
--- a/src/cheats/mod_editSlaveCheatNew.tw
+++ b/src/cheats/mod_editSlaveCheatNew.tw
@@ -1496,7 +1496,7 @@
 	<<radiobutton "$tempSlave.earT" "neko">> Cat
 	<<radiobutton "$tempSlave.earT" "inu">> Dog
 	<<radiobutton "$tempSlave.earT" "kit">> Fox
-	<<radiobutton "$tempSlave.earT" "tanuki">> TANUKI
+	<<radiobutton "$tempSlave.earT" "tanuki">> Tanuki
 	<br><br>
 
 	''Sense of Smell:''
@@ -2143,7 +2143,7 @@
 	<<radiobutton "$tempSlave.tailShape" "inu">> Dog
 	<<radiobutton "$tempSlave.tailShape" "kit">> Fox
 	<<radiobutton "$tempSlave.tailShape" "kitsune">> 3 Fox Tails
-	<<radiobutton "$tempSlave.tailShape" "tanuki">> TANUKI
+	<<radiobutton "$tempSlave.tailShape" "tanuki">> Tanuki
 	<<radiobutton "$tempSlave.tailShape" "ushi">> Bovine
 
 	<br><br>
diff --git a/src/facilities/nursery/longChildDescription.tw b/src/facilities/nursery/longChildDescription.tw
index 99770ac738b..ffdcc8437fe 100644
--- a/src/facilities/nursery/longChildDescription.tw
+++ b/src/facilities/nursery/longChildDescription.tw
@@ -1176,7 +1176,7 @@ $He is
 	<<if $activeChild.markings == "birthmark" && $activeChild.prestige == 0 && $activeChild.pornPrestige < 2>>
 		$He has a large, liver-colored birthmark, detracting from $his beauty.
 	<</if>>
-	<<if (skinToneLevel($activeChild.skin) > skinToneLevel($activeChild.origSkin))>>
+	<<if ($activeChild.skin == "sun tanned")>>
 		<<if ($activeChild.releaseRules != "restrictive" && $activeChild.releaseRules != "masturbation" && $activeChild.releaseRules != "chastity")>>
 			<<if ($activeChild.fetishStrength > 60) && ($activeChild.fetishKnown == 1)>>
 				$His tan is slightly uneven, since $he enjoys
diff --git a/src/js/utilJS.js b/src/js/utilJS.js
index 8f86bcbe134..d8cb8ea1893 100644
--- a/src/js/utilJS.js
+++ b/src/js/utilJS.js
@@ -1618,73 +1618,73 @@ window.randomRaceHair = function(raceName) {
 };
 
 window.skinToneLevel = function(skinTone) {
-	let skinNumber;
-	let skinToMelanin = {
-		"pure black": 25,
-		"ebony": 24,
-		"black": 23,
-		"dark brown": 22,
-		"brown": 21,
-		"light brown": 20,
-		"dark beige": 19,
-		"beige": 18,
-		"light beige": 17,
-		"dark": 16,
-		"dark olive": 15,
-		"bronze": 14,
-		"olive": 13,
-		"tan": 12,
-		"light olive": 11,
-		"light": 10,
-		"fair": 9,
-		"very fair": 8,
-		"extremely fair": 7,
-		"pale": 6,
-		"very pale": 5,
-		"extremely pale": 4,
-		"white": 3,
-		"ivory": 2,
-		"pure white": 1
-	};
-	if (!setup.naturalSkins.includes(skin)) {
+	if (!setup.naturalSkins.includes(skinTone)) {
 		return null;
 	} else {
+		let skinNumber;
+		let skinToMelanin = {
+			"pure black": 25,
+			"ebony": 24,
+			"black": 23,
+			"dark brown": 22,
+			"brown": 21,
+			"light brown": 20,
+			"dark beige": 19,
+			"beige": 18,
+			"light beige": 17,
+			"dark": 16,
+			"dark olive": 15,
+			"bronze": 14,
+			"olive": 13,
+			"tan": 12,
+			"light olive": 11,
+			"light": 10,
+			"fair": 9,
+			"very fair": 8,
+			"extremely fair": 7,
+			"pale": 6,
+			"very pale": 5,
+			"extremely pale": 4,
+			"white": 3,
+			"ivory": 2,
+			"pure white": 1
+		};
 		skinNumber = skinToMelanin[skinTone];
 		return skinNumber;
 	}
 };
 
 window.changeSkinTone = function(skin, value) {
-	let skinToMelanin = {
-		"pure black": 25,
-		"ebony": 24,
-		"black": 23,
-		"dark brown": 22,
-		"brown": 21,
-		"light brown": 20,
-		"dark beige": 19,
-		"beige": 18,
-		"light beige": 17,
-		"dark": 16,
-		"dark olive": 15,
-		"bronze": 14,
-		"olive": 13,
-		"tan": 12,
-		"light olive": 11,
-		"light": 10,
-		"fair": 9,
-		"very fair": 8,
-		"extremely fair": 7,
-		"pale": 6,
-		"very pale": 5,
-		"extremely pale": 4,
-		"white": 3,
-		"ivory": 2,
-		"pure white": 1
-	};
 	if (!setup.naturalSkins.includes(skin)) {
 		return skin;
 	} else {
+		let skinToMelanin = {
+			"pure black": 25,
+			"ebony": 24,
+			"black": 23,
+			"dark brown": 22,
+			"brown": 21,
+			"light brown": 20,
+			"dark beige": 19,
+			"beige": 18,
+			"light beige": 17,
+			"dark": 16,
+			"dark olive": 15,
+			"bronze": 14,
+			"olive": 13,
+			"tan": 12,
+			"light olive": 11,
+			"light": 10,
+			"fair": 9,
+			"very fair": 8,
+			"extremely fair": 7,
+			"pale": 6,
+			"very pale": 5,
+			"extremely pale": 4,
+			"white": 3,
+			"ivory": 2,
+			"pure white": 1
+		};
 		let newSkin = (skinToMelanin[skin] + value);
 		if (newSkin > 25) {
 			newSkin = 25;
@@ -1692,10 +1692,10 @@ window.changeSkinTone = function(skin, value) {
 			newSkin = 1;
 		}
 		let prop = "";
-			for (prop in skinToMelanin) {
-				if (!skinToMelanin.hasOwnProperty(prop)) continue;
-				if (newSkin >= skinToMelanin[prop]) return prop;
-			}
+		for (prop in skinToMelanin) {
+			if (!skinToMelanin.hasOwnProperty(prop)) continue;
+			if (newSkin >= skinToMelanin[prop]) return prop;
+		}
 		return prop;
 	}
 };
\ No newline at end of file
diff --git a/src/npc/startingGirls/startingGirls.tw b/src/npc/startingGirls/startingGirls.tw
index 16a9cf27ab5..4ce7f0557ed 100644
--- a/src/npc/startingGirls/startingGirls.tw
+++ b/src/npc/startingGirls/startingGirls.tw
@@ -1599,7 +1599,7 @@ __You are customizing this slave:__
 <<link "Cali Girl">>
 	<<set $archetyped = 1, $activeSlave.nationality = "American", $fixedNationality = "American">>
 	<<StartingGirlsWorkaround>>
-	<<set $activeSlave.eyeColor = "blue", $activeSlave.skin = "tan", $activeSlave.hColor = "blonde", $activeSlave.pubicHColor = "blonde", $activeSlave.markings = "none", $activeSlave.face = 95, $activeSlave.muscles = 20, $activeSlave.weight = -20, $activeSlave.height = Math.round(Height.forAge(190, $activeSlave))>>
+	<<set $activeSlave.eyeColor = "blue", $activeSlave.skin = "sun tanned", $activeSlave.override_Skin = 1, $activeSlave.hColor = "blonde", $activeSlave.pubicHColor = "blonde", $activeSlave.markings = "none", $activeSlave.face = 95, $activeSlave.muscles = 20, $activeSlave.weight = -20, $activeSlave.height = Math.round(Height.forAge(190, $activeSlave))>>
 	<<goto "Starting Girls">>
 <</link>>
 //Tall, taut, and tan//
diff --git a/src/uncategorized/RESS.tw b/src/uncategorized/RESS.tw
index 73af31b81cc..bbf7d9bdd86 100644
--- a/src/uncategorized/RESS.tw
+++ b/src/uncategorized/RESS.tw
@@ -426,7 +426,7 @@ clings to you in $his sleep as the warmth of your body begins to move away from
 It's an unusually nice day, with mild sunshine, light breezes, and nothing offensive or dangerous in the atmosphere. In the middle of the afternoon, you take a break from your busy schedule of sex and business and stroll out onto one of your penthouse balconies. It seems <<EventNameLink>> was struck by a similar impulse. <<if $activeSlave.assignment == "rest">>$He's assigned to do little but rest<<else>>This is one of $his rest periods<</if>>, so $he's come out here to lay naked on a towel and enjoy the sun.
 <<if (skinToneLevel($activeSlave.skin) > 20)>>
 	$His $activeSlave.skin doesn't tan much, so $he's just out here to bask in its warmth. $His body shines with lotion from a bottle lying next to $him, but it's just general-purpose stuff.
-<<elseif (skinToneLevel($activeSlave.skin) > 11)>>
+<<elseif ($activeSlave.skin == "sun tanned")>>
 	$His tanned skin shines with lotion from a bottle lying next to $him.
 <<else>>
 	$His skin shines with sunblock lotion from a bottle lying next to $him. It would be foolish of $him to let the sun ruin $his $activeSlave.skin skin.
diff --git a/src/uncategorized/longSlaveDescription.tw b/src/uncategorized/longSlaveDescription.tw
index a8116643892..a6644f01c79 100644
--- a/src/uncategorized/longSlaveDescription.tw
+++ b/src/uncategorized/longSlaveDescription.tw
@@ -2040,7 +2040,7 @@ $He is
 	<<if $activeSlave.markings == "birthmark" && $activeSlave.prestige == 0 && $activeSlave.pornPrestige < 2>>
 		$He has a large, liver-colored birthmark, detracting from $his beauty.
 	<</if>>
-	<<if (skinToneLevel($activeSlave.skin) > skinToneLevel($activeSlave.origSkin))>>
+	<<if ($activeSlave.skin == "sun tanned")>>
 		<<if ($activeSlave.releaseRules != "restrictive" && $activeSlave.releaseRules != "masturbation" && $activeSlave.releaseRules != "chastity")>>
 			<<if ($activeSlave.fetishStrength > 60) && ($activeSlave.fetishKnown == 1)>>
 				$His tan is slightly uneven, since $he enjoys
diff --git a/src/uncategorized/resFailure.tw b/src/uncategorized/resFailure.tw
index e4979439f15..1c4be4ab49a 100644
--- a/src/uncategorized/resFailure.tw
+++ b/src/uncategorized/resFailure.tw
@@ -276,7 +276,7 @@
 		<<set $activeSlave.pubicHColor = "blonde">>
 		<<set $activeSlave.underArmHColor = "blonde">>
 		<<set $activeSlave.race = "white">>
-		<<set $activeSlave.skin = "tan">>
+		<<set $activeSlave.skin = "sun tanned">>
 		<<set $activeSlave.override_H_Color = 1>>
 		<<set $activeSlave.override_Arm_H_Color = 1>>
 		<<set $activeSlave.override_Brow_H_Color = 1>>
diff --git a/src/uncategorized/salon.tw b/src/uncategorized/salon.tw
index 5dc35d1a3fe..a8781fe938c 100644
--- a/src/uncategorized/salon.tw
+++ b/src/uncategorized/salon.tw
@@ -645,13 +645,17 @@ $His skin is $activeSlave.skin.
 		<<set _needsSpacers = 1>>
 	<</if>>
 	<br>
-	<<if (skinToneLevel($activeSlave.skin) > 6)>>
-		$His skin is so light in color that any attempt at natural tanning is more likely to damage $his skin.
-	<<elseif (skinToneLevel($activeSlave.skin) < 20)>>
-		$His skin is so dark in color that any attempt at natural tanning is not likely to appear on $his skin.
+	<<if ($activeSlave.skin == "sun tanned" || $activeSlave.skin == "spray tanned")>>
+		[["Remove " + $his + " tanning"|Salon][$activeSlave.skin = $activeSlave.origSkin,cashX(forceNeg($modCost), "slaveMod", $activeSlave)]]
 	<<else>>
 		<<if ($activeSlave.skin != "sun tanned")>>
-			[["Sun tan " + $his + " skin"|Salon][$activeSlave.skin = "sun tanned",cashX(forceNeg($modCost), "slaveMod", $activeSlave)]]
+			<<if (skinToneLevel($activeSlave.skin) < 6)>>
+				$His skin is so light in color that any attempt at natural tanning is more likely to damage $his skin.
+			<<elseif (skinToneLevel($activeSlave.skin) > 20)>>
+				$His skin is so dark in color that any attempt at natural tanning is not likely to appear on $his skin.
+			<<else>>
+				[["Sun tan " + $his + " skin"|Salon][$activeSlave.skin = "sun tanned",cashX(forceNeg($modCost), "slaveMod", $activeSlave)]]
+			<</if>>
 		<</if>>
 	<</if>>
 	<<if ($activeSlave.skin != "spray tanned")>>
diff --git a/src/utility/descriptionWidgetsFlesh.tw b/src/utility/descriptionWidgetsFlesh.tw
index 6c6690cc624..cedea0b0298 100644
--- a/src/utility/descriptionWidgetsFlesh.tw
+++ b/src/utility/descriptionWidgetsFlesh.tw
@@ -17634,7 +17634,8 @@ $He has
 <<widget "skinDescription">>
 
 <<if $activeSlave.fuckdoll > 0>>
-	The small areas of visible skin are <<print $activeSlave.skin>><<if $activeSlave.markings == "freckles">> and lightly freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor != "red")>>, an attractive combination<</if>><<elseif $activeSlave.markings == "heavily freckled">> and heavily freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor != "red")>>, an attractive combination<</if>><</if>>.
+	The small areas of visible skin are <<print $activeSlave.skin>><<if $activeSlave.markings == "freckles">> and lightly freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor == "red")>>, an attractive combination<</if>><<elseif $activeSlave.markings == "heavily freckled">> and heavily freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor == "red")>>, an attractive combination<</if>><</if>>.
+	<<if ($activeSlave.skin == "sun tanned" || $activeSlave.skin == "spray tanned")>>$His skin has been tanned <<if $activeSlave.skin == "sun tanned">>to a natural, healthy-looking tone<<elseif $activeSlave.skin == "spray tanned">>with obvious, garish-looking makeup<</if>>.<</if>>
 <<elseif ($seeNationality == 1)>>
 	<<if $activeSlave.nationality == 0>>
 		Ethnically, $he's
@@ -17649,7 +17650,8 @@ $He has
 	<<else>>
 		$He's originally @@.tan;<<print $activeSlave.nationality>>;@@ ethnically, $he's
 	<</if>>
-	@@.tan;<<print $activeSlave.race>>,@@ and $his skin is <<print $activeSlave.skin>><<if $activeSlave.markings == "freckles">> and lightly freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor != "red")>>, an attractive combination<</if>><<elseif $activeSlave.markings == "heavily freckled">> and heavily freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor != "red")>>, an attractive combination<</if>><</if>>.
+	@@.tan;<<print $activeSlave.race>>,@@ and $his skin is <<print $activeSlave.skin>><<if $activeSlave.markings == "freckles">> and lightly freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor == "red")>>, an attractive combination<</if>><<elseif $activeSlave.markings == "heavily freckled">> and heavily freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor == "red")>>, an attractive combination<</if>><</if>>.
+	<<if ($activeSlave.skin == "sun tanned" || $activeSlave.skin == "spray tanned")>>$His skin has been tanned <<if $activeSlave.skin == "sun tanned">>to a natural, healthy-looking tone<<elseif $activeSlave.skin == "spray tanned">>with obvious, garish-looking makeup<</if>>.<</if>>
 	<<if $activeSlave.race != $activeSlave.origRace && $saleDescription != 1>>
 		$He has received plastic surgery to appear <<print $activeSlave.race>>; $he is originally <<print $activeSlave.origRace>>.
 	<<elseif $activeSlave.race != $activeSlave.origRace && $saleDescription == 1>>
@@ -17664,7 +17666,8 @@ $He has
 		<</if>>
 	<</if>>
 <<elseif ($seeRace == 1)>>
-	Ethnically, $he's @@.tan;<<print $activeSlave.race>>,@@ and $his skin is <<print $activeSlave.skin>><<if $activeSlave.markings == "freckles">> and lightly freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor != "red")>>, an attractive combination<</if>><<elseif $activeSlave.markings == "heavily freckled">> and heavily freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor != "red")>>, an attractive combination<</if>><</if>>.
+	Ethnically, $he's @@.tan;<<print $activeSlave.race>>,@@ and $his skin is <<print $activeSlave.skin>><<if $activeSlave.markings == "freckles">> and lightly freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor == "red")>>, an attractive combination<</if>><<elseif $activeSlave.markings == "heavily freckled">> and heavily freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor == "red")>>, an attractive combination<</if>><</if>>.
+	<<if ($activeSlave.skin == "sun tanned" || $activeSlave.skin == "spray tanned")>>$His skin has been tanned <<if $activeSlave.skin == "sun tanned">>to a natural, healthy-looking tone<<elseif $activeSlave.skin == "spray tanned">>with obvious, garish-looking makeup<</if>>.<</if>>
 	<<if $activeSlave.race != $activeSlave.origRace && $saleDescription != 1>>
 		$He has received plastic surgery to appear <<print $activeSlave.race>>; $he is originally <<print $activeSlave.origRace>>.
 	<<elseif $activeSlave.race != $activeSlave.origRace && $saleDescription == 1>>
@@ -17679,7 +17682,8 @@ $He has
 		<</if>>
 	<</if>>
 <<else>>
-	$His skin is <<print $activeSlave.skin>><<if $activeSlave.markings == "freckles">> and lightly freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor != "red")>>, an attractive combination<</if>><<elseif $activeSlave.markings == "heavily freckled">> and heavily freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor != "red")>>, an attractive combination<</if>><</if>>.
+	$His skin is <<print $activeSlave.skin>><<if $activeSlave.markings == "freckles">> and lightly freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor == "red")>>, an attractive combination<</if>><<elseif $activeSlave.markings == "heavily freckled">> and heavily freckled<<if (skinToneLevel($activeSlave.skin) > 5) && (skinToneLevel($activeSlave.skin) < 10) && ($activeSlave.hColor == "red")>>, an attractive combination<</if>><</if>>.
+	<<if ($activeSlave.skin == "sun tanned" || $activeSlave.skin == "spray tanned")>>$His skin has been tanned <<if $activeSlave.skin == "sun tanned">>to a natural, healthy-looking tone<<elseif $activeSlave.skin == "spray tanned">>with obvious, garish-looking makeup<</if>>.<</if>>
 <</if>>
 
 <</widget>>
diff --git a/src/utility/slaveCreationWidgets.tw b/src/utility/slaveCreationWidgets.tw
index 901a9ad8be4..05602f58819 100644
--- a/src/utility/slaveCreationWidgets.tw
+++ b/src/utility/slaveCreationWidgets.tw
@@ -2065,7 +2065,7 @@
 	<<set $activeSlave.underArmHColor = "blonde">>
 	<<set $activeSlave.eyebrowHColor = "blonde">>
 	<<set $activeSlave.race = "white">>
-	<<set $activeSlave.skin = "tan">>
+	<<set $activeSlave.skin = "sun tanned">>
 	<<set $activeSlave.override_H_Color = 1>>
 	<<set $activeSlave.override_Arm_H_Color = 1>>
 	<<set $activeSlave.override_Pubic_H_Color = 1>>
-- 
GitLab