From c6d24678b3217ffd493bad00849727f86676ded6 Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Sun, 30 Apr 2017 01:13:53 -0400
Subject: [PATCH] fcanon's fixes and an attempt at updating sanityCheck.

---
 devTools/check.py                             | 42 +++++++++++----
 sanityCheck                                   |  4 ++
 src/cheats/mod_EditSlaveCheat.tw              |  4 +-
 .../personalAssistantAppearance.tw            | 26 ++++++----
 src/uncategorized/saLongTermEffects.tw        |  2 +-
 src/uncategorized/saServeThePublic.tw         | 28 +++++-----
 src/uncategorized/slaveInteract.tw            | 13 ++---
 src/uncategorized/slaveSummary.tw             |  8 +--
 src/uncategorized/spaReport.tw                | 13 ++---
 src/utility/raWidgets.tw                      | 52 +++++++------------
 10 files changed, 102 insertions(+), 90 deletions(-)

diff --git a/devTools/check.py b/devTools/check.py
index dc3491656da..8a0a99e2379 100644
--- a/devTools/check.py
+++ b/devTools/check.py
@@ -4,41 +4,65 @@ import re
 import sys
 
 def myprint(*args):
-    print(fileinput.filename() + ":",*args)
+    print(filename + ":",*args)
+
+def yield_line_and_islastline(f):
+    global filename
+    global linenumber
+    try:
+        prevline = next(f)
+        filename = fileinput.filename()
+        linenumber = fileinput.filelineno()
+    except StopIteration:
+        return
+    for line in f:
+        yield (prevline, f.isfirstline())
+        filename = fileinput.filename()
+        linenumber = fileinput.filelineno()
+        prevline = line
+    yield prevline, True
 
 pattern = re.compile(r'(<<(\/?) *(if|for|else|switch|case)[^<>]*)')
 
-linenumber = 0
+
 tagfound = []
-for line in fileinput.input():
-    linenumber += 1
+for line, isLastLine in yield_line_and_islastline(fileinput.input()):
     for (whole,end,tag) in re.findall(pattern,line):
         if tag == "else" or tag == 'case':
             if len(tagfound) == 0:
                 myprint("Found", tag, "but with no opening tag:")
                 myprint("  ", linenumber,":", whole)
-                exit(1)
+                fileinput.nextfile()
             lasttag = tagfound[-1]
             if (tag == "else" and lasttag["tag"] != "if") or (tag == "case" and lasttag["tag"] != "switch"):
                 myprint("Mismatched else: Opening tag was:")
                 myprint("  ",lasttag["linenumber"],":", lasttag["whole"])
                 myprint("But this tag was:")
                 myprint("  ",linenumber,":", whole)
-                exit(1)
+                fileinput.nextfile()
+                break
         elif end != '/':
             tagfound.append({"whole": whole, "linenumber":linenumber,"tag":tag})
         else:
             if len(tagfound) == 0:
                 myprint("Found closing tag but with no opening tag:")
                 myprint("  ", linenumber,":", whole)
-                exit(1)
-
+                fileinput.nextfile()
+                break
             lasttag = tagfound.pop()
             if lasttag["tag"] != tag:
                 myprint("Mismatched tag: Opening tag was:")
                 myprint("  ",lasttag["linenumber"],":", lasttag["whole"])
                 myprint("Closing tag was:")
                 myprint("  ",linenumber,":", whole)
-                exit(1)
+                fileinput.nextfile()
+                break
+
 
+    if isLastLine:
+        if len(tagfound) != 0:
+            myprint("End of file found but", len(tagfound), ("tag hasn't" if len(tagfound)==1 else "tags haven't"), "been closed:")
+        for tag in tagfound:
+            myprint("  ", tag["linenumber"],":", tag["whole"])
+        tagfound = []
 
diff --git a/sanityCheck b/sanityCheck
index 2ef7f129f4e..781124fa11d 100644
--- a/sanityCheck
+++ b/sanityCheck
@@ -35,6 +35,10 @@ git grep "\$slave\[" -- 'src/*'
 git grep "\$slaves\[\$i\]\. " -- 'src/*'
 # Check using refreshmentType instead of refreshment
 git grep "\$PC.refreshmentType[^ =]" -- 'src/*'
+# Check, e.g., <<//if>>
+git grep "<</[a-zA-Z]*[^a-zA-Z<>]\+[a-zA-Z]*>>" -- 'src/*'
+# Check, e.g., =to
+git grep "=to" -- 'src/*'
 
 # Check that all the tags are properly opened and closed
 git ls-files "src/*.tw" | xargs -d '\n' ./devTools/check.py
