From b8c99a05ed0c0695a16195a278ad45bd319e1330 Mon Sep 17 00:00:00 2001
From: DCoded <dsoloha@live.com>
Date: Thu, 27 Jun 2019 10:55:37 -0400
Subject: [PATCH] Got saNanny stable, fixes

---
 src/endWeek/saNanny.js                   | 175 ++++++++++++++++++++++-
 src/facilities/nursery/nurseryWidgets.js |  57 ++++----
 2 files changed, 195 insertions(+), 37 deletions(-)

diff --git a/src/endWeek/saNanny.js b/src/endWeek/saNanny.js
index b6cd98d152f..67c92d5be78 100644
--- a/src/endWeek/saNanny.js
+++ b/src/endWeek/saNanny.js
@@ -4,16 +4,177 @@
  */
 window.saNanny = function saNanny(slave) {
 	"use strict";
-	const V = State.variables;
-	const {
+	const V = State.variables,
+	{
 		he, him, his, hers, himself, boy, He, His
-		} = getPronouns(slave);
+	} = getPronouns(slave);
 
-	let t = `works as a nanny this week. `;
+		let t = `works as a nanny. ${He} ${V.nurseryBabies ? `looks after the child${V.nurseryBabies > 0 ? `ren` : ``} in ${V.nurseryName}, ensuring their needs are met and that they are being raised as ${V.nurseryBabies === 1 ? `a good future slave` : `good future slaves`}. ` : `keeps ${V.nurseryName} neat and tidy for the children it will one day support`}. `;
 
-	if (V.Matron) {
-		t += `effects here`;
-	}
+		// TODO:
+		t += ` ${He} is `;
+		if (slave.trust < -20) {
+			t += `frightened of punishment and works very hard, <span class="yellowgreen">reducing the upkeep</span> of your slaves.`;
+		} else if (slave.devotion < -20) {
+			if (slave.trust >= 20) {
+				t += `uninterested in doing such work and barely lifts a finger to <span class="yellowgreen">reduce the upkeep</span> of your slaves.`;
+			} else {
+				t += `reluctant, requiring your other slaves to force ${his} services, and does not <span class="yellowgreen">reduce upkeep</span> of your slaves much.`;
+			}
+		} else if (slave.devotion <= 20) {
+			t += `hesitant, requiring your other slaves to demand ${his} services, and only slightly <span class="yellowgreen">reduces upkeep</span> of your slaves.`;
+		} else if (slave.devotion <= 50) {
+			t += `obedient, offering your other slaves ${his} services, and moderately <span class="yellowgreen">reduces the upkeep</span> of your slaves.`;
+		} else if (slave.devotion <= 95) {
+			t += `devoted, happily giving your other slaves ${his} services, and <span class="yellowgreen">reduces the upkeep</span> of your slaves.`;
+		} else {
+			t += `so happy to serve your other slaves that ${he} often sees to their needs before they know they have them, and greatly <span class="yellowgreen">reduces the upkeep</span> of your slaves.`;
+		}
+
+		// TODO:
+		if (slave.releaseRules !== "chastity") {
+			const _oral = jsRandom(5, 10);
+			slave.counter.oral += _oral;
+			V.oralTotal += _oral;
+		}
+
+		// TODO:
+		if (slave.relationship === -2) {
+			t += ` ${He} does ${his} best to perfect your domesticity due to ${his} emotional bond to you.`;
+		} else if (slave.relationship === -3 && slave.devotion > 50) {
+			t += ` ${He} does ${his} very best to be the perfect housewife, making ${him} an outstanding servant.`;
+		}
+
+		// TODO:
+		if (setup.servantCareers.includes(slave.career)) {
+			t += ` ${He} has experience with house keeping from ${his} life before ${he} was a slave, making ${him} more effective.`;
+		} else if (slave.skill.servant >= V.masteredXP) {
+			t += ` ${He} has experience with house keeping from working for you, making ${him} more effective.`;
+		} else {
+			slave.skill.servant += jsRandom(1, Math.ceil((slave.intelligence + slave.intelligenceImplant) / 15) + 8);
+		}
+
+		// TODO:
+		if (slave.fetishStrength > 60) {
+			if (slave.fetish === "submissive" && slave.fetishKnown === 1) {
+				t += ` ${His} natural affinity for submission increases ${his} effectiveness.`;
+			} else if (slave.fetishKnown === 1 && slave.fetish === "dom") {
+				t += ` ${His} sexual appetite for domination reduces ${his} effectiveness.`;
+			}
+		}
+		// TODO:
+		if (slave.energy < 20) {
+			t += ` ${His} frigidity allows ${him} to ignore the intercourse all around ${him}, making ${him} very efficient.`;
+		} else if (slave.energy < 40) {
+			t += ` ${His} low sex drive keeps ${him} from becoming too distracted by the intercourse all around ${him}, making ${him} more efficient.`;
+		}
+		// TODO:
+		if ((slave.eyes <= -1 && slave.eyewear !== "corrective glasses" && slave.eyewear !== "corrective contacts") || (slave.eyewear === "blurring glasses") || (slave.eyewear === "blurring contacts")) {
+			t += ` ${His} bad vision makes ${him} a worse servant.`;
+		}
+
+		// if (V.showVignettes === 1 && (slave.assignment === Job.NANNY)) {
+		// 	const vignette = GetVignette(slave);
+		// 	t += ` <u>This week</u> ${vignette.text} `;
+		// 	if (vignette.type === "cash") {
+		// 		let modifier = FResult(slave);
+		// 		if (vignette.effect > 0) {
+		// 			t += `<span class="yellowgreen">making you an extra ${cashFormat(Math.trunc(modifier * vignette.effect))}.</span>`;
+		// 		} else if (vignette.effect < 0) {
+		// 			t += `<span class="red">losing you ${cashFormat(Math.abs(Math.trunc(modifier * vignette.effect)))}.</span>`;
+		// 		} else {
+		// 			t += `an incident without lasting effect.`;
+		// 		}
+		// 		cashX(Math.trunc(modifier * vignette.effect), "houseServant", slave);
+		// 	} else if (vignette.type === "devotion") {
+		// 		if (vignette.effect > 0) {
+		// 			if (slave.devotion > 50) {
+		// 				t += `<span class="hotpink">increasing ${his} devotion to you.</span>`;
+		// 			} else if (slave.devotion >= -20) {
+		// 				t += `<span class="hotpink">increasing ${his} acceptance of you.</span>`;
+		// 			} else if (slave.devotion > -10) {
+		// 				t += `<span class="hotpink">reducing ${his} dislike of you.</span>`;
+		// 			} else {
+		// 				t += `<span class="hotpink">reducing ${his} hatred of you.</span>`;
+		// 			}
+		// 		} else if (vignette.effect < 0) {
+		// 			if (slave.devotion > 50) {
+		// 				t += `<span class="mediumorchid">reducing ${his} devotion to you.</span>`;
+		// 			} else if (slave.devotion >= -20) {
+		// 				t += `<span class="mediumorchid">reducing ${his} acceptance of you.</span>`;
+		// 			} else if (slave.devotion > -10) {
+		// 				t += `<span class="mediumorchid">increasing ${his} dislike of you.</span>`;
+		// 			} else {
+		// 				t += `<span class="mediumorchid">increasing ${his} hatred of you.</span>`;
+		// 			}
+		// 		} else {
+		// 			t += `an incident without lasting effect.`;
+		// 		}
+		// 		slave.devotion += (1 * vignette.effect);
+		// 	} else if (vignette.type === "trust") {
+		// 		if (vignette.effect > 0) {
+		// 			if (slave.trust > 20) {
+		// 				t += `<span class="mediumaquamarine">increasing ${his} trust in you.</span>`;
+		// 			} else if (slave.trust > -10) {
+		// 				t += `<span class="mediumaquamarine">reducing ${his} fear of you.</span>`;
+		// 			} else {
+		// 				t += `<span class="mediumaquamarine">reducing ${his} terror of you.</span>`;
+		// 			}
+		// 		} else if (vignette.effect < 0) {
+		// 			if (slave.trust > 20) {
+		// 				t += `<span class="gold">reducing ${his} trust in you.</span>`;
+		// 			} else if (slave.trust >= -20) {
+		// 				t += `<span class="gold">increasing ${his} fear of you.</span>`;
+		// 			} else {
+		// 				t += `<span class="gold">increasing ${his} terror of you.</span>`;
+		// 			}
+		// 		} else {
+		// 			t += `an incident without lasting effect.`;
+		// 		}
+		// 		slave.trust += (1 * vignette.effect);
+		// 	} else if (vignette.type === "health") {
+		// 		if (vignette.effect > 0) {
+		// 			t += `<span class="green">improving ${his} health.</span>`;
+		// 		} else if (vignette.effect < 0) {
+		// 			t += `<span class="red">affecting ${his} health.</span>`;
+		// 		} else {
+		// 			t += `an incident without lasting effect.`;
+		// 		}
+		// 		slave.health += (2 * vignette.effect);
+		// 	} else {
+		// 		let modifier = FResult(slave);
+		// 		if (vignette.effect > 0) {
+		// 			t += `<span class="green">gaining you a bit of reputation.</span>`;
+		// 		} else if (vignette.effect < 0) {
+		// 			t += `<span class="red">losing you a bit of reputation.</span>`;
+		// 		} else {
+		// 			t += `an incident without lasting effect.`;
+		// 		}
+		// 		repX((modifier * vignette.effect * 0.1), "vignette", slave);
+		// 	}
+		// }
+
+		if (V.Matron) {
+			t += `While there, ${he} benefits from ${V.Matron.slaveName}'s `;
+			if (V.Matron.physicalAge < 21) {
+				t += `youthful energy`;
+			} else {
+				t += `care`;
+			}
+			if (V.Matron.skill.oral) { // TODO: keep this? replace with something else?
+				t += ` and talented tongue`;
+			}
+			t += `. `;
+			if (slave.devotion < V.FarmerDevotionThreshold) {
+				slave.devotion += V.FarmerDevotionBonus;
+			}
+			if (slave.devotion < V.FarmerTrustThreshold) {
+				slave.trust += V.FarmerTrustBonus;
+			}
+			if (slave.health < 100) {
+				slave.health += V.FarmerHealthBonus;
+			}
+		}
 
 	return t;
 };
