From 58a1abf911428cc5beb257d1693fc6a661563181 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Sat, 8 May 2021 12:46:13 +0200
Subject: [PATCH] Fix assignment ency entries snot show in main tabs

---
 .../encyclopediaCommonAssignments.js          | 207 +++++++++++++-----
 src/js/slaveListing.js                        |  20 +-
 2 files changed, 164 insertions(+), 63 deletions(-)

diff --git a/src/gui/Encyclopedia/encyclopediaCommonAssignments.js b/src/gui/Encyclopedia/encyclopediaCommonAssignments.js
index e807677ed46..004c9ea8732 100644
--- a/src/gui/Encyclopedia/encyclopediaCommonAssignments.js
+++ b/src/gui/Encyclopedia/encyclopediaCommonAssignments.js
@@ -1,5 +1,148 @@
 /* TODO: add entries for Nursery */
 
+App.Encyclopedia.Assignments = {
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	attendingClasses() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Attending classes"),
+			" is an assignment which educates the slave, raising intelligence if possible. Being educated raises value and is useful for some jobs and leadership positions."
+		);
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	confinement() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Confinement"),
+			" is an assignment which accelerates breaking for disobedient slaves. If a slave isn't obedient enough to work and isn't ",
+			App.Encyclopedia.Dialog.linkDOM("unhealthy", "Health"),
+			" enough to need rest, this will make them useful sooner."
+		);
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	fucktoy() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Fucktoy service"),
+			" is an assignment which keeps the slave close and under the player's eye. It's mostly just for fun, but fucktoys can improve reputation based on their beauty, and the player character's attention can be targeted to areas of the slave's body with possible fetish effects on happy slaves."
+		);
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	gloryHole() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Occupying a glory hole"),
+			" is an assignment which makes money off of slaves regardless of their beauty, skills, or feelings; it's not fun or ",
+			App.Encyclopedia.Dialog.linkDOM("healthy", "Health"),
+			" but very powerful for extracting ¤ out of otherwise useless slaves."
+		);
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	milking() {
+		const fragment = document.createDocumentFragment();
+
+		fragment.append(
+			App.Encyclopedia.topic("Getting milked"),
+			" is an assignment which makes money from lactation based on a slave's breasts, ",
+			App.Encyclopedia.Dialog.linkDOM("health", "Health"),
+			" and hormonal status."
+		);
+		if (V.seeDicks > 0) {
+			fragment.append(" Cows with balls will also give semen.");
+		}
+		fragment.append(` Creates profit quickly from slaves with big tits${V.seeDicks ? " or balls" : ""}.`);
+
+		return fragment;
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	farming() {
+		const fragment = document.createDocumentFragment();
+		fragment.append(
+			App.Encyclopedia.topic("Farming"),
+			" is an assignment which produces ",
+			App.Encyclopedia.Dialog.linkDOM("food", "Food"),
+			" from your slaves' hard work"
+		);
+		if (V.seeBestiality) {
+			fragment.append(" and allows you to breed slaves with animals");
+		}
+		fragment.append(
+			". Can also reduce arcology upkeep with upgrades in the ",
+			App.Encyclopedia.Dialog.linkDOM("Farmyard", "Farmyard")
+		);
+		return fragment;
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	publicService() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Public Service"),
+			" is an assignment which increases reputation based on a slave's beauty, sexual appeal, and skills. Very similar to whoring, but for reputation rather than money."
+		);
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	rest() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Rest"),
+			" is an assignment mostly used to improve ",
+			App.Encyclopedia.Dialog.linkDOM("health", "Health"),
+			". It can be useful to order slaves you wish to intensively modify to rest, since most modifications damage health. It will synergize with curative treatments, providing bonus healing when both are simultaneously applied."
+		);
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	sexualServitude() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Sexual servitude"),
+			" is an assignment which pleases other slaves by forcing the slave to service them sexually. Useful for driving the targeted slave's ",
+			App.Encyclopedia.Dialog.linkDOM("devotion", "Devotion"),
+			" up quickly."
+		);
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	servitude() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Servitude"),
+			" is an assignment which reduces your upkeep based on the slave's ",
+			App.Encyclopedia.Dialog.linkDOM("devotion", "Devotion"),
+			" Available at lower obedience than other jobs, is insensitive to the quality of a slave's body, and doesn't require skills; a good transitional assignment. Unusually, low sex drive is advantageous as a servant, since it reduces distraction. Lactating slaves are slightly better at this job, since they can contribute to their fellow slaves' nutrition."
+		);
+	},
+
+	/**
+	 * @returns {DocumentFragment}
+	 */
+	whoring() {
+		return App.UI.DOM.combineNodes(
+			App.Encyclopedia.topic("Whoring"),
+			" is an assignment which makes money based on a slave's beauty, sexual appeal, and skills. Good whores take a long time to train and beautify but become very profitable."
+		);
+	}
+};
+
 App.Encyclopedia.addArticle("Slave Assignments", function() {
 	const frag = new DocumentFragment();
 	const r = [];
@@ -15,8 +158,7 @@ App.Encyclopedia.addArticle("Slave Assignments", function() {
 App.Encyclopedia.addArticle("Attending Classes", function() {
 	const frag = new DocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Attending classes"));
-	r.push("is an assignment which educates the slave, raising intelligence if possible. Being educated raises value and is useful for some jobs and leadership positions.");
+	r.push(App.Encyclopedia.Assignments.attendingClasses());
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Schoolroom", "Schoolroom")),
 		"note"));
@@ -27,10 +169,7 @@ App.Encyclopedia.addArticle("Attending Classes", function() {
 App.Encyclopedia.addArticle("Confinement", function() {
 	const frag = new DocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Confinement"));
-	r.push("is an assignment which accelerates breaking for disobedient slaves. If a slave isn't obedient enough to work and isn't");
-	r.push(App.Encyclopedia.Dialog.linkDOM("unhealthy", "Health"));
-	r.push("enough to need rest, this will make them useful sooner.");
+	r.push(App.Encyclopedia.Assignments.confinement());
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Cellblock", "Cellblock")),
 		"note"));
@@ -41,8 +180,7 @@ App.Encyclopedia.addArticle("Confinement", function() {
 App.Encyclopedia.addArticle("Fucktoy", function() {
 	const frag = new DocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Fucktoy service"));
-	r.push("is an assignment which keeps the slave close and under the player's eye. It's mostly just for fun, but fucktoys can improve reputation based on their beauty, and the player character's attention can be targeted to areas of the slave's body with possible fetish effects on happy slaves.");
+	r.push(App.Encyclopedia.Assignments.fucktoy());
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Master Suite", "Master Suite")),
 		"note"));
@@ -53,10 +191,7 @@ App.Encyclopedia.addArticle("Fucktoy", function() {
 App.Encyclopedia.addArticle("Glory Hole", function() {
 	const frag = new DocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Occupying a glory hole"));
-	r.push("is an assignment which makes money off of slaves regardless of their beauty, skills, or feelings; it's not fun or");
-	r.push(App.Encyclopedia.Dialog.linkDOM("healthy", "Health"));
-	r.push("but very powerful for extracting ¤ out of otherwise useless slaves.");
+	r.push(App.Encyclopedia.Assignments.gloryHole());
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Arcade", "Arcade")),
 		"note"));
@@ -68,14 +203,7 @@ App.Encyclopedia.addArticle("Milking", function() {
 	const frag = document.createDocumentFragment();
 	const r = [];
 
-	r.push(App.Encyclopedia.topic("Getting milked"));
-	r.push("is an assignment which makes money from lactation based on a slave's breasts,");
-	r.push(App.Encyclopedia.Dialog.linkDOM("health", "Health"));
-	r.push("and hormonal status.");
-	if (V.seeDicks > 0) {
-		r.push("Cows with balls will also give semen.");
-	}
-	r.push(`Creates profit quickly from slaves with big tits${V.seeDicks ? " or balls" : ""}.`);
+	r.push(App.Encyclopedia.Assignments.milking());
 
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Dairy", "Dairy")),
@@ -87,17 +215,7 @@ App.Encyclopedia.addArticle("Milking", function() {
 App.Encyclopedia.addArticle("Farming", function() {
 	const frag = document.createDocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Farming"));
-	r.push("is an assignment which produces");
-	r.push(App.Encyclopedia.Dialog.linkDOM("food", "Food"));
-	r.push("from your slaves' hard work");
-
-	if (V.seeBestiality) {
-		r.push("and allows you to breed slaves with animals");
-	}
-	r.push(`${r.pop()}.`);
-	r.push("Can also reduce arcology upkeep with upgrades in the ");
-	r.push(App.Encyclopedia.Dialog.linkDOM("Farmyard", "Farmyard"));
+	r.push(App.Encyclopedia.Assignments.farming());
 
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Farmyard", "Farmyard")),
@@ -109,8 +227,7 @@ App.Encyclopedia.addArticle("Farming", function() {
 App.Encyclopedia.addArticle("Public Service", function() {
 	const frag = new DocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Public Service"));
-	r.push("is an assignment which increases reputation based on a slave's beauty, sexual appeal, and skills. Very similar to whoring, but for reputation rather than money.");
+	r.push(App.Encyclopedia.Assignments.publicService());
 
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Club", "Club")),
@@ -122,10 +239,7 @@ App.Encyclopedia.addArticle("Public Service", function() {
 App.Encyclopedia.addArticle("Rest", function() {
 	const frag = new DocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Rest"));
-	r.push("is an assignment mostly used to improve");
-	r.push(App.UI.DOM.combineNodes(App.Encyclopedia.Dialog.linkDOM("health", "Health"), "."));
-	r.push("It can be useful to order slaves you wish to intensively modify to rest, since most modifications damage health. It will synergize with curative treatments, providing bonus healing when both are simultaneously applied.");
+	r.push(App.Encyclopedia.Assignments.rest());
 
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facilities: ", App.Encyclopedia.Dialog.linkDOM("Spa", "Spa"),
@@ -135,24 +249,12 @@ App.Encyclopedia.addArticle("Rest", function() {
 	return frag;
 }, "assignmentCommon");
 
-App.Encyclopedia.addArticle("Sexual Servitude", function() {
-	const frag = new DocumentFragment();
-	const r = [];
-	r.push(App.Encyclopedia.topic("Sexual servitude"));
-	r.push("is an assignment which pleases other slaves by forcing the slave to service them sexually. Useful for driving the targeted slave's");
-	r.push(App.Encyclopedia.Dialog.linkDOM("devotion", "Devotion"));
-	r.push("up quickly.");
-	frag.append(...App.Events.spaceSentences(r));
-	return frag;
-}, "assignmentCommon");
+App.Encyclopedia.addArticle("Sexual Servitude", App.Encyclopedia.Assignments.servitude, "assignmentCommon");
 
 App.Encyclopedia.addArticle("Servitude", function() {
 	const frag = new DocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Servitude"));
-	r.push("is an assignment which reduces your upkeep based on the slave's");
-	r.push(App.Encyclopedia.Dialog.linkDOM("devotion", "Devotion"));
-	r.push("Available at lower obedience than other jobs, is insensitive to the quality of a slave's body, and doesn't require skills; a good transitional assignment. Unusually, low sex drive is advantageous as a servant, since it reduces distraction. Lactating slaves are slightly better at this job, since they can contribute to their fellow slaves' nutrition.");
+	r.push(App.Encyclopedia.Assignments.servitude());
 
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Servants' Quarters", "Servants' Quarters")),
@@ -164,8 +266,7 @@ App.Encyclopedia.addArticle("Servitude", function() {
 App.Encyclopedia.addArticle("Whoring", function() {
 	const frag = new DocumentFragment();
 	const r = [];
-	r.push(App.Encyclopedia.topic("Whoring"));
-	r.push("is an assignment which makes money based on a slave's beauty, sexual appeal, and skills. Good whores take a long time to train and beautify but become very profitable.");
+	r.push(App.Encyclopedia.Assignments.whoring());
 
 	r.push(App.UI.DOM.makeElement("span",
 		App.UI.DOM.combineNodes("Associated facility: ", App.Encyclopedia.Dialog.linkDOM("Brothel", "Brothel")),
diff --git a/src/js/slaveListing.js b/src/js/slaveListing.js
index 19c6fed698a..30a4ad03b87 100644
--- a/src/js/slaveListing.js
+++ b/src/js/slaveListing.js
@@ -912,36 +912,36 @@ App.UI.SlaveList.penthousePage = function() {
 		if (V.showTipsFromEncy) {
 			switch (jn) {
 				case "rest":
-					span.append(App.Encyclopedia.renderArticle("rest"));
+					span.append(App.Encyclopedia.Assignments.rest());
 					break;
 				case "chooseOwn":
 					break; /* no entry written for choose own */
 				case "fucktoy":
-					span.append(App.Encyclopedia.renderArticle("fucktoy"));
+					span.append(App.Encyclopedia.Assignments.fucktoy());
 					break;
 				case "classes":
-					span.append(App.Encyclopedia.renderArticle("attendingClasses"));
+					span.append(App.Encyclopedia.Assignments.attendingClasses());
 					break;
 				case "houseServant":
-					span.append(App.Encyclopedia.renderArticle("servitude"));
+					span.append(App.Encyclopedia.Assignments.servitude());
 					break;
 				case Job.WHORE:
-					span.append(App.Encyclopedia.renderArticle("whoring"));
+					span.append(App.Encyclopedia.Assignments.whoring());
 					break;
 				case "publicServant":
-					span.append(App.Encyclopedia.renderArticle("publicService"));
+					span.append(App.Encyclopedia.Assignments.publicService());
 					break;
 				case "subordinateSlave":
-					span.append(App.Encyclopedia.renderArticle("sexualServitude"));
+					span.append(App.Encyclopedia.Assignments.sexualServitude());
 					break;
 				case "cow":
-					span.append(App.Encyclopedia.renderArticle("milking"));
+					span.append(App.Encyclopedia.Assignments.milking());
 					break;
 				case "gloryhole":
-					span.append(App.Encyclopedia.renderArticle("gloryHole"));
+					span.append(App.Encyclopedia.Assignments.gloryHole());
 					break;
 				case "confinement":
-					span.append(App.Encyclopedia.renderArticle("confinement"));
+					span.append(App.Encyclopedia.Assignments.confinement());
 					break;
 				default:
 					span.append(App.UI.DOM.makeElement("span", "missing tip for this tab", "error"));
-- 
GitLab