From ee4ce98fc5c0a3a59dd02305f086dfd9eb18650d Mon Sep 17 00:00:00 2001
From: DCoded <dcoded@live.com>
Date: Thu, 18 Jun 2020 23:24:11 -0400
Subject: [PATCH] Misc changes

---
 .../farmyard/reports/farmyardReport.js        | 125 +++++++++---------
 src/facilities/statistics.js                  |   2 +-
 2 files changed, 67 insertions(+), 60 deletions(-)

diff --git a/src/facilities/farmyard/reports/farmyardReport.js b/src/facilities/farmyard/reports/farmyardReport.js
index 7727c0722be..f41d42babc3 100644
--- a/src/facilities/farmyard/reports/farmyardReport.js
+++ b/src/facilities/farmyard/reports/farmyardReport.js
@@ -5,7 +5,6 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 		slaves = App.Utils.sortedEmployees(App.Entity.facilities.farmyard),
 		devBonus = (V.farmyardDecoration !== "standard") ? 1 : 0,
 		Farmer = S.Farmer;
-		// arcology = V.arcologies[0];
 
 	let
 		profits = 0,
@@ -14,7 +13,7 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 
 
 
-	// MARK: FARMER
+	// MARK: Farmer
 
 	function farmerChanges() {
 		farmerHealth(Farmer);
@@ -176,7 +175,6 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 		}
 	};
 
-	/** @param {App.Entity.SlaveState} Farmer */
 	function farmerRelationshipSlaves(Farmer) {
 		const { he, his, He } = getPronouns(Farmer);
 
@@ -275,7 +273,7 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 				App.UI.DOM.appendNewElement("div", farmerEntry, App.Art.SlaveArtElement(Farmer, 0, 0), ["imageRef", "tinyImg"]);
 			}
 
-			$(farmerEntry).append(`<span class="slave-name">${SlaveFullName(Farmer)}</span> is serving as your Matron.`);
+			$(farmerEntry).append(`<span class="slave-name">${SlaveFullName(Farmer)}</span> is serving as the Farmer.`);
 			$(farmerEntry).append(standardSlaveReport(Farmer, false));
 		} else {
 			standardSlaveReport(Farmer, true);
@@ -287,7 +285,7 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 
 
 
-	// MARK: FARMHANDS
+	// MARK: Farmhands
 
 	const farmhandCount = count => {
 		return `<strong>There ${count > 1 ? `are ${count} farmhands` : `is one farmhand`} working out of ${V.farmyardName}.</strong>`;
@@ -330,17 +328,6 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 		}
 	};
 
-	if (slaves) {
-		const
-			intro = App.UI.DOM.appendNewElement("p", frag, '', "indent");
-
-		let r = [];
-
-		r.push(farmhandCount);
-
-		$(intro).append(r);
-	}
-
 	const farmhandProfit = slave => {
 		let incomeStats = getSlaveStatisticData(slave, slave.assignment === Job.FARMYARD ? V.facility.farmyard : undefined);
 		return incomeStats.income;
@@ -358,69 +345,91 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 		return foodWeek;
 	};
 
-	const farmhandTrust = slave => slave.trust < 30 ? slave.trust += 5 : null;
+	const farmhandTrust = slave => {
+		if (slave.trust < 30) {
+			slave.trust += 5;
+		}
+	};
 
-	const farmhandEnergy = slave => slave.energy > 40 && slave.energy < 95 ? slave.energy++ : null;
+	const farmhandEnergy = slave => {
+		if (slave.energy > 40 && slave.energy < 95) {
+			slave.energy++;
+		}
+	};
 