diff --git a/src/cheats/mod_EditSlaveCheat.tw b/src/cheats/mod_EditSlaveCheat.tw
index 5cc1321cd71..184264bb5b9 100644
--- a/src/cheats/mod_EditSlaveCheat.tw
+++ b/src/cheats/mod_EditSlaveCheat.tw
@@ -1133,8 +1133,8 @@ Paraphilias:
 <<radiobutton "$activeSlave.sexualQuirk" "unflinching">> Unflinching
 <<radiobutton "$activeSlave.sexualQuirk" "size queen">> Size Queen
 <<if $activeSlave.sexualQuirk != "none">>
-	<<if ($activeSlave.sexualFlaw != "cum addict") && ($activeSlave.sexualFlaw != "anal addict") && ($activeSlave.sexualFlaw != "attention whore") && ($activeSlave.sexualFlaw != "breast growth") && ($activeSlave.sexualFlaw != "abusive") && ($activeSlave.sexualFlaw != "malicious") &&  ($activeSlave.sexualFlaw != "self hating") && ($activeSlave.sexualFlaw != "neglectful") &&  ($activeSlave.sexualFlaw != "breeder")>>
-		<<set $activeSlave.sexualFlaw = "none">>	
+	<<if ($activeSlave.sexualFlaw != "cum addict") && ($activeSlave.sexualFlaw != "anal addict") && ($activeSlave.sexualFlaw != "attention whore") && ($activeSlave.sexualFlaw != "breast growth") && ($activeSlave.sexualFlaw != "abusive") && ($activeSlave.sexualFlaw != "malicious") && ($activeSlave.sexualFlaw != "self hating") && ($activeSlave.sexualFlaw != "neglectful") && ($activeSlave.sexualFlaw != "breeder")>>
+		<<set $activeSlave.sexualFlaw = "none">>
 	<</if>>
 <</if>>
 
diff --git a/src/uncategorized/personalAssistantAppearance.tw b/src/uncategorized/personalAssistantAppearance.tw
index 25475d753da..87100cefcfc 100644
--- a/src/uncategorized/personalAssistantAppearance.tw
+++ b/src/uncategorized/personalAssistantAppearance.tw
@@ -1152,27 +1152,31 @@ She's a cute little <<if $arcologies[0].FSSupremacist != "unset">>$arcologies[0]
 	<<case "egyptian revivalist">>
 		She's managed to untangle herself from the wrappings, though she has choosen to leave several still wrapped around her body.
 	<<case "edo revivalist">>
-		She has tightly bound herself in shibari ropes, though they don't achieve much given she can still fly freely.
+		She's managed to correct the spell, somwhat, though she now resebles something that belongs in a hentai.
 	<<case "arabian revivalist">>
-		She has donned the skimpiest, sluttiest outfit she could think of. She's just begging to get stoned.
+		She's managed to correct the spell, and even succeed at it. She has altered her appearance to resemble a gorgeous djinn. She is seductivly performing a belly dance for you.
 	<<case "chinese revivalist">>
-		She has added a number of peircings to her body to allow her to be suspended by hooks rather than flying.
+		She has chosen to embrace the outcome of her spell, even pushing her luck a little more, leaving her wearing a long and very fashionable qipao.
 	<<case "chattel religionist">>
-		She has chosen to go fully naked, exposing the symbols of your religion pierced through het nipples and clit.
+		She has chosen to embrace the outcome of her spell, proudly displaying the various holy symbols hanging from around her neck and dangling from her nipples, navel and clit.
 	<<case "physical idealist">>
-		She has adjusted her appearance to be rather muscular. Not only can she crack a whip harder than ever, but when she flexes, she nearly pops the belt around her chest.
+		She managed to regain freedom of movement, but has chosen to leave her torn robes unfixed to further highlight her ridiculous muscles.
 	<<case "repopulation focus">>
-		She's added a pair of tight belts across her stomach recently. The taut material painfully digs into her growing pregnancy.
+		<<if $seeHyperPreg == 1>>
+			She's managed to cast a levitation spell to allow her to move and a spell to prevent her from bursting, but she can do nothing about the dozens of active children crowding her womb. She meekly floats along with it, gently rubbing its squirming mass through her torn robe.
+		<<else>>
+			She's managed to cast a spell to lighten her belly, but she can do nothing about the roudy octuplets crowding her womb. She meekly pats her exposed belly, feebly trying to calm her bablies, as she looks up ways to mend her torn dress.
+		<</if>>
 	<<case "eugenics">>
