From 4fcb5da6507b05e82ba04e5e7f0e537a90dcc596 Mon Sep 17 00:00:00 2001
From: DCoded <dcoded@live.com>
Date: Thu, 23 Jul 2020 22:25:48 -0400
Subject: [PATCH] Began refactoring childrenReport

---
 .../nursery/reports/childrenReport.js         | 312 +++++++-----------
 1 file changed, 125 insertions(+), 187 deletions(-)

diff --git a/src/facilities/nursery/reports/childrenReport.js b/src/facilities/nursery/reports/childrenReport.js
index df979406e03..fd4a968a3cc 100644
--- a/src/facilities/nursery/reports/childrenReport.js
+++ b/src/facilities/nursery/reports/childrenReport.js
@@ -5,11 +5,12 @@
 App.Facilities.Nursery.childrenReport = function childrenReport() {
 	const
 		Matron = V.Matron,
+		nannies = App.Utils.sortedEmployees(App.Entity.facilities.nursery),
 		NL = App.Entity.facilities.nursery.employeesIDs().size,
 		CL = V.cribs.length;
 
 	let
-		r = ``;
+		r = [];
 
 	for (const child of V.cribs) {
 		const
@@ -24,79 +25,19 @@ App.Facilities.Nursery.childrenReport = function childrenReport() {
 		// TODO: add Matron and nanny effects
 		if (child.actualAge >= 3) {
 			if (Matron || NL) {
-				let
-					chance = jsRandom(1, 100);
+				let chance = jsRandom(1, 100);
 
 				if (jsDef(Matron)) {
 					if (Matron.fetish !== "none") {
 						if (chance > 90) {
 							if (child.fetish === "none") {
-								// TODO: clean up the following blocks
-								r += `${child.slaveName} has taken a few cues from ${Matron.slaveName}, and `;
-								switch (child.fetish) {
-									case "submissive":
-										r += `is now a submissive`;
-										break;
-									case "cumslut":
-										r += `is now a cumslut`;
-										break;
-									case "humiliation":
-										r += `now has a fetish for humiliation`;
-										break;
-									case "buttslut":
-										r += `is now a buttslut`;
-										break;
-									case "boobs":
-										r += `now has a fetish for boobs and breastplay`;	// TODO: not happy with this wording
-										break;
-									case "sadist":
-										r += `now gets off on causing pain`;
-										break;
-									case "masochist":
-										r += `now gets off on pain`;
-										break;
-									case "dom":
-										r += `is now very sexually dominant`;
-										break;
-									case "pregnancy":
-										r += `has developed a facination for all things pregnancy-related`;
-										break;
-								}
-								r += `. `;
+								r.push(`${child.slaveName} has taken a few cues from ${Matron.slaveName}, and ${newChildFetish(child.fetish)}.`);
+
 								child.fetish = Matron.fetish;
 							} else {
 								if (chance > 95) {
-									r += `${Matron.slaveName} has rubbed off on ${child.slaveName}, in more ways than one. ${He} `;
-									switch (child.fetish) {
-										case "submissive":
-											r += `is now a submissive`;
-											break;
-										case "cumslut":
-											r += `is now a cumslut`;
-											break;
-										case "humiliation":
-											r += `now has a fetish for humiliation`;
-											break;
-										case "buttslut":
-											r += `is now a buttslut`;
-											break;
-										case "boobs":
-											r += `now has a fetish for all things breast-related`;
-											break;
-										case "sadist":
-											r += `now gets off on causing pain`;
-											break;
-										case "masochist":
-											r += `now gets off on pain`;
-											break;
-										case "dom":
-											r += `is now very sexually dominant`;
-											break;
-										case "pregnancy":
-											r += `has developed a facination for all things pregnancy-related`;
-											break;
-									}
-									r += `. `;
+									r.push(`${Matron.slaveName} has rubbed off on ${child.slaveName}, in more ways than one. ${He} ${newChildFetish(child.fetish)}.`);
+
 									child.fetish = Matron.fetish;
 								}
 							}
@@ -104,76 +45,18 @@ App.Facilities.Nursery.childrenReport = function childrenReport() {
 					}
 				}
 
-				if (NL > 0) {
-					for (const slave of App.Utils.sortedEmployees(App.Entity.facilities.nursery)) {
+				if (nannies) {
+					for (const slave of nannies) {
 						if (slave.fetish !== "none") {
 							if (chance > 85) {
 								if (child.fetish === "none") {
-									r += `${slave.slaveName} has left quite an impression on ${child.slaveName}, and ${he} `;
-									switch (child.fetish) {
-										case "submissive":
-											r += `is now a submissive`;
-											break;
-										case "cumslut":
-											r += `is now a cumslut`;
-											break;
-										case "humiliation":
-											r += `now has a fetish for humiliation`;
-											break;
-										case "buttslut":
-											r += `is now a buttslut`;
-											break;
-										case "boobs":
-											r += `now has a fetish for all things breast-related`;
-											break;
-										case "sadist":
-											r += `now gets off on causing pain`;
-											break;
-										case "masochist":
-											r += `now gets off on pain`;
-											break;
-										case "dom":
-											r += `is now very sexually dominant`;
-											break;
-										case "pregnancy":
-											r += `has developed a facination for all things pregnancy-related`;
-											break;
-									}
-									r += `. `;
+									r.push(`${slave.slaveName} has left quite an impression on ${child.slaveName}, and ${he} ${newChildFetish(child.fetish)}.`);
+
 									child.fetish = slave.fetish;
 								} else {
 									if (chance > 90) {
-										r += `${child.slaveName} seems to have taken to ${slave.slaveName}'s example, and `;
-										switch (child.fetish) {
-											case "submissive":
-												r += `is now a submissive`;
-												break;
-											case "cumslut":
-												r += `is now a cumslut`;
-												break;
-											case "humiliation":
-												r += `now has a fetish for humiliation`;
-												break;
-											case "buttslut":
-												r += `is now a buttslut`;
-												break;
-											case "boobs":
-												r += `now has a fetish for all things breast-related`;
-												break;
-											case "sadist":
-												r += `now gets off on causing pain`;
-												break;
-											case "masochist":
-												r += `now gets off on pain`;
-												break;
-											case "dom":
-												r += `is now very sexually dominant`;
-												break;
-											case "pregnancy":
-												r += `has developed a facination for all things pregnancy-related`;
-												break;
-										}
-										r += `. `;
+										r.push(`${child.slaveName} seems to have taken to ${slave.slaveName}'s example, and ${newChildFetish(child.fetish)}.`);
+
 										child.fetish = slave.fetish;
 									}
 								}
@@ -182,65 +65,15 @@ App.Facilities.Nursery.childrenReport = function childrenReport() {
 					}
 				}
 
-				// TODO: add education system
-				if (jsDef(Matron) && Matron) {
-					const {
-						he2, him2, his2, He2
-					} = getPronouns(Matron).appendSuffix('2');
-
-					if (Matron.intelligence + Matron.intelligenceImplant > 65) {
-						r += `${Matron.slaveName} is so intelligent and well-educated that ${he2} is able to teach ${CL > 1 ? `the children` : `${child.slaveName}`} very effectively, and so ${CL > 1 ? child.slaveName : `${he}`} gradually grows smarter. `;	// TODO: not happy with this
-						child.intelligenceImplant += 3;	// TODO: should this raise intelligence instead?
-					} else if (Matron.intelligenceImplant > 30) {
-						r += `${Matron.slaveName}'s education makes up for the fact that ${CL > 1 ? child.slaveName : `${he}`} isn't the brightest and allows ${him2} to teach ${CL > 1 ? `the children` : `${child.slaveName}`} quite effectively, and so ${CL > 1 ? child.slaveName : `${he}`} grows a bit smarter. `;	// TODO:
-						child.intelligenceImplant += 2;
-					} else if (Matron.intelligence > 50) {
-						r += `Though ${Matron.slaveName} has had little to no formal education, ${his2} natural brilliance allows ${him2} to teach ${CL > 1 ? `the children` : `${child.slaveName}`} quite effectively, and so ${CL > 1 ? child.slaveName : `${he}`} grows a bit smarter. `;	// TODO:
-						child.intelligenceImplant += 2;
-					} else {
-						r += `${Matron.slaveName} isn't the brightest, and isn't as effective at teaching as ${he2} otherwise could be. ${He2} is only somewhat effective at teaching ${CL > 1 ? `the children` : `${child.slaveName}`}, and so ${CL > 1 ? child.slaveName : `${he}`} grows just a little bit smarter. `;	// TODO:
-						child.intelligenceImplant++;
-					}
-				}
-
-				if (NL > 0) {
-					let
-						averageIntelligence = 0,
-						averageIntelligenceImplant = 0;
-
-					const nannies = App.Entity.facilities.nursery.employees();
-					for (const nanny of nannies) {
-						averageIntelligence += nanny.intelligence;
-						averageIntelligenceImplant += nanny.intelligenceImplant;
-					}
-
-					const firstNanny = nannies[0];
-
-					averageIntelligence = averageIntelligence / NL;
-					averageIntelligenceImplant = averageIntelligenceImplant / NL;
-
-					if (averageIntelligence + averageIntelligenceImplant > 65) {
-						r += `${NL > 1 ? `The nannies are mostly` : `${firstNanny.slaveName} is`} very intelligent and well educated and are able to teach ${CL > 1 ? `the children` : child.slaveName} very effectively. `;
-						child.intelligenceImplant += 3;
-					} else if (averageIntelligence > 50) {
-						r += `${NL > 1 ? `The nannies are mostly` : `${firstNanny.slaveName} is`} very intelligent and able to teach ${CL > 1 ? `the children` : child.slaveName} quite effectively. `;
-						child.intelligenceImplant += 2;
-					} else if (averageIntelligenceImplant > 25) {
-						r += `${NL > 1 ? `The nannies are mostly` : `${firstNanny.slaveName} is`} very well educated and able to teach ${CL > 1 ? `the children` : child.slaveName} quite effectively. `;
-						child.intelligenceImplant += 2;
-					} else if (averageIntelligenceImplant > 15) {
-						r += `${NL > 1 ? `The nannies are mostly` : `${firstNanny.slaveName} is`} well educated and able to teach ${CL > 1 ? `the children` : child.slaveName} fairly effectively. `;
-						child.intelligenceImplant++;
-					}
-				}
-
-				// TODO: add fitness system
-				if (jsDef(Matron) && Matron) {
-					// TODO:
+				// TODO: expand education system
+				if (Matron) {
+					matronEducationEffects();
+					matronFitnessEffects();
 				}
 
-				if (NL > 0) {
-					// TODO:
+				if (nannies) {
+					nannyEducationEffects();
+					nannyFitnessEffects();
 				}
 			}
 
@@ -379,5 +212,110 @@ App.Facilities.Nursery.childrenReport = function childrenReport() {
 		r += `<br>`;
 	}
 
+	function newChildFetish(fetish = "none") {
+		switch (fetish) {
+			case "submissive":
+				return `is now a submissive`;
+			case "cumslut":
+				return `is now a cumslut`;
+			case "humiliation":
+				return `now has a fetish for humiliation`;
+			case "buttslut":
+				return `is now a buttslut`;
+			case "boobs":
+				return `now has a fetish for all things breast-related`;
+			case "sadist":
+				return `now gets off on causing pain`;
+			case "masochist":
+				return `now gets off on pain`;
+			case "dom":
+				return `is now very sexually dominant`;
+			case "pregnancy":
+				return `has developed a facination for all things pregnancy-related`;
+			default:
+				throw `<span class="red">Something broke in newChildFetish(). Please report this.</span>`;
+		}
+	}
+
+
+
+	// MARK: Matron Effects
+
+	function matronEducationEffects() {
+		const
+			{ he2, him2, his2 } = getPronouns(Matron).appendSuffix('2'),
+
+			theChildren = CL > 1 ? `the children` : `${child.slaveName}`;
+
+		if (Matron.intelligence + Matron.intelligenceImplant > 65) {
+			child.intelligenceImplant += 3;
+
+			return `${Matron.slaveName} is so intelligent and well-educated that ${he2} is able to teach ${theChildren} very effectively, and so ${CL > 1 ? `${child.slaveName} gradually grows` : `they gradually grow`} smarter. `;
+		} else if (Matron.intelligenceImplant > 30) {
+			child.intelligenceImplant += 2;
+
+			return `${Matron.slaveName}'s education makes up for the fact that ${he2} isn't the brightest and allows ${him2} to teach ${theChildren} quite effectively, and so ${theChildren} grows a bit smarter. `;
+		} else if (Matron.intelligence > 50) {
+			child.intelligenceImplant += 2;
+
+			return `Though ${Matron.slaveName} has had little to no formal education, ${his2} natural brilliance allows ${him2} to teach ${theChildren} quite effectively, and so ${CL > 1 ? `${child.slaveName} grows` : `they grow`} a bit smarter. `;
+		} else {
+			child.intelligenceImplant++;
+
+			return `${Matron.slaveName} isn't the brightest and is only somewhat effective at teaching ${theChildren}, so ${CL > 1 ? `${child.slaveName} grows` : `they grow`} just a little bit smarter. `;
+		}
+	}
+
+	function matronFitnessEffects() {
+		// TODO:
+		return;
+	}
+
+
+
+	// MARK: Nanny Effects
+
+	function nannyEducationEffects() {
+		let
+			averageIntelligence = 0,
+			averageIntelligenceImplant = 0;
+
+		for (const nanny of nannies) {
+			averageIntelligence += nanny.intelligence;
+			averageIntelligenceImplant += nanny.intelligenceImplant;
+		}
+
+		const
+			firstNanny = nannies[0],
+			theNanniesAre = NL > 1 ? `The nannies are mostly` : `${firstNanny.slaveName} is`,
+			theChildren = CL > 1 ? `the children` : child.slaveName;
+
+		averageIntelligence = averageIntelligence / NL;
+		averageIntelligenceImplant = averageIntelligenceImplant / NL;
+
+		if (averageIntelligence + averageIntelligenceImplant > 65) {
+			child.intelligenceImplant += 3;
+
+			return `${theNanniesAre} very intelligent and well educated and are able to teach ${theChildren} very effectively. `;
+		} else if (averageIntelligence > 50) {
+			child.intelligenceImplant += 2;
+
+			return `${theNanniesAre} very intelligent and able to teach ${theChildren} quite effectively. `;
+		} else if (averageIntelligenceImplant > 25) {
+			child.intelligenceImplant += 2;
+
+			return `${theNanniesAre} very well educated and able to teach ${theChildren} quite effectively. `;
+		} else if (averageIntelligenceImplant > 15) {
+			child.intelligenceImplant++;
+
+			return `${theNanniesAre} well educated and able to teach ${theChildren} fairly effectively. `;
+		}
+	}
+
+	function nannyFitnessEffects() {
+		// TODO:
+		return;
+	}
+
 	return r;
 };
-- 
GitLab