From c3a3fb85c4fb3c93d10e0d0d6b8067c3c2c4d46b Mon Sep 17 00:00:00 2001
From: kopareigns <kopareigns@gmail.com>
Date: Mon, 9 Apr 2018 20:36:05 -0400
Subject: [PATCH] Spring Cleaning

---
 src/uncategorized/BackwardsCompatibility.tw |  7 ++++---
 src/uncategorized/newSlaveIntro.tw          | 16 +++++++--------
 src/uncategorized/officeDescription.tw      | 22 ++++++---------------
 3 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw
index 1867dda4c01..83efb9eb52a 100644
--- a/src/uncategorized/BackwardsCompatibility.tw
+++ b/src/uncategorized/BackwardsCompatibility.tw
@@ -130,13 +130,14 @@
 <<if ndef $peacekeepers>>
 	<<set $peacekeepers = 0>>
 <</if>>
-
 <<if def $modestClothes>>
 	<<unset $modestClothes>>
 <</if>>
-
 <<if ndef $completedOrgans>>
-<<set $completedOrgans = []>>
+	<<set $completedOrgans = []>>
+<</if>>
+<<if def $eventSlaves>>
+	<<unset $eventSlaves>>
 <</if>>
 
 /* pregmod stuff */
diff --git a/src/uncategorized/newSlaveIntro.tw b/src/uncategorized/newSlaveIntro.tw
index bfe6c4df194..bc67af4ce93 100644
--- a/src/uncategorized/newSlaveIntro.tw
+++ b/src/uncategorized/newSlaveIntro.tw
@@ -10,13 +10,11 @@
 <<SlaveTitle $activeSlave>>
 
 <<if $specialSlave == 1>>
-	<<for $i = 0; $i < $heroSlaves.length; $i++>>
-		<<if $activeSlave.ID == $heroSlaves[$i].ID>>
-			<<set $heroSlaves.deleteAt($i)>>
-			<<set $specialSlave = 0>>
-			<<break>>
-		<</if>>
-	<</for>>
+	<<set $i = $heroSlaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
+	<<if $i != -1>>
+		<<set $heroSlaves.deleteAt($i)>>
+	<</if>>
+	<<set $specialSlave = 0>>
 <</if>>
 
 <br>
@@ -503,7 +501,7 @@ The legalities completed, ''__@@.pink;<<SlaveFullName $activeSlave>>@@__'' <<if
 	<</if>>
 <<elseif $arcologies[0].FSChineseRevivalist >= 50>>
 	<<if $activeSlave.intelligenceImplant == 1>>
-		Though she knows it's not a truly authentic ancient Chinese restoration, her educated mind grasps the potential benefits of ancient Confucian philosophy for slaves, and she @@.mediumaquamarine;hopes@@ your arcology at least maintains some pretence of order and conservatism.
+		Though she knows it's not a truly authentic ancient Chinese restoration, her educated mind grasps the potential benefits of ancient Confucian philosophy for slaves, and she @@.mediumaquamarine;hopes@@ your arcology at least maintains some pretense of order and conservatism.
 		<<set $activeSlave.trust += 2>>
 	<</if>>
 <</if>>
@@ -1077,7 +1075,7 @@ The legalities completed, ''__@@.pink;<<SlaveFullName $activeSlave>>@@__'' <<if
 				She will never bear children, and will @@.mediumorchid;remember her status@@ with every fucking she receives. Your absolute power over her body is rightfully @@.gold;terrifying.@@
 				<<set $activeSlave.trust -= 20, $activeSlave.devotion -= 50>>
 			<</if>>
-			Society @@.green;approves@@ of your promptly rendering her sterile; this advances the idea that all only the elite should breed.
+			Society @@.green;approves@@ of your promptly rendering her sterile; this advances the idea that only the elite should breed.
 			<<FSChange "Eugenics" 1>>
 			<<if $activeSlave.pregKnown == 1>>
 				Since you snuffed out an unworthy life in the process, the sterilization has an even @@.green;bigger impact.@@
diff --git a/src/uncategorized/officeDescription.tw b/src/uncategorized/officeDescription.tw
index 51cd28d6af2..bd8ffa9b7e7 100644
--- a/src/uncategorized/officeDescription.tw
+++ b/src/uncategorized/officeDescription.tw
@@ -6,14 +6,9 @@
 
 <<if $clubAdsSpending >= 5000>>
 	A corner of your desk is piled with sample merchandise from the campaign promoting your club.
-	<<set $eventSlaves = []>>
-	<<for _odi = 0; _odi < $slaves.length; _odi++>>
-	<<if ($slaves[_odi].assignment == "serve in the club") && canWalk($slaves[_odi])>>
-		<<set $eventSlaves.push($slaves[_odi])>>
-	<</if>>
-	<</for>>
-	<<if $eventSlaves.length > 0>>
-	<<set $activeSlave = $eventSlaves.random()>>
+	<<set _eventSlaves = $slaves.filter(function(s) { return s.assignment == "serve in the club" && canWalk(s); })>>
+	<<if _eventSlaves.length > 0>>
+	<<set $activeSlave = _eventSlaves.random()>>
 	<<if random(1,2) == 1>>
 		This includes a sex toy based on $activeSlave.slaveName's
 		<<if (random(1,3) == 1) && ($activeSlave.vaginalSkill >= 100)>>
@@ -41,14 +36,9 @@
 	<<else>>
 	A corner of your desk is piled with sample merchandise from the campaign promoting $brothelName.
 	<</if>>
-	<<set $eventSlaves = []>>
-	<<for _odi = 0; _odi < $slaves.length; _odi++>>
-	<<if ($slaves[_odi].assignment == "work in the brothel") && canWalk($slaves[_odi])>>
-		<<set $eventSlaves.push($slaves[_odi])>>
-	<</if>>
-	<</for>>
-	<<if $eventSlaves.length > 0>>
-	<<set $activeSlave = $eventSlaves.random()>>
+	<<set _eventSlaves = $slaves.filter(function(s) { return s.assignment == "work in the brothel" && canWalk(s); })>>
+	<<if _eventSlaves.length > 0>>
+	<<set $activeSlave = _eventSlaves.random()>>
 	<<if random(1,2) == 1>>
 		This includes a sex toy based on $activeSlave.slaveName's
 		<<if (random(1,3) == 1) && ($activeSlave.vaginalSkill >= 100)>>
-- 
GitLab