-		She has an iron chastity belt under her loincloth and two large bulges in her middle. You don't have to guess she has a pair of enormous dildos locked inside her.
+		She still hasn't managed to undo the spell; it's pretty obvious given how desperatly horny she is.
 	<<case "gender radicalist">>
-		She's recently begun rendering herself more androgynous. Something can be seen commonly tenting her loincloth; when ever if shifts to the side, you catch sight of a thumb sized and heavily pierced clitoris.
+		She has chosen to embrace the outcome of her spell; she either sports bulge or a tent in the front of her dress and frquently can be seen reading books on male anatomy.
 	<<case "gender fundamentalist">>
-		She's recently increased the size of her breasts and width of her hips. The belt around her chest tightly binds her new bust and causes its flesh to bulge and jiggle delightfully.
+		She still hasn't managed to undo the spell; her belly has become so swollen with ovum she looks ready to birth triplets. She can barely concentrate; her mind focused entirely on dicks cumming in her wet pussy, but she can't risk it, knowing full well she'd become so pregnant she'd likely burst. Her ample breasts and child bearing hips only make it harder to keep away from cocks.
 	<<case "asset expansionist">>
-		She's had to let out her chest belt to accommodate her new excessive bust, but only a little; the belt creates a deep canyon across her chest with plenty of flesh bulging above and below the straining leather.
+		She's managed to partially undo the spell; her breasts are merely as big as she is now. One simple, correctly performed, levitation spell later and she is fully capable of functioning with her oversized tits.
 	<<case "transformation fetishist">>
-		She's had to let out her chest belt to accommodate her new excessive bust, but only a little; the belt creates a deep canyon across her fake chest and threatens to painfully pop the underlying implants.
+		While she has managed to regain her flexibility, she still greatly resembles an overinflated blow-up doll. Her lips are stuck in an O shape, her breasts are the size of beachballs, her ass and thighs larger than any girl's you've seen, and above all else is her huge medecine ball sized belly; fortunatly they don't weigh nearly as much as the should, part of the benefits of being an inflatable sex-doll.
 	<<case "pastoralist">>
 		She's exchanged her chest belt for a pair of rings with leather straps. She wears them so tightly every motion she makes forces a gush of milk from her painfully swollen breasts.
 	<<case "maturity preferentialist">>
diff --git a/src/uncategorized/saLongTermEffects.tw b/src/uncategorized/saLongTermEffects.tw
index ed78a638f51..b1717922ee6 100644
--- a/src/uncategorized/saLongTermEffects.tw
+++ b/src/uncategorized/saLongTermEffects.tw
@@ -4824,7 +4824,7 @@
 
 <<if $slaves[$i].vagina == -1>>
 <<if $slaves[$i].dick == 0>>
-	<<set _frustration == 0>>
+	<<set _frustration = 0>>
 	<<if $slaves[$i].energy > 20>>
 		$pronounCap
 		<<if canDoAnal($slaves[$i])>>
diff --git a/src/uncategorized/saServeThePublic.tw b/src/uncategorized/saServeThePublic.tw
index d186962a760..41a3250fe7c 100644
--- a/src/uncategorized/saServeThePublic.tw
+++ b/src/uncategorized/saServeThePublic.tw
@@ -857,37 +857,37 @@ Her appearance attracted $beauty members of the public (<<print Math.trunc($beau
 <<switch $slaves[$i].behavioralFlaw>>
 <<case "arrogant">>
 	She receives less gratitude because she treats clients like they are beneath her dignity.
-<<case "bitchy")>>
+<<case "bitchy">>
 	She receives less gratitude because she makes cutting remarks to clients.
-<<case "odd")>>
+<<case "odd">>
 	She receives less gratitude because clients are annoyed by her odd behavior.
-<<case "hates men")>>
+<<case "hates men">>
 	She receives less gratitude because she can't conceal her distaste for the company of men.
-<<case "hates women")>>
+<<case "hates women">>
 	She receives less gratitude because she can't conceal her distaste for the company of women.
-<<case "devout")>>
+<<case "devout">>
 	She receives less gratitude because people are annoyed by her habit of praying for forgiveness during sex.
-<<case "liberated")>>
+<<case "liberated">>
 	She receives less gratitude because people are annoyed by her obvious belief that being forced to serve them is wrong.
 <</switch>>
 <<switch $slaves[$i].sexualFlaw>>
 <<case "hates oral">>
 	She receives less gratitude because she tries to avoid sucking cock.