diff --git a/src/facilities/nursery/nurseryWidgets.js b/src/facilities/nursery/nurseryWidgets.js
index 345bbf9eeef..fa561bdb908 100644
--- a/src/facilities/nursery/nurseryWidgets.js
+++ b/src/facilities/nursery/nurseryWidgets.js
@@ -13046,9 +13046,9 @@ App.Facilities.Nursery.LongChildDescription = function(child) {
 	/* 000-250-006 */
 	if (V.seeImages) {
 		if (V.imageChoice === 1) {
-			r += `<div class="imageRef lrgVector"><div class="mask">&nbsp;</div><<SlaveArt $activeChild 3 0>></div> `;
+			r += `<div class="imageRef lrgVector"><div class="mask">&nbsp;</div>${SlaveArt(child, 3, 0)}</div> `;
 		} else {
-			r += `<div class="imageRef lrgRender"><div class="mask">&nbsp;</div><<SlaveArt $activeChild 3 0>></div> `;
+			r += `<div class="imageRef lrgRender"><div class="mask">&nbsp;</div>${SlaveArt(child, 3, 0)}</div> `;
 		}
 	}
 	/* 000-250-006 */
@@ -16473,7 +16473,7 @@ App.Facilities.Nursery.childrenReport = function childrenReport() {
 
 		if (child.growTime > 0) {
 			child.growTime--;
-			r += `<br><span class="pink">${child.slaveName}</span> is growing steadily. ${He} ${child.growTime <= 0 ? `is <span class="lime">ready for release.</span> ${He} will be ejected from ${his} crib upon your approach` : `will be ready for release in about ${child.growTime} weeks`}.`;
+			r += `<br><span class="pink">${child.slaveName}</span> is growing steadily. ${He} ${child.growTime <= 0 ? `is <span class="lime">ready for release.</span> ${He} will be ejected from ${his} crib upon your approach` : `will be ready for release in about ${child.growTime} weeks`}. `;
 		} else {
 			r += `<span class="pink">${child.slaveName}</span> is <span class="lime">ready for release.</span> ${He} will be removed from ${V.nurseryName} upon your approach.`;
 		}
@@ -16550,7 +16550,6 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 	const
 		V = State.variables,
 		Matron = getSlave(V.Matron.ID),
-		slaves = V.slaves,
 		arcology = V.arcologies[0];
 
 	let
@@ -16560,8 +16559,6 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 		idleBonus = 0,
 		devBonus = 0;
 
-	V.NurseryiIDs = SlaveSort.IDs(V.NurseryiIDs);
-
 	if (V.nurseryDecoration !== "standard") {
 		devBonus = 1;
 	}
@@ -16587,11 +16584,12 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 
 		let FLsFetish = 0;
 
+		// TODO: different fetish?
 		if (Matron.fetishStrength <= 95) {
 			if (Matron.fetish !== "caring") {
-				// if (fetishChangeChance(Matron > jsRandom(0, 100))) {
-				// 	FLsFetish = 1, Matron.fetishKnown = 1, Matron.fetish = "caring";
-				// }
+				if (fetishChangeChance(Matron > jsRandom(0, 100))) {
+					FLsFetish = 1, Matron.fetishKnown = 1, Matron.fetish = "caring";
+				}
 			} else if (!Matron.fetishKnown) {
 				FLsFetish = 1, Matron.fetishKnown = 1;
 			} else {
@@ -16609,10 +16607,10 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 			V.Matron = Matron;
 		}
 
-		r += `&nbsp;&nbsp;&nbsp;&nbsp;${SlaveFullName(Matron)} is serving as ${V.nurseryName} matron.`;
+		r += `&nbsp;&nbsp;&nbsp;&nbsp;${SlaveFullName(Matron)} is serving as ${V.nurseryName} matron. `;
 
 		if (Matron.relationship === -3 && Matron.devotion > 50) {
-			r += `${He} tries ${his} best to ${V.nurseryChildren ? `properly take care of and raise the children` : `look after ${V.nurseryName} and keep it tidy and running smoothly`}.`;
+			r += `${He} tries ${his} best to ${V.nurseryChildren ? `properly take care of and raise the children` : `look after ${V.nurseryName} and keep it tidy and running smoothly`}. `;
 		}
 
 		if (FLsFetish === 1) {
@@ -16622,15 +16620,15 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 		}
 
 		// TODO:
-		// if (setup.matronCareers.includes(Matron.career)) {
-		// 	r += `${He} has experience with childcare from ${his} life before ${he} was a slave, making ${him} better at properly raising children, and giving ${him} a better chance of softening flaws into beneficial quirks. `;
-		// 	idleBonus++;
-		// } else if (Matron.skill.matron >= V.masteredXP) {
-		// 	r += `${He} has experience with childcare from working for you, making ${him} better at properly raising children, and giving ${him} a better chance of softening flaws into beneficial quirks. `;
-		// 	idleBonus++;
-		// } else {
-		// 	Matron.skill.matron += jsRandom(1, (Matron.intelligence + 4) * 2);
-		// }
+		if (setup.matronCareers.includes(Matron.career)) {
+			r += `${He} has experience with childcare from ${his} life before ${he} was a slave, making ${him} better at properly raising children, and giving ${him} a better chance of softening flaws into beneficial quirks. `;
+			idleBonus++;
+		} else if (Matron.skill.matron >= V.masteredXP) {
+			r += `${He} has experience with childcare from working for you, making ${him} better at properly raising children, and giving ${him} a better chance of softening flaws into beneficial quirks. `;
+			idleBonus++;
+		} else {
+			Matron.skill.matron += jsRandom(1, (Matron.intelligence + 4) * 2);
+		}
 
 		// TODO:
 		if (Matron.fetish === "none") {
@@ -16672,7 +16670,7 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 	}
 
 	if (NL > 0) {
-		r += `&nbsp;&nbsp;&nbsp;&nbsp;<strong>${NL > 1 ? `There are ${NL} slaves` : `There is one slave`} working in ${V.nurseryName}.</strong>`;
+		r += `&nbsp;&nbsp;&nbsp;&nbsp;<strong>${NL > 1 ? `There are ${NL} slaves` : `There is one slave`} working in ${V.nurseryName}.</strong> `;
 		if (arcology.FSRepopulationFocus > 0 && V.nurseryBabies > 0) {
 			r += `Society <span class="green">approves</span> of your bringing more children into this world. `;
 		} else if (arcology.FSGenderFundamentalist > 0) {
@@ -16686,7 +16684,7 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 			r += `<br><br>`;
 			/* 000-250-006 */
 			if (V.seeImages && V.seeReportImages) {
-				// r += `<div class="imageRef smlImg"><<SlaveArt ${Matron} 0 0>></div>`;
+				r += `<div class="imageRef smlImg">${SlaveArt(Matron), 0, 0}</div>`;
 			}
 			/* 000-250-006 */
 			r += `<strong><u><span class="pink">${SlaveFullName(Matron)}</span></u></strong> is serving as the Matron in ${V.nurseryName}.
@@ -16715,8 +16713,7 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 
 	for (let dI = 0; dI < NL; dI++) {
 		const
-			slave = slaves[dI];
-			// i = V.slaveIndices[V.NurseryiIDs[dI]],	// FIXME:
+			slave = getSlave(V.NurseryiIDs[dI]);
 
 		slave.devotion += devBonus, slave.trust += trustBonus, slave.health += healthBonus;
 
@@ -16750,20 +16747,20 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 		// TODO:
 		if (V.showEWD) {
 			const
-				He = getPronouns(slave);
+				He = slave.genes === "XX" ? `She` : `He`;
 			r += `<br><br>`;
 			/* 000-250-006 */
 			if (V.seeImages && V.seeReportImages) {
-				// r += `<div class="imageRef smlImg"><<SlaveArt $slaves[${dI}] 0 0>></div>`;
+				r += `<div class="imageRef smlImg">${SlaveArt(slave, 0, 0)}</div>`;
 			}
 			/* 000-250-006 */
-			r += `<strong><u><span class="pink">${SlaveFullName(slaves[dI])}</span></u></strong>`;
+			r += `<strong><u><span class="pink">${SlaveFullName(slave)}</span></u></strong>`;
 			if (slave.choosesOwnAssignment === 2) {
 				r += `<<include "SA chooses own job">>`;
 			} else {
-				r += `is working in ${V.nurseryName}. `;
+				r += ` is working in ${V.nurseryName}. `;
 			}
-			r += `<br>&nbsp;&nbsp;&nbsp;&nbsp;${He} ${saRest(slave)}
+			r += `<br>&nbsp;&nbsp;&nbsp;&nbsp;${He} ${saNanny(slave)}
 			<br>&nbsp;&nbsp;&nbsp;
 			${saChoosesOwnClothes(slave)}
 			<<include "SA rules">>
@@ -16777,7 +16774,7 @@ App.Facilities.Nursery.nurseryReport = function nurseryReport() {
 			r += `<<silently>>
 			<<include "SA chooses own job">>
 			${saChoosesOwnClothes(slave)}
-			${saRest(slave)}
+			${saNanny(slave)}
 			<<include "SA rules">>
 			<<include "SA diet">>
 			<<include "SA long term effects">>
-- 
GitLab