From 41281895c77c489f64362f0a883e8fb2621d8d38 Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Fri, 31 Jan 2020 17:16:14 -0500
Subject: [PATCH] tired work

---
 src/endWeek/healthFunctions.js              | 34 +++++++++++
 src/endWeek/saStayConfined.js               | 64 +++++++++++++++------
 src/init/storyInit.tw                       |  1 +
 src/js/assignJS.js                          |  1 +
 src/uncategorized/BackwardsCompatibility.tw |  3 +
 src/uncategorized/cellblockReport.tw        |  7 ++-
 src/uncategorized/saRecruitGirls.tw         | 42 ++++++++++++--
 src/uncategorized/saRules.tw                |  1 +
 8 files changed, 129 insertions(+), 24 deletions(-)

diff --git a/src/endWeek/healthFunctions.js b/src/endWeek/healthFunctions.js
index d9015048d43..0498c832510 100644
--- a/src/endWeek/healthFunctions.js
+++ b/src/endWeek/healthFunctions.js
@@ -373,6 +373,12 @@ window.tired = function tired(slave) {
 			assignment -= 40; // Major tired reduction due to a solid week of rest
 		} else if (["guard you", "be the Attendant", "be the Matron", "be the Stewardess", "be the Milkmaid", "be the Farmer", "be the DJ", "be the Madam", "be the Schoolteacher", "be the Wardeness", "be the Nurse", "be your Head Girl"].includes(slave.assignment)) { // Heads are very busy, but always have luxurious conditions, so it balances out, save for the two exceptions
 			assignment += 15;
+		} else if (["recruit girls"].includes(slave.assignment)) {
+			if (H.tired > 80) { // I'll take it easy a week to better recruit the next. 
+				assignment -= 20;
+			} else {
+				assignment += 10;
+			}
 		} else if (["get milked"].includes(slave.assignment)) {
 			if (slave.devotion > 20) {
 				assignment += 2;
@@ -391,6 +397,34 @@ window.tired = function tired(slave) {
 					assignment += 5;
 				}
 			}
+		} else if (["be confined in the cellblock", "stay confined"].includes(slave.assignment)) { // Generally not tiring unless a Wardeness is present, in which case she uses sleep deprivation to break slaves.
+			if (slave.assignment === "be confined in the cellblock" && V.Wardeness !== 0 && slave.fetish !== "mindbroken") {
+				if (V.Wardeness.fetish === "mindbroken") {
+					if (H.tired > 80) {
+						assignment -= 8;
+					} else {
+						assignment += 40;
+					}
+				} else if (V.Wardeness.sexualFlaw === "caring") {
+					assignment += 5;
+				} else if (V.Wardeness.sexualFlaw === "malicious" || V.Wardeness.sexualFlaw === "abusive") {
+					if (H.condition > 20) {
+						assignment += 40;
+					} else if (H.tired > 80) {
+						assignment -= 8;
+					} else {
+						assignment += 20;
+					}
+				} else if (H.tired > 50) {
+					assignment -= 8;
+				} else if (H.tired <= 30) {
+					assignment += 33;
+				} else {
+					assignment += 20;
+				}
+			} else {
+				assignment -= 8;
+			}
 		} else if (["be confined in the arcade"].includes(slave.assignment)) { // Brutal assignments
 			// assignment += 50; // We should have a safeguard in place to prevent slave health meltdown while contained in the machine
 		} else if (["work a glory hole", "work as a farmhand"].includes(slave.assignment)) { // Hard assignments
diff --git a/src/endWeek/saStayConfined.js b/src/endWeek/saStayConfined.js
index 4a1453a591b..3c8cd5d9911 100644
--- a/src/endWeek/saStayConfined.js
+++ b/src/endWeek/saStayConfined.js
@@ -45,10 +45,7 @@ window.saStayConfined = function saStayConfined(slave) {
 			}
 		}
 