-<<case "hates anal")>>
+<<case "hates anal">>
 	She receives less gratitude because she tries to avoid taking it up the ass.
-<<case "hates penetration")>>
+<<case "hates penetration">>
 	She receives less gratitude because she tries to avoid getting fucked.
-<<case "repressed")>>
+<<case "repressed">>
 	She receives less gratitude because citizens who don't feel like forcing her sometimes have to cajole her past her repressed sexuality.
-<<case "idealistic")>>
+<<case "idealistic">>
 	She receives less gratitude because citizens who don't feel like forcing her sometimes have to convince her to have sex with them.
-<<case "apathetic")>>
+<<case "apathetic">>
 	She receives less gratitude because she often just lies there taking dick.
-<<case "crude")>>
+<<case "crude">>
 	She receives less gratitude because she isn't exactly the most elegant sexual partner.
-<<case "judgemental")>>
+<<case "judgemental">>
 	She receives less gratitude because she openly disdains unattractive citizens.
-<<case "shamefast")>>
+<<case "shamefast">>
 	She receives less gratitude because she sometimes hesitates to take her clothes off and get to work.
 <<case "cum addict">>
 	Her abject begging for cum annoys citizens who aren't looking for oral, but this is more than outweighed by how much it delights those who are.
diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw
index 1c002b6f04c..b58e05c4b47 100644
--- a/src/uncategorized/slaveInteract.tw
+++ b/src/uncategorized/slaveInteract.tw
@@ -71,7 +71,7 @@
 	<<if canDoAnal($activeSlave)>>
 	| <<link "Fuck her ass">><<replace "#miniscene">><<include "FAnus">><br>&nbsp;&nbsp;&nbsp;&nbsp;<</replace>><</link>>
 	<<else>>
-		| //Remove her chastity belt if you wish to fuck her ass//
+	| //Remove her chastity belt if you wish to fuck her ass//
 	<</if>>
 	</span>
 	| <<link "Use her mouth">><<replace "#miniscene">><<include "FLips">><br>&nbsp;&nbsp;&nbsp;&nbsp;<</replace>><</link>>
@@ -110,7 +110,7 @@
 	<span id = "impreg">
 	<<if ((canGetPregnant($activeSlave)) && ($activeSlave.clothes != "a Fuckdoll suit"))>>
 		<<if ($PC.dick != 0 && $activeSlave.eggType == "human")>>
-			| <<link "Impregnate her yourself">><<replace "#miniscene">><<include "FPCImpreg">><br>&nbsp;&nbsp;&nbsp;&nbsp;<</replace>><<SlaveInteractImpreg>><<SlaveInteractFertility>><</link>>
+		| <<link "Impregnate her yourself">><<replace "#miniscene">><<include "FPCImpreg">><br>&nbsp;&nbsp;&nbsp;&nbsp;<</replace>><<SlaveInteractImpreg>><<SlaveInteractFertility>><</link>>
 		<</if>>
 		| [[Use another slave to impregnate her|FSlaveImpreg]]
 	<</if>>
@@ -379,9 +379,6 @@ __Rules Assistant__
 		| <<link "Dick">><<set $activeSlave.toyHole = "dick">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>>
 		<</if>>
 		| <<link "No Preference">><<set $activeSlave.toyHole = "all her holes">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>>
-		
-		<br>
-		
 	<</if>>
 </span>
 
@@ -433,7 +430,7 @@ __Assignment__: <strong><span id="assign">$activeSlave.assignment<<if $activeSla
 	<</if>>
 <</if>>
 <<if ($activeSlave.devotion >= -20) || (($activeSlave.devotion >= -50) && ($activeSlave.trust < -20)) || ($activeSlave.trust < -50)>>
-  <<if ($activeSlave.intelligenceImplant < 1) || ($activeSlave.accent+$schoolroomUpgradeLanguage > 2) || ($activeSlave.oralSkill <= 30) || ($activeSlave.whoreSkill <= 30) || ($activeSlave.entertainSkill <= 30) || ($activeSlave.analSkill < 30) || (($activeSlave.vaginalSkill < 30) && ($activeSlave.vagina >= 0))>>
+  <<if $activeSlave.intelligenceImplant < 1 && $activeSlave.fetish != "mindbroken">>
 	| __<<link "Take slave classes">>   <<assignJob $activeSlave "take classes">><<replace "#assign">>$activeSlave.assignment<</replace>><<SlaveInteractFucktoy>><</link>>__
   <<else>>
     | Take slave classes