-	for (const slave of slaves) {
-		V.i = V.slaveIndices[slave.ID];
+	if (slaves) {
+		const
+			intro = App.UI.DOM.appendNewElement("p", frag, '', "indent");
 
-		slave.devotion += devBonus;
+		let r = [];
 
-		App.Utils.setLocalPronouns(slave);	// needed for "include"s
+		r.push(farmhandCount);
 
-		if (V.showEWD) {
-			const
-				slaveEntry = App.UI.DOM.appendNewElement("div", frag, '', "slave-report");
+		for (const slave of slaves) {
+			V.i = V.slaveIndices[slave.ID];
 
-			if (V.seeImages && V.seeReportImages) {
-				App.UI.DOM.appendNewElement("div", slaveEntry, App.Art.SlaveArtElement(slave, 0, 0), ["imageRef", "tinyImg"]);
-			}
+			slave.devotion += devBonus;
 
-			$(slaveEntry).append(`<span class="slave-name">${SlaveFullName(slave)}</span> `);
+			App.Utils.setLocalPronouns(slave);	// needed for "include"s
 
-			if (slave.choosesOwnAssignment === 2) {
-				$(slaveEntry).append(App.UI.DOM.renderPassage("SA chooses own job"));
-			} else {
-				$(slaveEntry).append(`is working out of ${V.farmyardName}.`);
-			}
+			if (V.showEWD) {
+				const
+					slaveEntry = App.UI.DOM.appendNewElement("div", frag, '', "slave-report");
 
-			farmhandLivingRules(slave);
-			farmhandHealth(slave);
-			farmhandDevotion(slave);
-			farmhandTrust(slave);
-			farmhandEnergy(slave);
-			farmhandFood(slave);
-			profits += farmhandProfit(slave);
+				if (V.seeImages && V.seeReportImages) {
+					App.UI.DOM.appendNewElement("div", slaveEntry, App.Art.SlaveArtElement(slave, 0, 0), ["imageRef", "tinyImg"]);
+				}
 
-			const
-				{ He } = getPronouns(slave),
-				farmhandContent = App.UI.DOM.appendNewElement("div", slaveEntry, '', "indent");
+				$(slaveEntry).append(`<span class="slave-name">${SlaveFullName(slave)}</span> `);
 
-			$(farmhandContent).append(`${He} ${App.SlaveAssignment.workTheFarm(slave, farmerBonus)}`);
-			$(slaveEntry).append(standardSlaveReport(slave, false));
-		} else {	// silently discard return values
-			App.SlaveAssignment.workTheFarm(slave, farmerBonus);
-			standardSlaveReport(slave, true);
+				if (slave.choosesOwnAssignment === 2) {
+					$(slaveEntry).append(App.UI.DOM.renderPassage("SA chooses own job"));
+				} else {
+					$(slaveEntry).append(`is working out of ${V.farmyardName}.`);
+				}
+
+				farmhandLivingRules(slave);
+				farmhandHealth(slave);
+				farmhandDevotion(slave);
+				farmhandTrust(slave);
+				farmhandEnergy(slave);
+				farmhandFood(slave);
+				profits += farmhandProfit(slave);
+
+				const
+					{ He } = getPronouns(slave),
+					farmhandContent = App.UI.DOM.appendNewElement("div", slaveEntry, '', "indent");
+
+				$(farmhandContent).append(`${He} ${App.SlaveAssignment.workTheFarm(slave, farmerBonus)}`);
+				$(slaveEntry).append(standardSlaveReport(slave, false));
+			} else {	// silently discard return values
+				App.SlaveAssignment.workTheFarm(slave, farmerBonus);
+				standardSlaveReport(slave, true);
+			}
 		}
+
+		$(intro).append(r);
 	}
 
 
 
-	// MARK: MENIALS
+	// MARK: Menials
 
-	if (V.farmMenials > 0) {
+	if (V.farmMenials) {
 		let farmMenialProductivity = 9;
 
 		if (V.farmyardUpgrade.pump) {
 			farmMenialProductivity += 1;
 		}
+
 		if (V.farmyardUpgrade.fertilizer) {
 			farmMenialProductivity += 2;
 		}
+
 		if (V.farmyardUpgrade.seeds) {
 			farmMenialProductivity += 3;
 		}
+
 		if (V.farmyardUpgrade.machinery) {
 			farmMenialProductivity += 3;
 		}
@@ -430,7 +439,7 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 
 
 
-	// MARK: FARMYARD
+	// MARK: Farmyard
 
 	const farmyardStatsRecords = () => {
 		// TODO: check over these setters and remove those we don't need
@@ -501,22 +510,20 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
 		return r;
 	};
 
-
-
-	// MARK: MAIN LOOP (may get rid of this entirely, we'll see)
-
-	// FIXME: necessary?
-	const farmyardStatsDisplay = () => `<<includeDOM App.Facilities.Farmyard.Stats(false)>><<timed 50ms>><<replace #farmyardstats>><<includeDOM App.Facilities.Farmyard.Stats(true)>><</replace>><</timed>>`;
+	// FIXME: no idea what I'm doing here
+	const statsSpan = document.createElement("span");
 
 	farmyardStatsRecords();
 	farmyardProfit(profits, foodWeek);
 	farmyardDecoration();
-	farmyardStatsDisplay();
 
 	V.food += foodWeek;
 
+	frag.append(App.Facilities.Farmyard.Stats(false));
+	statsSpan.append(App.Facilities.Farmyard.Stats(true));
 
 
+	// TODO: move this into seperate file
 	/**
 	 * Generates (and returns if not silent) a standard slave report
 	 * @param {App.Entity.SlaveState} slave
diff --git a/src/facilities/statistics.js b/src/facilities/statistics.js
index 4343717cc4c..84bb43cec59 100644
--- a/src/facilities/statistics.js
+++ b/src/facilities/statistics.js
@@ -507,7 +507,7 @@ App.Facilities.Farmyard.Stats = (function() {
 	const H = new App.Facilities.StatsHelper();
 	const assureList = [ "farmhandIncome", "farmhandCosts", "maintenance", "totalIncome", "totalExpenses", "food", "profit" ];
 
-	/** Generate the arcade statistics table
+	/** Generate the Farmyard statistics table
 	 * @param {boolean} showDetails
 	 * @returns {HTMLElement|DocumentFragment}
 	 */
-- 
GitLab