From 03fea5ec0cde9f54d8ae658bb0f00e548ada0b15 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Sat, 7 Nov 2020 19:37:19 -0500
Subject: [PATCH] polish

---
 src/endWeek/reports/spaReport.js | 331 +++++++++++++++++--------------
 1 file changed, 187 insertions(+), 144 deletions(-)

diff --git a/src/endWeek/reports/spaReport.js b/src/endWeek/reports/spaReport.js
index 344c8ef017f..639d56433aa 100644
--- a/src/endWeek/reports/spaReport.js
+++ b/src/endWeek/reports/spaReport.js
@@ -1,13 +1,13 @@
 /**
  * @returns {DocumentFragment}
  */
-App.EndWeek.dairyReport = function() {
+App.EndWeek.spaReport = function() {
 	const el = new DocumentFragment();
 	let r;
 
-
-	const _slaves = App.Utils.sortedEmployees(App.Entity.facilities.spa);
-	let _DL = _slaves.length, _SL = V.slaves.length, _bonusToggle = 0, _healthBonus = 0, _idleBonus = 0, _restedSlaves = 0, _trustBonus = 0, _devBonus;
+	const slaves = App.Utils.sortedEmployees(App.Entity.facilities.spa);
+	let _DL = slaves.length;
+	let _bonusToggle = 0, _healthBonus = 0, _idleBonus = 0, _restedSlaves = 0, _restedSlave, _trustBonus = 0, _devBonus;
 
 	if (V.spaDecoration !== "standard") {
 		_devBonus = 1;
@@ -34,12 +34,16 @@ App.EndWeek.dairyReport = function() {
 		if (S.Attendant.fetishStrength <= 95) {
 			if (S.Attendant.fetish !== "submissive") {
 				if (fetishChangeChance(S.Attendant) > random(0, 100)) {
-					_FLsFetish = 1, S.Attendant.fetishKnown = 1, S.Attendant.fetish = "submissive";
+					_FLsFetish = 1;
+					S.Attendant.fetishKnown = 1;
+					S.Attendant.fetish = "submissive";
 				}
 			} else if (S.Attendant.fetishKnown === 0) {
-				_FLsFetish = 1, S.Attendant.fetishKnown = 1;
+				_FLsFetish = 1;
+				S.Attendant.fetishKnown = 1;
 			} else {
-				_FLsFetish = 2, S.Attendant.fetishStrength += 4;
+				_FLsFetish = 2;
+				S.Attendant.fetishStrength += 4;
 			}
 		}
 		if (S.Attendant.fetish === "none" || S.Attendant.fetish === "submissive") {
@@ -50,7 +54,6 @@ App.EndWeek.dairyReport = function() {
 			He, His,
 			he, his, him, himself, wife
 		} = getPronouns(S.Attendant);
-		//&nbsp;&nbsp;&nbsp;&nbsp;
 		r.push(`${SlaveFullName(S.Attendant)} is serving as the spa attendant.`);
 		if (S.Attendant.relationship === -3 && S.Attendant.devotion > 50) {
 			r.push(` ${He} tries ${his} best to be your perfect attentive, caring and loving ${wife}.`);
@@ -62,10 +65,12 @@ App.EndWeek.dairyReport = function() {
 		}
 		if (setup.attendantCareers.includes(S.Attendant.career)) {
 			r.push(`${He} has experience with counseling from ${his} life before ${he} was a slave, making ${him} better at building rapport with troubled slaves, and giving ${him} a better chance of softening flaws into beneficial quirks.`);
-			_bonusToggle = 1, _idleBonus++;
+			_bonusToggle = 1;
+			_idleBonus++;
 		} else if (S.Attendant.skill.attendant >= V.masteredXP) {
 			r.push(`${He} has experience with counseling from working for you, making ${him} better at building rapport with troubled slaves, and giving ${him} a better chance of softening flaws into beneficial quirks.`);
-			_bonusToggle = 1, _idleBonus++;
+			_bonusToggle = 1;
+			_idleBonus++;
 		} else {
 			S.Attendant.skill.attendant += random(1, Math.ceil((S.Attendant.intelligence + S.Attendant.intelligenceImplant) / 15) + 8);
 		}
@@ -84,7 +89,8 @@ App.EndWeek.dairyReport = function() {
 		}
 		if (S.Attendant.visualAge > 35) {
 			r.push(`${His} apparent maturity encourages the slaves in the spa to relax and pour out their troubles to ${him}.`);
-			_healthBonus++, _idleBonus++;
+			_healthBonus++;
+			_idleBonus++;
 		}
 		if (S.Attendant.intelligence + S.Attendant.intelligenceImplant > 15) {
 			r.push(`${He}'s so intelligent ${he} can suss out the cause of slaves' emotional issues and counsel them effectively.`);
@@ -92,158 +98,195 @@ App.EndWeek.dairyReport = function() {
 		}
 		if (isFertile(S.Attendant) || (S.Attendant.bellyPreg >= 1500) || (S.Attendant.counter.birthsTotal > 0) || (S.Attendant.bellyImplant >= 1500)) {
 			r.push(`${He} has a natural mothering instinct and really makes ${his} charges feel at home.`);
-			_idleBonus++, _healthBonus++;
+			_idleBonus++;
+			_healthBonus++;
 		}
 		let _attendantUsedCure = 0;
-		for (const _slave of _slaves) {
-			const {
-				He2, His2,
-				he2, his2, him2, himself2, wife2
-			} = getPronouns(_slave).appendSuffix("2");
-			if (_slave.fetish === "mindbroken" && _slave.health.condition > 20 && _attendantUsedCure === 0 && V.spaFix !== 2) {
+		for (const slave of slaves) {
+			const {he2, his2, him2} = getPronouns(slave).appendSuffix("2");
+			if (slave.fetish === "mindbroken" && slave.health.condition > 20 && _attendantUsedCure === 0 && V.spaFix !== 2) {
 				_attendantUsedCure = 1;
 				if (random(1, 100) > 90 - S.Attendant.devotion) {
-					//<br>&nbsp;&nbsp;&nbsp;&nbsp;
-					r.push(`<span class="green">Something almost miraculous has happened.</span> ${S.Attendant.slaveName} has always refused to believe that ${_slave.slaveName} could not be reached, and has lavished patient tenderness on ${_him2} in ${V.spaName}. ${_slave.slaveName} has begun to respond, and is stirring from ${_his2} mental torpor.`);
-					_slave.devotion = -3;
-					_slave.sexualFlaw = "apathetic";
-					_slave.behavioralFlaw = either("hates men", "odd");
-					_slave.fetish = "none";
-					_slave.fetishKnown = 1;
-					const _spr = V.genePool.findIndex(function(s) { return s.ID === _slave.ID; });
+					const curedSlave = App.UI.DOM.makeElement("div", null, "indent");
+					const curedArray = [`<span class="green">Something almost miraculous has happened.</span> ${S.Attendant.slaveName} has always refused to believe that ${slave.slaveName} could not be reached, and has lavished patient tenderness on ${him2} in ${V.spaName}. ${slave.slaveName} has begun to respond, and is stirring from ${his2} mental torpor.`];
+					slave.devotion = -3;
+					slave.sexualFlaw = "apathetic";
+					slave.behavioralFlaw = either("hates men", "odd");
+					slave.fetish = "none";
+					slave.fetishKnown = 1;
+					const _spr = V.genePool.findIndex(function(s) { return s.ID === slave.ID; });
 					if (V.genePool[_spr].intelligence >= -95) {
-						_slave.intelligence = V.genePool[_spr].intelligence - 30;
+						slave.intelligence = V.genePool[_spr].intelligence - 30;
 					}
-					if (V.arcologies[0].FSPaternalist > 0) {
-						r.push(`Society <span class="green">strongly approves</span> of${_slave.slaveName} being restored to sanity, which advances ideals about enlightened slaveownership.`);
+					if (V.arcologies[0].FSPaternalist !== "unset" && V.arcologies[0].FSPaternalist > 0) {
+						curedArray.push(` Society <span class="green">strongly approves</span> of${slave.slaveName} being restored to sanity, which advances ideals about enlightened slaveownership.`);
 						V.arcologies[0].FSPaternalist += 0.01 * V.FSSingleSlaveRep;
-						repX(2 * V.FSSingleSlaveRep * (V.arcologies[0].FSPaternalist / V.FSLockinLevel), "spa", _slave);
+						repX(2 * V.FSSingleSlaveRep * (V.arcologies[0].FSPaternalist / V.FSLockinLevel), "spa", slave);
 					}
+					App.Events.addNode(curedSlave, curedArray);
+					r.push(curedSlave);
 				}
 			}
 			const _seed = _bonusToggle * 10;
-			if (_bonusToggle === 1 && _slave.trust < 60) {
-				_slave.trust++;
+			if (_bonusToggle === 1 && slave.trust < 60) {
+				slave.trust++;
 			}
-			if (S.Attendant.rivalryTarget === _slave.ID) {
-				r.push(`${He} constantly harasses ${his} ${rivalryTerm(S.Attendant)}, ${_slave.slaveName}, preventing ${_him2} from getting comfortable and forcing ${_him2} to keep ${_his2} guard up.`);
-				_slave.devotion -= 4, _slave.trust -= 4;
+			if (S.Attendant.rivalryTarget === slave.ID) {
+				r.push(`${He} constantly harasses ${his} ${rivalryTerm(S.Attendant)}, ${slave.slaveName}, preventing ${him2} from getting comfortable and forcing ${him2} to keep ${his2} guard up.`);
+				slave.devotion -= 4;
+				slave.trust -= 4;
 				if (random(1, 100) > 35) {
-					S.Attendant.rivalry++, S.Attendant.rivalry++, _slave.rivalry++;
+					S.Attendant.rivalry++;
+					S.Attendant.rivalry++;
+					slave.rivalry++;
 				}
-			} else if (S.Attendant.relationshipTarget === _slave.ID) {
-				r.push(`${He} dedicates most of ${his} attention to ${his} ${relationshipTerm(S.Attendant)}, ${_slave.slaveName}, making ${_his2} stress, both physical and mental, wash away.`);
-				_slave.devotion += 3, _slave.trust += 3;
-			} else if (areRelated(S.Attendant, _slave)) {
-				r.push(`${He} makes sure to spend extra time caring for ${his} ${relativeTerm(S.Attendant, _slave)}, ${_slave.slaveName}.`);
-				_slave.trust++;
-				improveCondition(_slave, 1);
+			} else if (S.Attendant.relationshipTarget === slave.ID) {
+				r.push(`${He} dedicates most of ${his} attention to ${his} ${relationshipTerm(S.Attendant)}, ${slave.slaveName}, making ${his2} stress, both physical and mental, wash away.`);
+				slave.devotion += 3;
+				slave.trust += 3;
+			} else if (areRelated(S.Attendant, slave)) {
+				r.push(`${He} makes sure to spend extra time caring for ${his} ${relativeTerm(S.Attendant, slave)}, ${slave.slaveName}.`);
+				slave.trust++;
+				improveCondition(slave, 1);
 			}
-			switch (_slave.prestigeDesc) {
+			switch (slave.prestigeDesc) {
 				case "$He is a famed Free Cities whore, and commands top prices.":
-					r.push(`${He} does ${his} best to relax the famous whore,${_slave.slaveName}, making sure to`);
-					if (_slave.vagina > 2 || _slave.anus > 2) {
-						r.push(`pay special attention to ${_his2} worn holes.`);
+					r.push(`${He} does ${his} best to relax the famous whore,${slave.slaveName}, making sure to`);
+					if (slave.vagina > 2 || slave.anus > 2) {
+						r.push(`pay special attention to ${his2} worn holes.`);
 					} else {
-						r.push(`get ${_him2} clean and relaxed for ${_his2} next usage.`);
+						r.push(`get ${him2} clean and relaxed for ${his2} next usage.`);
 					}
-					_slave.devotion += 3, _slave.trust += 3;
+					slave.devotion += 3;
+					slave.trust += 3;
+					break;
 				case "$He is a famed Free Cities slut, and can please anyone.":
-					r.push(`${He} does ${his} best to soothe the famous entertainer, ${_slave.slaveName}, letting ${_him2} relax in blissful peace.`);
-					_slave.devotion += 3, _slave.trust += 3;
-				case "${He} is remembered for winning best in show as a cockmilker.":
-					if (_slave.balls > 6 && _slave.dick !== 0) {
+					r.push(`${He} does ${his} best to soothe the famous entertainer, ${slave.slaveName}, letting ${him2} relax in blissful peace.`);
+					slave.devotion += 3;
+					slave.trust += 3;
+					break;
+				case "$He is remembered for winning best in show as a cockmilker.":
+					if (slave.balls > 6 && slave.dick !== 0) {
 						if (S.Attendant.fetish === "cumslut") {
-							r.push(`${He} can't keep ${his} ${hasBothArms(S.Attendant) ? `hands` : `hand`} off ${_slave.slaveName}'s cock and balls, but ${_he2} doesn't mind being milked constantly. Before long, strands of cum can be found floating all throughout the bath.`);
+							r.push(`${He} can't keep ${his} ${hasBothArms(S.Attendant) ? `hands` : `hand`} off ${slave.slaveName}'s cock and balls, but ${he2} doesn't mind being milked constantly. Before long, strands of cum can be found floating all throughout the bath.`);
 							S.Attendant.fetishStrength += 4;
 						} else {
-							r.push(`${He} does ${his} best to accommodate ${_slave.slaveName}'s massive genitals and tends to ${_him2} whenever ${_he2} feels a need for release.`);
+							r.push(`${He} does ${his} best to accommodate ${slave.slaveName}'s massive genitals and tends to ${him2} whenever ${he2} feels a need for release.`);
 							if (random(1, 100) > 65 && S.Attendant.fetish === "none") {
 								r.push(`After taking several massive loads to the face, ${S.Attendant.slaveName} begins to find satisfaction in being coated in cum.`);
 								S.Attendant.fetish = "cumslut";
 							}
 						}
 					}
-					_slave.devotion += 3, _slave.trust += 3;
+					slave.devotion += 3;
+					slave.trust += 3;
+					break;
 				case "$He is remembered for winning best in show as a dairy cow.":
-					if (_slave.lactation > 0 && (_slave.boobs - _slave.boobsImplant) > 6000) {
+					if (slave.lactation > 0 && (slave.boobs - slave.boobsImplant) > 6000) {
 						if (S.Attendant.fetish === "boobs") {
-							r.push(`${He} can't keep ${his} ${hasBothArms(S.Attendant) ? `hands` : `hand`} off ${_slave.slaveName}'s huge breasts, but ${_he2} doesn't mind being milked constantly. Before long the bath gains a white tint.`);
-							S.Attendant.fetishStrength += 4, S.Attendant.fetishStrength += 4;
+							r.push(`${He} can't keep ${his} ${hasBothArms(S.Attendant) ? `hands` : `hand`} off ${slave.slaveName}'s huge breasts, but ${he2} doesn't mind being milked constantly. Before long the bath gains a white tint.`);
+							S.Attendant.fetishStrength += 4;
+							S.Attendant.fetishStrength += 4;
 						} else {
-							r.push(`${He} does ${his} best to accommodate ${_slave.slaveName}'s massive breasts and tends to ${_him2} whenever ${_he2} feels a need for release.`);
+							r.push(`${He} does ${his} best to accommodate ${slave.slaveName}'s massive breasts and tends to ${him2} whenever ${he2} feels a need for release.`);
 							if (random(1, 100) > 65 && S.Attendant.fetish === "none") {
 								r.push(`After multiple milking sessions, ${S.Attendant.slaveName} begins to find ${himself} fantasizing about having giant milky breasts too.`);
 								S.Attendant.fetish = "boobs";
 							}
 						}
-						_slave.devotion += 3, _slave.trust += 3, _slave.lactationDuration = 2, _slave.boobs -= _slave.boobsMilk, _slave.boobsMilk = 0;
+						slave.devotion += 3;
+						slave.trust += 3;
+						slave.lactationDuration = 2;
+						slave.boobs -= slave.boobsMilk;
+						slave.boobsMilk = 0;
 					}
+					break;
 				case "$He is remembered for winning best in show as a breeder.":
-					if (_slave.bellyPreg >= 5000) {
+					if (slave.bellyPreg >= 5000) {
 						if (S.Attendant.fetish === "pregnancy") {
-							r.push(`${He} can't keep ${his} ${hasBothArms(S.Attendant) ? `hands` : `hand`} off ${_slave.slaveName}'s pregnancy, but ${_he2} doesn't mind ${_his2} full belly being fondled.`);
-							S.Attendant.fetishStrength += 4, S.Attendant.fetishStrength += 4;
+							r.push(`${He} can't keep ${his} ${hasBothArms(S.Attendant) ? `hands` : `hand`} off ${slave.slaveName}'s pregnancy, but ${he2} doesn't mind ${his2} full belly being fondled.`);
+							S.Attendant.fetishStrength += 4;
+							S.Attendant.fetishStrength += 4;
 						} else {
-							r.push(`${He} does ${his} best to accommodate ${_slave.slaveName}'s pregnancy and to make sure the mother-to-be is happy and comfortable.`);
+							r.push(`${He} does ${his} best to accommodate ${slave.slaveName}'s pregnancy and to make sure the mother-to-be is happy and comfortable.`);
 							if (random(1, 100) > 65 && S.Attendant.fetish === "none") {
-								r.push(`After massaging ${_slave.slaveName}'s growing belly multiple times, ${S.Attendant.slaveName} begins to find ${himself} fantasizing about being swollen with life too.`);
+								r.push(`After massaging ${slave.slaveName}'s growing belly multiple times, ${S.Attendant.slaveName} begins to find ${himself} fantasizing about being swollen with life too.`);
 								S.Attendant.fetish = "pregnancy";
 							}
 						}
-						_slave.devotion += 3, _slave.trust += 3;
+						slave.devotion += 3;
+						slave.trust += 3;
 					} else {
 						if (S.Attendant.fetish === "pregnancy") {
-							r.push(`${He} can't help but pester ${_slave.slaveName} with questions about ${_his2} famous pregnancy, limiting ${_his2} ability to truly relax.`);
-							_slave.devotion += 1, _slave.trust += 1;
-						} else if (canGetPregnant(_slave)) {
-							r.push(`${He} does ${his} best to encourage ${_slave.slaveName}'s fertilization by performing any fertility boosting actions ${he} can.`);
-							_slave.devotion += 3, _slave.trust += 3;
+							r.push(`${He} can't help but pester ${slave.slaveName} with questions about ${his2} famous pregnancy, limiting ${his2} ability to truly relax.`);
+							slave.devotion += 1;
+							slave.trust += 1;
+						} else if (canGetPregnant(slave)) {
+							r.push(`${He} does ${his} best to encourage ${slave.slaveName}'s fertilization by performing any fertility boosting actions ${he} can.`);
+							slave.devotion += 3;
+							slave.trust += 3;
 						}
 					}
 			}
-			if (S.Attendant.intelligence + S.Attendant.intelligenceImplant > 15) && (_attendantUsedCure === 0) && ((S.Attendant.intelligence + S.Attendant.intelligenceImplant) + _seed) > random(1, 200) && (V.spaFix === 0) {
-				if (_slave.behavioralFlaw !== "none") {
-					SoftenBehavioralFlaw(_slave);
+			if (
+				(S.Attendant.intelligence + S.Attendant.intelligenceImplant > 15) &&
+				(_attendantUsedCure === 0) &&
+				(
+					(S.Attendant.intelligence + S.Attendant.intelligenceImplant) + _seed) > random(1, 200) &&
+					(V.spaFix === 0)
+			) {
+				App.Events.addNode(el, r);
+				r = [];
+				if (slave.behavioralFlaw !== "none") {
+					SoftenBehavioralFlaw(slave);
 					_attendantUsedCure += 1;
-					//<br>&nbsp;&nbsp;&nbsp;&nbsp;
-					r.push(`${S.Attendant.slaveName} works carefully with _slave.slaveName, and successfully <span class="green">softens ${_his2} behavioral flaw</span> into an appealing quirk.`);
-				} else if (_slave.sexualFlaw !== "none") {
-					SoftenSexualFlaw(_slave);
+					r.push(`${S.Attendant.slaveName} works carefully with ${slave.slaveName}, and successfully`);
+					r.push(App.UI.DOM.makeElement("span", `softens ${his2} behavioral flaw`, "green"));
+					r.push(`into an appealing quirk.`);
+				} else if (slave.sexualFlaw !== "none") {
+					SoftenSexualFlaw(slave);
 					_attendantUsedCure += 1;
-					//<br>&nbsp;&nbsp;&nbsp;&nbsp;
-					r.push(`${S.Attendant.slaveName} works carefully with _slave.slaveName, and successfully <span class="green">softens ${_his2} sexual flaw</span> into an appealing quirk.`);
+					r.push(`${S.Attendant.slaveName} works carefully with ${slave.slaveName}, and successfully`);
+					r.push(App.UI.DOM.makeElement("span", `softens ${his2} sexual flaw`, "green"));
+					r.push(`into an appealing quirk.`);
 				}
+				App.Events.addNode(el, r, "div", "indent");
+				r = [];
 			}
-			if (_slave.lactation > 0) {
-				r.push(`${S.Attendant.slaveName} takes care to keep _slave.slaveName's breasts comfortably drained.`);
-				_slave.lactationDuration = 2, _slave.boobs -= _slave.boobsMilk, _slave.boobsMilk = 0;
+			if (slave.lactation > 0) {
+				r.push(`${S.Attendant.slaveName} takes care to keep ${slave.slaveName}'s breasts comfortably drained.`);
+				slave.lactationDuration = 2;
+				slave.boobs -= slave.boobsMilk;
+				slave.boobsMilk = 0;
 			}
 		}
+		App.Events.addNode(el, r);
 		if (_DL < V.spa) {
 			const _seed = random(1, 10) + ((V.spa - _DL) * (random(150, 170) + (_idleBonus * 10)));
 			cashX(_seed, "spa", S.Attendant);
-			//<br>&nbsp;&nbsp;&nbsp;&nbsp;
+			r = [];
 			r.push(`Since ${he} doesn't have enough slaves to occupy all ${his} time, the spa takes in citizens' slaves on a contract basis and ${he} helps them too, earning <span class="yellowgreen"> ${cashFormat(_seed)}.</span>`);
 			if (V.arcologies[0].FSHedonisticDecadence > 0 && _DL === 0) {
 				r.push(`Society <span class="green">loves</span> being allowed to lounge in your spa, greatly advancing your laid back culture.`);
 				FutureSocieties.Change("Hedonistic", 2);
 			}
+			App.Events.addNode(el, r, "div", "indent");
 		}
 	}
 
 	if (_DL > 0) {
-		//&nbsp;&nbsp;&nbsp;&nbsp;
+		r = [];
 		if (_DL > 1) {
-			r.push(`''There are${_DL} slaves`);
+			r.push(`There are ${_DL} slaves`);
 		} else {
-			r.push(`''There is one slave`);
+			r.push(`There is one slave`);
 		}
-		r.push(` resting and recuperating in the spa.''`);
+		r.push(`resting and recuperating in the spa.`);
 		if (V.arcologies[0].FSHedonisticDecadence > 0 && _DL === 0) {
 			r.push(`Society <span class="green">approves</span> of your slaves being pampered this way, greatly advancing your laid back culture.`);
 			FutureSocieties.Change("Hedonistic", 1);
 		}
+		App.Events.addNode(el, r, "p", ["indent", "bold"]);
 	}
 
 	if (S.Attendant) {
@@ -268,72 +311,70 @@ App.EndWeek.dairyReport = function() {
 		}
 	}
 
-	for (const _slave of _slaves) {
-		const { }
-		const {
-			He, His,
-			he, his, him, himself, wife
-		} = getPronouns(_slave);
-		_slave.devotion += _devBonus, _slave.trust += _trustBonus;
-		improveCondition(_slave, 5 + _healthBonus);
-		if (_slave.health.condition < -80) {
-			improveCondition(_slave, 15);
-		} else if (_slave.health.condition < -40) {
-			improveCondition(_slave, 10);
-		} else if (_slave.health.condition < 0) {
-			improveCondition(_slave, 5);
+	for (const slave of slaves) {
+		const {he, his} = getPronouns(slave);
+		slave.devotion += _devBonus;
+		slave.trust += _trustBonus;
+		improveCondition(slave, 5 + _healthBonus);
+		if (slave.health.condition < -80) {
+			improveCondition(slave, 15);
+		} else if (slave.health.condition < -40) {
+			improveCondition(slave, 10);
+		} else if (slave.health.condition < 0) {
+			improveCondition(slave, 5);
 		}
-		if (V.spaUpgrade === 1 && _slave.health.condition < 100) {
-			improveCondition(_slave, normalRandInt(8));
+		if (V.spaUpgrade === 1 && slave.health.condition < 100) {
+			improveCondition(slave, normalRandInt(8));
 		}
-		if (_slave.devotion < 60 && _slave.trust < 60) {
-			_slave.devotion++, _slave.trust++;
-		} else if ((_slave.trust < 40)) {
-			_slave.trust += 10;
-		} else if ((_slave.devotion < 40)) {
-			_slave.devotion += 10;
+		if (slave.devotion < 60 && slave.trust < 60) {
+			slave.devotion++;
+			slave.trust++;
+		} else if ((slave.trust < 40)) {
+			slave.trust += 10;
+		} else if ((slave.devotion < 40)) {
+			slave.devotion += 10;
 		}
 		switch (V.spaDecoration) {
 			case "Chattel Religionist":
 			case "Chinese Revivalist":
-				_slave.rules.living = "normal";
+				slave.rules.living = "normal";
+				break;
 			case "Degradationist":
-				_slave.rules.living = "spare";
+				slave.rules.living = "spare";
+				break;
 			default:
-				_slave.rules.living = "luxurious";
+				slave.rules.living = "luxurious";
 		}
-		if (_slave.health.condition >= 20 && _slave.health.tired <= 30 && _slave.trust > 60 && _slave.devotion > 60 && _slave.fetish !== "mindbroken" && _slave.sexualFlaw === "none" && _slave.behavioralFlaw === "none") {
-			//<p>
-			r.push(`<span class="slave-name">${_slave.slaveName}</span> is feeling well enough to leave ${V.spaName},`);
-			//<span class="noteworthy">
-			if (V.assignmentRecords[_slave.ID]) {
-				const _oldJob = V.assignmentRecords[_slave.ID];
-				assignJobSafely(_slave, _oldJob);
-				if (_slave.choosesOwnAssignment === 1) {
+		if (slave.health.condition >= 20 && slave.health.tired <= 30 && slave.trust > 60 && slave.devotion > 60 && slave.fetish !== "mindbroken" && slave.sexualFlaw === "none" && slave.behavioralFlaw === "none") {
+			const slaveFixed = App.UI.DOM.makeElement("p");
+			$(slaveFixed).append(`<span class="slave-name">${slave.slaveName}</span> is feeling well enough to leave ${V.spaName}, `);
+			r = [];
+			if (V.assignmentRecords[slave.ID]) {
+				const _oldJob = V.assignmentRecords[slave.ID];
+				assignJobSafely(slave, _oldJob);
+				if (slave.choosesOwnAssignment === 1) {
 					r.push(`and ${he} is resting before choosing another task.`);
-				} else if (_slave.assignment === "rest") {
+				} else if (slave.assignment === "rest") {
 					if (_oldJob !== "rest") {
 						r.push(`and since ${he} was unable to return to ${his} old task to ${_oldJob}, ${his} assignment has defaulted to rest.`);
 					} else {
 						r.push(`so ${he} has returned to rest.`);
 					}
 				} else {
-					r.push(`so ${he} goes back to ${_slave.assignment}.`);
+					r.push(`so ${he} goes back to ${slave.assignment}.`);
 				}
 			} else {
 				r.push(`so ${his} assignment has defaulted to rest.`);
-				removeJob(_slave, "rest in the spa");
+				removeJob(slave, "rest in the spa");
 			}
-			//</span>
-			//</p>
-			_restedSlaves++, _DL--, _dI--;
+			App.Events.addNode(slaveFixed, r, "span", "noteworthy");
+			el.append(slaveFixed);
+			_restedSlaves++;
+			_restedSlave = slave;
+			_DL--;
 			continue;
 		}
 
-
-
-
-
 		if (V.showEWD !== 0) {
 			const slaveEntry = App.UI.DOM.appendNewElement("div", el, '', "slave-report");
 			if (V.seeImages && V.seeReportImages) {
@@ -349,24 +390,24 @@ App.EndWeek.dairyReport = function() {
 			}
 			App.Events.addNode(slaveEntry, r, "div");
 
-			const { He } = getPronouns(slave);
+			const {He} = getPronouns(slave);
 			r = [
 				He,
-				App.SlaveAssignment.rest(_slave)
-			]
+				App.SlaveAssignment.rest(slave)
+			];
 
-			if (_slave.fetish === "mindbroken") {
+			if (slave.fetish === "mindbroken") {
 				r.push(`${He} remains in the Spa, completely mindbroken.`);
-			} else if (_slave.sexualFlaw !== "none" || _slave.behavioralFlaw !== "none") {
+			} else if (slave.sexualFlaw !== "none" || slave.behavioralFlaw !== "none") {
 				r.push(`${He} remains in the Spa, stubborn in ${his} flaw.`);
-			} else if (_slave.trust < 60 || _slave.devotion < 60) {
+			} else if (slave.trust < 60 || slave.devotion < 60) {
 				r.push(`${He} remains in the Spa, as ${he} is still learning to accept life as a slave.`);
-			} else if (_slave.health.condition < 20) {
+			} else if (slave.health.condition < 20) {
 				r.push(`${He} remains in the Spa, as ${he} is benefiting from its healing properties.`);
-			} else if (_slave.health.tired > 30) {
+			} else if (slave.health.tired > 30) {
 				r.push(`${He} remains in the Spa, continuing to soak away ${his} fatigue.`);
 			}
-			r.push(App.SlaveAssignment.standardSlaveReport(slave, false))
+			r.push(App.SlaveAssignment.standardSlaveReport(slave, false));
 			App.Events.addNode(slaveEntry, r, "div", "indent");
 		} else {
 			// discard return values silently
@@ -375,15 +416,15 @@ App.EndWeek.dairyReport = function() {
 		}
 	}
 	if (_restedSlaves > 0) {
-		//<br><br>&nbsp;&nbsp;&nbsp;
+		const {he, him} = getPronouns(_restedSlave);
 		if (_restedSlaves === 1) {
-			//TODO: fix pronoun
 			r.push(`One slave has rested until ${he} reached a state of <span class="hotpink">devotion</span> and <span class="mediumaquamarine">trust</span> and will leave the spa before the end of the week.`);
 		} else {
 			r.push(`${_restedSlaves} slaves have rested until they reached a state of <span class="hotpink">devotion</span> and <span class="mediumaquamarine">trust</span> and will leave the spa before the end of the week.`);
 		}
 		if (V.spaDecoration !== "standard") {
-			//<br><br>&nbsp;&nbsp;&nbsp;&nbsp;
+			App.Events.addNode(el, r, "p", "indent");
+			r = [];
 			r.push(`${capFirstChar(V.spaName)}'s ${V.spaDecoration} atmosphere <span class="hotpink">had an impact on`);
 			if (_restedSlaves === 1) {
 				r.push(`${him} while ${he} was`);
@@ -393,4 +434,6 @@ App.EndWeek.dairyReport = function() {
 			r.push(`</span> resting.`);
 		}
 	}
+	App.Events.addNode(el, r, "p", "indent");
+	return el;
 };
-- 
GitLab