@@ -501,12 +498,12 @@ __Assignment__: <strong><span id="assign">$activeSlave.assignment<<if $activeSla
 	<<else>>Spa<</if>>
 	<</if>>
 	<<if $clinic != 0>>|
-	<<if $clinic > $clinicSlaves && ($activeSlave.health < 20) || (($activeSlave.chem > 15) && ($clinicUpgradeFilters == 1)) || (($activeSlave.bellyImplant > 100) && ($bellyImplants == 1)) || $activeSlave.preg > 1>>
+	<<if $clinic > $clinicSlaves && ($activeSlave.health < 20 || ($Nurse != 0 && ($activeSlave.chem > 15 && $clinicUpgradeFilters == 1) || ($bellyImplants == 1 && $activeSlave.bellyImplant > 100) || ($activeSlave.preg => 1 && ($clinicSpeedGestation >= 0 || $slaves[_i].pregControl == "speed up"))))>>
 		[[Clinic|Assign][$slaves[_i] = $activeSlave, $returnTo = "Clinic", $i = _i]]
 	<<else>>Clinic<</if>>
 	<</if>>
 	<<if $schoolroom != 0>>|
-	<<if $schoolroom > $schoolroomSlaves && (($activeSlave.devotion >= -20) || (($activeSlave.devotion >= -50) && ($activeSlave.trust < -20)) || ($activeSlave.trust < -50)) && (($activeSlave.intelligenceImplant < 1) || ($activeSlave.voice != 0 && $activeSlave.accent+$schoolroomUpgradeLanguage > 2) || ($activeSlave.oralSkill <= 10+$schoolroomUpgradeSkills*20) || ($activeSlave.whoreSkill <= 10+$schoolroomUpgradeSkills*20) || ($activeSlave.entertainSkill <= 10+$schoolroomUpgradeSkills*20) || ($activeSlave.analSkill < 10+$schoolroomUpgradeSkills*20) || (($activeSlave.vagina >= 0) && ($activeSlave.vaginalSkill < 10+$schoolroomUpgradeSkills*20)))>>
+	<<if $schoolroom > $schoolroomSlaves && $activeSlave.fetish != "mindbroken" && ($activeSlave.devotion >= -20 || ($activeSlave.devotion >= -50 && $activeSlave.trust < -20) || $activeSlave.trust < -50) && (($activeSlave.intelligenceImplant < 1) || ($activeSlave.voice != 0 && $activeSlave.accent+$schoolroomUpgradeLanguage > 2) || ($activeSlave.oralSkill <= 10+$schoolroomUpgradeSkills*20) || ($activeSlave.whoreSkill <= 10+$schoolroomUpgradeSkills*20) || ($activeSlave.entertainSkill <= 10+$schoolroomUpgradeSkills*20) || ($activeSlave.analSkill < 10+$schoolroomUpgradeSkills*20) || ($activeSlave.vagina >= 0 && $activeSlave.vaginalSkill < 10+$schoolroomUpgradeSkills*20))>>
 		[[Schoolroom|Assign][$slaves[_i] = $activeSlave, $returnTo = "Schoolroom", $i = _i]]
 	<<else>>Schoolroom<</if>>
 	<</if>>
diff --git a/src/uncategorized/slaveSummary.tw b/src/uncategorized/slaveSummary.tw
index df180de1c33..27235943d32 100644
--- a/src/uncategorized/slaveSummary.tw
+++ b/src/uncategorized/slaveSummary.tw
@@ -71,8 +71,8 @@
 <<if _Slave.fuckdoll > 0>><<continue>><</if>>
 <<if $Flag == 0>>
 	<<if _Slave.assignment == "rest in the spa">><<continue>><</if>>
-	<<if (_Slave.health < 20) || (_Slave.trust < 60) || (_Slave.devotion <= 60) || (_Slave.fetish == "mindbroken")>>
-	<<if _Slave.devotion >= -20 || _Slave.fetish == "mindbroken" || _Slave.sexualFlaw !== "none" || _Slave.behavioralFlaw !== "none">>
+	<<if (_Slave.health < 20) || (_Slave.trust < 60) || (_Slave.devotion <= 60) || (_Slave.fetish == "mindbroken") || _Slave.sexualFlaw !== "none" || _Slave.behavioralFlaw !== "none">>
+	<<if _Slave.devotion >= -20 || _Slave.fetish == "mindbroken">>
 		<br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>><<print "[[_Slave.slaveName|Slave Interact][$activeSlave = $slaves["+_i+"]]]">>
 	<<else>>
 		<br>//_Slave.slaveName cannot be trusted in the spa//
