From 6403002ffc29f7d55bcfcdda29a78c332411899d Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Tue, 26 Mar 2019 01:16:07 -0400
Subject: [PATCH] minor injury response to JS

---
 src/endWeek/minorInjuryResponse.js       | 45 ++++++++++++++++++++++++
 src/uncategorized/minorInjuryResponse.tw | 39 --------------------
 src/uncategorized/saServeThePublic.tw    |  8 ++---
 src/uncategorized/saWhore.tw             |  8 ++---
 4 files changed, 53 insertions(+), 47 deletions(-)
 create mode 100644 src/endWeek/minorInjuryResponse.js
 delete mode 100644 src/uncategorized/minorInjuryResponse.tw

diff --git a/src/endWeek/minorInjuryResponse.js b/src/endWeek/minorInjuryResponse.js
new file mode 100644
index 00000000000..0a3c400e7d9
--- /dev/null
+++ b/src/endWeek/minorInjuryResponse.js
@@ -0,0 +1,45 @@
+/* eslint-disable no-undef */
+/* eslint-disable no-unused-vars */
+window.minorInjuryResponse = /** @param {App.Entity.SlaveState} slave */ function minorInjuryResponse(slave) {
+	const arcology = State.variables.arcologies[0];
+	const arcologyUpgrade = State.variables.arcologyUpgrade;
+	let pronouns = getPronouns(slave);
+	const he = pronouns.pronoun;
+	const himself = pronouns.objectReflexive;
+	const He = capFirstChar(he);
+	let r = "";
+	
+	if (arcology.FSDegradationist > 20) {
+		r += ` ${He} carries on, knowing that in your degradationist arcology, this is accepted behavior.`;
+	} else if (arcology.FSPaternalist > 20) {
+		if (arcologyUpgrade.drones === 1 && jsRandom(1, 100) > 50) {
+			r += ` The security drones successfully detain him and oblige him to pay significant <span class="yellowgreen">compensation,</span> since abusing slaves is discouraged here.`;
+			cashX(50, "slaveUpkeep", slave);
+		} else if (arcologyUpgrade.grid === 1 && jsRandom(1, 100) > 50) {
+			r += ` The computer systems successfully detain him and require him to pay significant <span class="yellowgreen">compensation,</span> since abusing slaves is discouraged here.`;
+			cashX(50, "slaveUpkeep", slave);
+		} else if (slave.whoreSkill > jsRandom(1, 100)) {
+			r += ` ${slave.slaveName} is used to this sort of thing, and convinces him to pay significant <span class="yellowgreen">compensation,</span> since abusing slaves is discouraged here.`;
+			cashX(50, "slaveUpkeep", slave);
+		} else if (slave.combatSkill > 0) {
+			r += ` ${slave.slaveName} can take care of ${himself}, and ${he} successfully forces him to pay significant <span class="yellowgreen">compensation,</span> since abusing slaves is discouraged here.`;
+			cashX(50, "slaveUpkeep", slave);
+		}
+	} else {
+		if (arcologyUpgrade.drones === 1 && jsRandom(1, 100) > 50) {
+			r += ` The security drones successfully detain him and oblige him to pay minor <span class="yellowgreen">compensation.</span>`;
+			cashX(10, "slaveUpkeep", slave);
+		} else if (arcologyUpgrade.grid === 1 && jsRandom(1, 100) > 50) {
+			r += ` The computer systems successfully detain him and require him to pay minor <span class="yellowgreen">compensation.</span>`;
+			cashX(10, "slaveUpkeep", slave);
+		} else if (slave.whoreSkill > jsRandom(1, 100)) {
+			r += ` ${slave.slaveName} is used to this sort of thing, and convinces him to pay minor <span class="yellowgreen">compensation.</span>`;
+			cashX(10, "slaveUpkeep", slave);
+		} else if (slave.combatSkill > 0) {
+			r += ` ${slave.slaveName} can take care of ${himself}, and $he successfully forces him to pay minor <span class="yellowgreen">compensation.</span>`;
+			cashX(10, "slaveUpkeep", slave);
+		}
+	}
+	
+	return r;
+}
diff --git a/src/uncategorized/minorInjuryResponse.tw b/src/uncategorized/minorInjuryResponse.tw
deleted file mode 100644
index 3fa3911dc5b..00000000000
--- a/src/uncategorized/minorInjuryResponse.tw
+++ /dev/null
@@ -1,39 +0,0 @@
-:: minor injury response [nobr]
-
-<<if $arcologies[0].FSDegradationist > 20>>
-
-$He carries on, knowing that in your degradationist arcology, this is accepted behavior.
-
-<<elseif $arcologies[0].FSPaternalist > 20>>
-
-<<if ($arcologyUpgrade.drones == 1) && (random(1,100) > 50)>>
-	The security drones successfully detain him and oblige him to pay significant @@.yellowgreen;compensation,@@ since abusing slaves is discouraged here.
-	<<run cashX(50, "slaveUpkeep", $slaves[$i])>>
-<<elseif ($arcologyUpgrade.grid == 1) && (random(1,100) > 50)>>
-	The computer systems successfully detain him and require him to pay significant @@.yellowgreen;compensation,@@ since abusing slaves is discouraged here.
-	<<run cashX(50, "slaveUpkeep", $slaves[$i])>>
-<<elseif ($slaves[$i].whoreSkill > random(1,100))>>
-	$slaves[$i].slaveName is used to this sort of thing, and convinces him to pay significant @@.yellowgreen;compensation,@@ since abusing slaves is discouraged here.
-	<<run cashX(50, "slaveUpkeep", $slaves[$i])>>
-<<elseif ($slaves[$i].combatSkill > 0)>>
-	$slaves[$i].slaveName can take care of $himself, and $he successfully forces him to pay significant @@.yellowgreen;compensation,@@ since abusing slaves is discouraged here.
-	<<run cashX(50, "slaveUpkeep", $slaves[$i])>>
-<</if>>
-
-<<else>>
-
-<<if ($arcologyUpgrade.drones == 1) && (random(1,100) > 50)>>
-	The security drones successfully detain him and oblige him to pay minor @@.yellowgreen;compensation.@@
-	<<run cashX(10, "slaveUpkeep", $slaves[$i])>>
-<<elseif ($arcologyUpgrade.grid == 1) && (random(1,100) > 50)>>
-	The computer systems successfully detain him and require him to pay minor @@.yellowgreen;compensation.@@
-	<<run cashX(10, "slaveUpkeep", $slaves[$i])>>
-<<elseif ($slaves[$i].whoreSkill > random(1,100))>>
-	$slaves[$i].slaveName is used to this sort of thing, and convinces him to pay minor @@.yellowgreen;compensation.@@
-	<<run cashX(10, "slaveUpkeep", $slaves[$i])>>
-<<elseif ($slaves[$i].combatSkill > 0)>>
-	$slaves[$i].slaveName can take care of $himself, and $he successfully forces him to pay minor @@.yellowgreen;compensation.@@
-	<<run cashX(10, "slaveUpkeep", $slaves[$i])>>
-<</if>>
-
-<</if>>
diff --git a/src/uncategorized/saServeThePublic.tw b/src/uncategorized/saServeThePublic.tw
index 2f63bfb005e..7735fa9c457 100644
--- a/src/uncategorized/saServeThePublic.tw
+++ b/src/uncategorized/saServeThePublic.tw
@@ -315,19 +315,19 @@ $His appearance attracted $beauty members of the public (<<print Math.trunc($bea
 	<<if (_injuryChance > 80)>>
 		<<set $slaves[$i].minorInjury = "sore ass">>
 		Rough anal with a careless citizen left $him with a @@.red;$slaves[$i].minorInjury.@@
-		<<include "minor injury response">>
+		<<= minorInjuryResponse($slaves[$i])>>
 	<<elseif (_injuryChance > 60)>>
 		<<set $slaves[$i].minorInjury = "black eye">>
 		A violent citizen left $him with a @@.red;$slaves[$i].minorInjury.@@
-		<<include "minor injury response">>
+		<<= minorInjuryResponse($slaves[$i])>>
 	<<elseif (_injuryChance > 40)>>
 		<<set $slaves[$i].minorInjury = "split lip">>
 		An abusive citizen left $him with a @@.red;$slaves[$i].minorInjury.@@
-		<<include "minor injury response">>
+		<<= minorInjuryResponse($slaves[$i])>>
 	<<elseif (_injuryChance > 20)>>
 		<<set $slaves[$i].minorInjury = "bad bruise">>
 		A rough citizen left $him with a @@.red;$slaves[$i].minorInjury.@@
-		<<include "minor injury response">>
+		<<= minorInjuryResponse($slaves[$i])>>
 	<<else>>
 		<<set $slaves[$i].minorInjury = "sore muscle">>
 		The hard labor of constant sex left $him with @@.red;$slaves[$i].minorInjury.@@
diff --git a/src/uncategorized/saWhore.tw b/src/uncategorized/saWhore.tw
index 2f3e8f8cb4e..888112f4dc6 100644
--- a/src/uncategorized/saWhore.tw
+++ b/src/uncategorized/saWhore.tw
@@ -300,19 +300,19 @@ $His appearance attracted $beauty customers (<<print Math.trunc($beauty/7)>> a d
 	<<if (_injuryChance > 80)>>
 		<<set $slaves[$i].minorInjury = "sore ass">>
 		Rough anal with a careless customer left $him with a @@.red;$slaves[$i].minorInjury.@@
-		<<include "minor injury response">>
+		<<= minorInjuryResponse($slaves[$i])>>
 	<<elseif (_injuryChance > 60)>>
 		<<set $slaves[$i].minorInjury = "black eye">>
 		A violent customer left $him with a @@.red;$slaves[$i].minorInjury.@@
-		<<include "minor injury response">>
+		<<= minorInjuryResponse($slaves[$i])>>
 	<<elseif (_injuryChance > 40)>>
 		<<set $slaves[$i].minorInjury = "split lip">>
 		An abusive customer left $him with a @@.red;$slaves[$i].minorInjury.@@
-		<<include "minor injury response">>
+		<<= minorInjuryResponse($slaves[$i])>>
 	<<elseif (_injuryChance > 20)>>
 		<<set $slaves[$i].minorInjury = "bad bruise">>
 		A rough customer left $him with a @@.red;$slaves[$i].minorInjury.@@
-		<<include "minor injury response">>
+		<<= minorInjuryResponse($slaves[$i])>>
 	<<else>>
 		<<set $slaves[$i].minorInjury = "sore muscle">>
 		The hard labor of constant sex left $him with a @@.red;$slaves[$i].minorInjury.@@
-- 
GitLab