-		t += ` The stress of confinement <span class="red">damages ${his} health.</span>`;
-		healthDamage(slave, 10);
-
-		if (slave.health.illness > 0 || slave.health.tired > 60) {
+		if (slave.health.illness > 0) {
 			t += ` ${He} is<span class="red">`;
 			if (slave.health.illness === 1) {
 				t += ` feeling under the weather`;
@@ -61,28 +58,57 @@ window.saStayConfined = function saStayConfined(slave) {
 			} else if (slave.health.illness === 5) {
 				t += ` terribly ill`;
 			}
-			if (slave.health.illness > 0 && slave.health.tired > 60) {
-				t += ` and`;
+			t += `,</span> so ${his} misery only grows.`;
+		}
+		if (slave.assignment === "be confined in the cellblock" && V.Wardeness !== 0) {
+			t += ` The stress of confinement <span class="red">damages ${his} health.</span> ${V.Wardeness.slaveName}`;
+			if (V.Wardeness.fetish === "mindbroken") {
+				if (H.tired > 80) {
+					t += `'s empty mind often overlooks ${him} when ${he} falls inert from exhaustion, giving ${him} <span class="green">a much needed chance to rest.</span>`;
+				} else {
+					t += `'s empty mind is void of mercy; This broken Wardeness sees <span class="red">no need for breaks nor rest.</span>`;
+				}
+			} else if (V.Wardeness.sexualFlaw === "caring") {
+				t += ` is too caring and has to focus on not coddling ${him}.`;
+			} else if (V.Wardeness.sexualFlaw === "malicious" || V.Wardeness.sexualFlaw === "abusive") {
+				if (H.condition > 20) {
+					t += ` enjoys <span class="red">depriving ${him} of sleep and watching ${him} succumb to fatigue.</span>`;
+				} else if (H.tired > 80) {
+					t += ` knows better than to let ${him} become dangerously exhausted in ${his} condition.`;
+				} else {
+					t += ` enjoys <span class="red">depriving ${him} of sleep,</span> leaving ${him} vulnerable.`;
+				}
+			} else if (H.tired > 50) {
+				t += ` allots ${him} <span class="green">time to sleep</span> in an effort to prevent exhaustion from interrupting ${his} efforts.`;
+			} else if (H.tired <= 30) {
+				t += ` welcomes ${him} to ${V.cellblockName} by <span class="yellow">denying ${him} sleep</span> until ${he} is nice and pliable.`;
+			} else {
+				t += ` makes sure to <span class="yellow">deny ${him} sleep</span> to keep ${him} pliable.`;
 			}
-			if (slave.health.tired > 90) {
-				t += ` exhausted`;
-			} else if (slave.health.tired > 60) {
-				t += ` tired`;
+		} else {
+			t += ` The stress of confinement <span class="red">damages ${his} health`;
+			if (slave.health.tired > 30) {
+				t += `,</span> but the isolation gives ${his} tired body a chance to rest.`;
+			} else {
+				t += `.</span>`;
 			}
-			t += `,</span> so ${his} misery only grows.`;
 		}
+		healthDamage(slave, 10);
 	} else {
 		t += `is oblivious to ${his} confinement.`;
 	}
+	tired(slave);
 
-	if (V.Wardeness !== 0 && (V.Wardeness.sexualFlaw === "malicious" || V.Wardeness.sexualFlaw === "abusive" || V.Wardeness.sexualFlaw === "breast growth") && slave.lactation === 1 && slave.lactationDuration === 0) {
-		t += ` ${V.Wardeness.slaveName} `;
-		if (V.Wardeness.sexualFlaw === "malicious") {
-			t += `savors the torment brought about by ${his} milk-bloated chest and makes sure to milk ${him} thoroughly every other week to maximize ${his} suffering.`;
-		} else if (V.Wardeness.sexualFlaw === "abusive") {
-			t += `enjoys neglecting ${his} milk-bloated chest until it gets big and painfully swollen; only then does the abusive jail-keeper roughly drain ${his} sensitive mounds.`;
-		} else if (V.Wardeness.sexualFlaw === "breast growth") {
-			t += `loves watching ${his} breasts steadily swell with pent-up milk and only milks ${him} in order to reset the process.`;
+	if (slave.assignment === "be confined in the cellblock" && V.Wardeness !== 0) {
+		if ((V.Wardeness.sexualFlaw === "malicious" || V.Wardeness.sexualFlaw === "abusive" || V.Wardeness.sexualFlaw === "breast growth") && slave.lactation === 1 && slave.lactationDuration === 0) {
+			t += ` ${V.Wardeness.slaveName} `;
+			if (V.Wardeness.sexualFlaw === "malicious") {
+				t += `savors the torment brought about by ${his} milk-bloated chest and makes sure to milk ${him} thoroughly every other week to maximize ${his} suffering.`;
+			} else if (V.Wardeness.sexualFlaw === "abusive") {
+				t += `enjoys neglecting ${his} milk-bloated chest until it gets big and painfully swollen; only then does the abusive jail-keeper roughly drain ${his} sensitive mounds.`;
+			} else if (V.Wardeness.sexualFlaw === "breast growth") {
+				t += `loves watching ${his} breasts steadily swell with pent-up milk and only milks ${him} in order to reset the process.`;
+			}
 		}
 	}
 
diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw
index 88fa2fcd158..ac2bef19a03 100644
--- a/src/init/storyInit.tw
+++ b/src/init/storyInit.tw
@@ -912,6 +912,7 @@ You should have received a copy of the GNU General Public License along with thi
 <<set $recruiterProgress = 0>>
 <<set $recruiterIdleRule = "number">>
 <<set $recruiterIdleNumber = 20>>
+<<set $recruiterIOUs = 0>>
 <<set $bodyguardTrains = 1>>
 <<set $Bodyguard = 0>>
 <<set $Madam = 0>>
diff --git a/src/js/assignJS.js b/src/js/assignJS.js
index 6794fb1a765..1c82c12ddb3 100644
--- a/src/js/assignJS.js
+++ b/src/js/assignJS.js
@@ -457,6 +457,7 @@ window.removeJob = function removeJob(slave, assignment) {
 			V.HeadGirl = 0;
 		} else if (V.Recruiter !== 0 && slave.ID === V.Recruiter.ID) {
 			V.Recruiter = 0;
+			V.recruiterIOUs = 0;
 		} else if (V.Bodyguard !== 0 && slave.ID === V.Bodyguard.ID) {
 			V.Bodyguard = 0;
 		} else if (V.Madam !== 0 && slave.ID === V.Madam.ID) {
diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw
index eaeb570ef8f..9f2b02ccead 100644
--- a/src/uncategorized/BackwardsCompatibility.tw
+++ b/src/uncategorized/BackwardsCompatibility.tw
@@ -185,6 +185,9 @@
 <<if ndef $bodyguardTrains>>
 	<<set $bodyguardTrains = 1>>
 <</if>>
+<<if ndef $recruiterIOUs>>
+	<<set $recruiterIOUs = 0>>
+<</if>>
 <<if ndef $summaryStats>>
 	<<set $summaryStats = 0>>
 <</if>>
diff --git a/src/uncategorized/cellblockReport.tw b/src/uncategorized/cellblockReport.tw
index 66dc0ed1eb7..29d656c411e 100644
--- a/src/uncategorized/cellblockReport.tw
+++ b/src/uncategorized/cellblockReport.tw
@@ -71,9 +71,12 @@
 	<<elseif $Wardeness.energy > 95>>
 		$He is so sexually depraved that $he constantly molests the prisoners, breaking them to a life of servitude.
 	<</if>>
-	<<if $Wardeness.sexualFlaw == "malicious">>
+	<<if $Wardeness.sexualFlaw == "malicious" || $Wardeness.sexualFlaw == "abusive">>
 		<<set _devBonus++, _trustMalus += 2, _idleBonus += 2>>
 		Sexual abuse of prisoners has become an end for $him, not a means. $He inspires $his prisoners to do everything possible to qualify to get away from $him, even as $he slowly grinds away their interest in sex to do it.
+	<<elseif $Wardeness.sexualFlaw == "caring">>
+		<<set _devBonus--, _trustMalus--, _idleBonus-->>
+		$His kindness sometimes shows through $his tough facade, letting prisoners get off easier than they should.
 	<</if>>
 	<<if ($Wardeness.dick > 2) && (canPenetrate($Wardeness))>>
 		<<set _devBonus++, _trustMalus++, _idleBonus++>>
@@ -138,6 +141,7 @@
 		''__@@.pink;<<= SlaveFullName($slaves[$i])>>@@__'' is serving as the Wardeness in $cellblockName.
 		<br>&nbsp;&nbsp;&nbsp;&nbsp;
 		<<= saChoosesOwnClothes($slaves[$i])>>
+		<<run tired($slaves[$i])>>
 		<<include "SA rules">>
 		<<include "SA diet">>
 		<<include "SA long term effects">>
@@ -148,6 +152,7 @@
 	<<else>>
 		<<silently>>
 		<<run saChoosesOwnClothes($slaves[$i])>>
+		<<run tired($slaves[$i])>>
 		<<include "SA rules">>
 		<<include "SA diet">>
 		<<include "SA long term effects">>
diff --git a/src/uncategorized/saRecruitGirls.tw b/src/uncategorized/saRecruitGirls.tw
index 2f806b327d1..bfccd39cdfb 100644
--- a/src/uncategorized/saRecruitGirls.tw
+++ b/src/uncategorized/saRecruitGirls.tw
@@ -30,17 +30,42 @@
 	<<set $slaves[$i].boobs -= $slaves[$i].boobsMilk, $slaves[$i].boobsMilk = 0>>
 <</if>>
 
-<<if $recruiterTarget == "other arcologies">>
+<<run tired($slaves[$i])>>
+
+<<if $slaves[$i].tired > 80>>
+
+	uses the week to recover from fatigue and
+	<<if $recruiterTarget == "other arcologies">>
+		<<set _j = $arcologies.findIndex(function(s) { return s.direction == $arcologies[0].influenceTarget; })>>
+		<<if _j != -1>>
+			better prepare to manipulate $arcologies[_j].name's culture.
+		<<elseif !_influenced>>
+			realize that you have not targeted a neighboring arcology for cultural influence, making $his assignment pointless.
+			<<if $oldRecruiterTarget>>
+				<<set $recruiterTarget = clone($oldRecruiterTarget)>>
+				@@.yellow;$He goes back to recruiting $recruiterTarget.@@
+				<<unset $oldRecruiterTarget>>
+			<</if>>
+		<</if>>
+	<<elseif $slaves.length < _idleTarget>>
+		better prepare to manipulate $recruiterTarget into enslavement.
+	<<else>>
+		prepare methods to better support your cultural directions.
+	<</if>>
+	<<set $recruiterIOUs++>>
+
+<<elseif $recruiterTarget == "other arcologies">>
 
 	<<set _influenced = 0>>
 	<<set _j = $arcologies.findIndex(function(s) { return s.direction == $arcologies[0].influenceTarget; })>>
 	<<if _j != -1>>
-		acting as a sexual Ambassador to $arcologies[_j].name, which mostly means that $he travels there in $his official capacity and has culturally influential sex with its leading citizens.
+		acts as a sexual Ambassador to $arcologies[_j].name, which mostly means that $he travels there in $his official capacity and has culturally influential sex with its leading citizens.
 
 		<<set _oldRepGain = hashSum($lastWeeksRepIncome)>>
 		<<set $pure = 0>>
 		<<run saServeThePublic($slaves[$i])>>
-		<<set _influence = Math.clamp((hashSum($lastWeeksRepIncome)-_oldRepGain)*0.01,1,3)>>
+		<<set _influence = Math.clamp((hashSum($lastWeeksRepIncome)-_oldRepGain)*0.01, 1 ,3+$recruiterIOUs)>>
+		<<set $recruiterIOUs = 0>>
 
 		<<if $arcologies[0].FSSubjugationist != "unset">>
 			<<if ($arcologies[_j].FSSubjugationist != "unset")>>
@@ -307,6 +332,11 @@
 
 	uses your online resources and some @@.yellowgreen;modest funds@@ to convince $recruiterTarget from the old world to immigrate for voluntary enslavement.
 
+	<<if $recruiterIOUs > 0>>
+		<<set $recruiterProgress += $recruiterIOUs>>
+		<<set $recruiterIOUs = 0>>
+	<</if>>
+
 	<<if $slaves[$i].devotion > 95>>
 		$His extreme devotion to you lends $him total cogency.
 		<<set $recruiterProgress += 2>>
@@ -430,7 +460,7 @@
 
 	<<set _seed = 0>>
 	<<set _seed -= (6 - (6*$slaves[$i].skill.entertainment/100))>>
-	<<set _seed -= (3 - $slaves[$i].face)>>
+	<<set _seed -= (3 - (3*$slaves[$i].face/100)>>
 	<<if $slaves[$i].intelligence+$slaves[$i].intelligenceImplant < -15>>
 		<<set _seed = Math.min(_seed, ($slaves[$i].intelligence+$slaves[$i].intelligenceImplant)/10)>>
 	<</if>>
@@ -479,6 +509,10 @@
 	<<if $studio && $slaves[$i].porn.viewerCount >= 10000 && $slaves[$i].porn.prestige > 0>>
 		<<set _seed += $slaves[$i].porn.prestige*3>>
 	<</if>>
+	<<if $recruiterIOUs > 0>>
+		<set _seed += $recruiterIOUs, _FSdefend += $recruiterIOUs>>
+		<<set $recruiterIOUs = 0>>
+	<</if>>
 
 	<<if $arcologies[0].FSSupremacist != "unset">>
 		<<if $slaves[$i].intelligence+$slaves[$i].intelligenceImplant > 50>>
diff --git a/src/uncategorized/saRules.tw b/src/uncategorized/saRules.tw
index d7798f3448f..1b6ea2a3158 100644
--- a/src/uncategorized/saRules.tw
+++ b/src/uncategorized/saRules.tw
@@ -1581,6 +1581,7 @@
 
 			$He is @@.hotpink;very happy@@ with $his private room in $cellblockName and @@.mediumaquamarine;trusts@@ you a bit more for placing $him in charge of it.
 			<<set $slaves[$i].devotion += 1, $slaves[$i].trust += 1>>
+			It also helps to offset the tiring nature of $his position.
 
 			<<if ($slaves[$i].attrKnown == 0)>>
 				<<if ($week-$slaves[$i].weekAcquired > 4) && $slaves[$i].energy > 20>>
-- 
GitLab