@@ -173,7 +173,7 @@
 <<if _Slave.fuckdoll > 0>><<continue>><</if>>
 <<if $Flag == 0>>
 	<<if _Slave.assignment == "get treatment in the clinic">><<continue>><</if>>
-	<<if (_Slave.health < 20) || ((_Slave.chem > 15) && ($clinicUpgradeFilters == 1)) || ((_Slave.bellyImplant > 100) && ($bellyImplants == 1)) || _Slave.preg > 1>>
+	<<if (_Slave.health < 20) || ($Nurse != 0 && (_Slave.chem > 15 && $clinicUpgradeFilters == 1) || ($bellyImplants == 1 && _Slave.bellyImplant > 100) || (_Slave.preg => 1 && ($clinicSpeedGestation >= 0 || $slaves[_i].pregControl == "speed up")))>>
 		<br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>><<print "[[_Slave.slaveName|Slave Interact][$activeSlave = $slaves["+_i+"]]]">>
 	<<else>>
 		<br>//_Slave.slaveName cannot benefit from the clinic//
@@ -199,7 +199,7 @@
 	<<continue>>
 <</if>>
 <<case "Schoolroom">>
-<<if _Slave.fuckdoll > 0>><<continue>><</if>>
+<<if _Slave.fuckdoll > 0 || _Slave.fetish == "mindbroken">><<continue>><</if>>
 <<if $Flag == 0>>
 	<<if _Slave.assignment == "learn in the schoolroom">><<continue>><</if>>
 	<<if (_Slave.devotion >= -20) || ((_Slave.devotion >= -50) && (_Slave.trust < -20)) || (_Slave.trust < -50)>>
diff --git a/src/uncategorized/spaReport.tw b/src/uncategorized/spaReport.tw
index 41c918be1ca..2bca6c2f10e 100644
--- a/src/uncategorized/spaReport.tw
+++ b/src/uncategorized/spaReport.tw
@@ -1,6 +1,6 @@
 :: Spa Report [nobr]
 
-<<set _flawSoftened = 0, _healthBonus = 0, _idleBonus = 0, _restedSlaves = 0, _trustBonus = 0, _DL = $SpaiIDs.length, $spaSlaves = _DL, _SL = $slaves.length, _FLs = -1>>
+<<set _bonusToggle = 0, _healthBonus = 0, _idleBonus = 0, _restedSlaves = 0, _trustBonus = 0, _DL = $SpaiIDs.length, $spaSlaves = _DL, _SL = $slaves.length, _FLs = -1>>
 
 <<for _dI = 0; _dI < _DL; _dI++>>
 <<set _i = $SpaiIDs[_dI].Index, _ID = $SpaiIDs[_dI].ID>>
@@ -56,11 +56,6 @@
 	<<if ($Attendant.fetish == "none") || ($Attendant.fetish == "submissive")>>
 		<<set _devBonus++>>
 	<</if>>
-	<<if $attendantCareers.includes($Attendant.career)>>
-		<<set _bonusToggle = 1>>
-	<<else>>
-		<<set _bonusToggle = 0>>
-	<</if>>
 	&nbsp;&nbsp;&nbsp;&nbsp;$Attendant.slaveName is serving as the spa attendant.<<if $Attendant.relationship == -3>> She tries her best to be your perfect attentive and caring wife.<</if>>
 	<<if (_FLsFetish == 1)>>
 		When she is paid a visit by a slave with sexual issues to work out, she provides her with an understanding, willing, giving partner. She finds real satisfaction in helping your slaves find sexual gratification, and @@.lightsalmon;becomes a submissive.@@
@@ -69,7 +64,7 @@
 	<</if>>
 	<<if $attendantCareers.includes($Attendant.career)>>
 		She has experience with counseling from her life before she was a slave, making her better at building a rapport with troubled slaves, and giving her a better chance of softening flaws into beneficial quirks.
-		<<set _idleBonus++>>
+		<<set _bonusToggle = 1, _idleBonus++>>
 	<</if>>
 	<<if ($Attendant.eyes == -2)>>
 		Her blindness allows her to deeply connect with her girls.
@@ -139,7 +134,7 @@
 		<<set $slaves[_i].behavioralQuirk = "advocate">>
 		<</switch>>
 				<<set $slaves[_i].behavioralFlaw = "none", _attendantUsedCure += 1>>
-				$Attendant.slaveName works carefully with $slaves[_i].slaveName, and successfully @@.green;softens her behavioral flaw@@ into an appealing quirk.
+				<br>&nbsp;&nbsp;&nbsp;&nbsp;$Attendant.slaveName works carefully with $slaves[_i].slaveName, and successfully @@.green;softens her behavioral flaw@@ into an appealing quirk.
 		<</if>>
 	<<elseif $slaves[_i].sexualFlaw != "none">>
 		<<if random(1,100) > (100-($Attendant.intelligence*10)-_seed)>>
@@ -164,7 +159,7 @@
 		<<set $slaves[_i].sexualQuirk = "size queen">>
 		<</switch>>
 				<<set $slaves[_i].sexualFlaw = "none", _attendantUsedCure += 1>>
-				$Attendant.slaveName works carefully with $slaves[_i].slaveName, and successfully @@.green;softens her sexual flaw@@ into an appealing quirk.
+				<br>&nbsp;&nbsp;&nbsp;&nbsp;$Attendant.slaveName works carefully with $slaves[_i].slaveName, and successfully @@.green;softens her sexual flaw@@ into an appealing quirk.
 		<</if>>
 	<</if>>
 	<</if>>
diff --git a/src/utility/raWidgets.tw b/src/utility/raWidgets.tw
index eea8344e5d9..f9ca23d60e4 100644
--- a/src/utility/raWidgets.tw
+++ b/src/utility/raWidgets.tw
@@ -2971,7 +2971,7 @@ Your brand design is ''$brandDesign.''
 <<widget "RARemoveRule">>
 	<<for _s = 0; _s < $args[0].currentRules.length; _s++>>
 		<<if _currentRule.ID == $args[0].currentRules[_s]>>
-			<<set $dump = $args[0].currentRules.pluck([_s],[_s])>>
+			<<set _dump = $args[0].currentRules.deleteAt(_s)>>
 		<</if>>
 	<</for>>
 	<br>Rule _rule (_currentRule.name) is no longer applying to $args[0].slaveName.
@@ -4093,20 +4093,6 @@ is now _currentRule.hLength cm long.
 	<</if>>
 	<</if>>
 	<</if>>
-	<<if _used == 0>>
-		<<set _tmp = lastClitSettingEnergyRule($args[0], $defaultRules)>>
-		<<if (_tmp != null) && (_tmp.ID == _currentRule.ID)>>
-		<<if _currentRule.clitSettingEnergy !== "no default setting">>
-		<<if $args[0].energy < _currentRule.clitSettingEnergy && $args[0].clitSetting !== "all">>
-			<<set $args[0].clitSetting = "all", _used = 1>>
-			<br>$args[0].slaveName's smart piercing has been set to enhance libido.
-		<<elseif $args[0].energy >= _currentRule.clitSettingEnergy + 10 && $args[0].clitSetting !== "none">>
-			<<set $args[0].clitSetting = "none", _used = 1>>
-			<br>$args[0].slaveName's smart piercing has been set to suppress libido.
-		<</if>>
-		<</if>>
-		<</if>>
-	<</if>>
 	<<if _used == 0>>
 		<<set _tmp = lastClitSettingXYRule($args[0], $defaultRules)>>
 		<<if (_tmp != null) && (_tmp.ID == _currentRule.ID)>>
@@ -4135,6 +4121,20 @@ is now _currentRule.hLength cm long.
 		<</if>>
 		<</if>>
 	<</if>>
+	<<if _used == 0>>
+		<<set _tmp = lastClitSettingEnergyRule($args[0], $defaultRules)>>
+		<<if (_tmp != null) && (_tmp.ID == _currentRule.ID)>>
+		<<if _currentRule.clitSettingEnergy !== "no default setting">>
+		<<if $args[0].energy < _currentRule.clitSettingEnergy && $args[0].clitSetting !== "all">>
+			<<set $args[0].clitSetting = "all", _used = 1>>
+			<br>$args[0].slaveName's smart piercing has been set to enhance libido.
+		<<elseif $args[0].energy >= _currentRule.clitSettingEnergy + 10 && $args[0].clitSetting !== "none">>
+			<<set $args[0].clitSetting = "none", _used = 1>>
+			<br>$args[0].slaveName's smart piercing has been set to suppress libido.
+		<</if>>
+		<</if>>
+		<</if>>
+	<</if>>
 <</if>>
 
 <<set _tmp = lastVaginaPiercingRule($args[0], $defaultRules)>>
@@ -4454,7 +4454,7 @@ consequences.
 		<</if>>
 	<</if>>
 <<case "clinic">>
-	<<if ($clinic > $clinicSlaves) && ($args[0].health < 20) || (($args[0].chem > 15) && ($clinicUpgradeFilters == 1)) || (($args[0].bellyImplant > 100) && ($bellyImplants == 1)) || $args[0].preg > 1>>
+	<<if ($clinic > $clinicSlaves) && ($args[0].health < 20) || (($Nurse != 0) && ($args[0].chem > 15) && ($clinicUpgradeFilters == 1)) || (($args[0].bellyImplant > 100) && ($bellyImplants == 1)) || $args[0].preg > 1>>
 	<<if ($args[0].assignment != "get treatment in the clinic")>>
 		<br>$args[0].slaveName has automatically been assigned to $args[0].assignment.
 		<<if ($personalAttention == $args[0].ID)>>
@@ -4562,7 +4562,7 @@ consequences.
 		<</if>>
 	<</if>>
 <<case "schoolroom">>
-	<<if ($schoolroom > $schoolroomSlaves) && ($args[0].devotion >= -20) || (($args[0].devotion >= -50) && ($args[0].trust < -20)) || ($args[0].trust < -50)>>
+	<<if ($schoolroom > $schoolroomSlaves) && ($args[0].fetish != "mindbroken") && ($args[0].devotion >= -20 || ($args[0].devotion >= -50 && $args[0].trust < -20) || $args[0].trust < -50)>>
 	<<if ($args[0].intelligenceImplant < 1) || ($args[0].voice != 0 && $args[0].accent+$schoolroomUpgradeLanguage > 2) || ($args[0].oralSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].whoreSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].entertainSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].analSkill < 10+$schoolroomUpgradeSkills*20) || (($args[0].vagina >= 0) && ($args[0].vaginalSkill < 10+$schoolroomUpgradeSkills*20))>>
 	<<if ($args[0].assignment != "learn in the schoolroom")>>
 		<br>$args[0].slaveName has automatically been assigned to $args[0].assignment.
@@ -4626,38 +4626,26 @@ consequences.
 	<<if (def _currentRule.excludedSlaves) && (_currentRule.excludedSlaves.length > 0) && ruleSlaveExcluded($args[0], _currentRule)>>
 		<<RARemoveRule $args[0]>>
 		<<continue>>
-	<</if>>
-
-	<<if (def _currentRule.selectedSlaves) && (_currentRule.selectedSlaves.length > 0) && !ruleSlaveSelected($args[0], _currentRule)>>
+	<<elseif (def _currentRule.selectedSlaves) && (_currentRule.selectedSlaves.length > 0) && !ruleSlaveSelected($args[0], _currentRule)>>
 		<<RARemoveRule $args[0]>>
 		<<continue>>
 	<</if>>
-
 	<<if $args[0].assignmentVisible == 0>>
-
 		<<if (def _currentRule.excludeFacility) && (_currentRule.excludeFacility.length > 0) && ruleExcludeSlaveFacility(_currentRule, $args[0])>>
 			<<RARemoveRule $args[0]>>
 			<<continue>>
-		<</if>>
-		
-		<<if (def _currentRule.facility) && (_currentRule.facility.length > 0) && !ruleAppliedToSlaveFacility(_currentRule, $args[0])>>
+		<<elseif (def _currentRule.facility) && (_currentRule.facility.length > 0) && !ruleAppliedToSlaveFacility(_currentRule, $args[0])>>
 			<<RARemoveRule $args[0]>>
 			<<continue>>
 		<</if>>
-		
 	<<else>>
-
 		<<if (def _currentRule.excludeAssignment) && (_currentRule.excludeAssignment.length > 0) && ruleAssignment(_currentRule.excludeAssignment, $args[0].assignment)>>
 			<<RARemoveRule $args[0]>>
 			<<continue>>
-		<</if>>
-
-		<<if (def _currentRule.assignment) && (_currentRule.assignment.length > 0) && !ruleAssignment(_currentRule.assignment, $args[0].assignment)>>
+		<<elseif (def _currentRule.assignment) && (_currentRule.assignment.length > 0) && !ruleAssignment(_currentRule.assignment, $args[0].assignment)>>
 			<<RARemoveRule $args[0]>>
 			<<continue>>
 		<</if>>
-
-		
 	<</if>>
 <</if>>
 
-- 
GitLab