From b0a49129d05614836e2e15c09fd1f974f52534c1 Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Fri, 23 Oct 2020 13:40:06 -0700
Subject: [PATCH] Arcology management fixes and cleanup, part 4

---
 src/endWeek/economics/arcmgmt.js | 49 +++++++++++---------------------
 1 file changed, 17 insertions(+), 32 deletions(-)

diff --git a/src/endWeek/economics/arcmgmt.js b/src/endWeek/economics/arcmgmt.js
index 1e2d711d7fb..92a80d4db33 100644
--- a/src/endWeek/economics/arcmgmt.js
+++ b/src/endWeek/economics/arcmgmt.js
@@ -2,7 +2,6 @@ globalThis.arcmgmt = function() {
 	const el = new DocumentFragment();
 	let r;
 	let _enslaved;
-	let _weatherFreeze;
 	let _crime;
 	let _terrain;
 	let _transportHub;
@@ -83,11 +82,13 @@ globalThis.arcmgmt = function() {
 
 	citizenToSlave();
 
-	updateWeather();
+	V.GDP = Math.trunc(((V.NPCSlaves + V.menials) * 0.35 * _slaveProductivity) + (V.lowerClass * 0.35) + (V.middleClass * 0.75) + (V.upperClass * 2) + (V.topClass * 10)) / 10;
 
-	/* Bunch of visitor stuff*/
-	if (_weatherFreeze === 0) {
-		weatherFreeze();
+	if (!isFrozen()) {
+		transport();
+	} else {
+		/* enslavement happens even if there's no traffic due to weather */
+		enslavement();
 	}
 
 	V.ASlaves = V.NPCSlaves + V.menials + V.fuckdolls + V.menialBioreactors;
@@ -408,6 +409,7 @@ globalThis.arcmgmt = function() {
 			r.push(`Your impressive reputation relative to ${V.arcologies[0].name}'s prosperity <span class="green">drives an increase in business.</span>`);
 			_AWeekGrowth++;
 		} else if (V.rep > 18000) {
+			/* no growth penalty if PC is at high rep, no matter how high prosperity goes */
 		} else if (V.arcologies[0].prosperity > (V.rep / 60)) {
 			r.push(`Your low reputation relative to ${V.arcologies[0].name}'s prosperity <span class="red">seriously impedes business growth.</span>`);
 			_AWeekGrowth -= 2;
@@ -1412,46 +1414,34 @@ globalThis.arcmgmt = function() {
 		return el;
 	}
 
-	function updateWeather() {
-		/* Bad weather switch*/
+	function isFrozen() {
+		/* during bad weather and without appropriate upgrades, transport (including visitors and immigration/emigration) will be halted */
+		let _weatherFreeze = 0;
 		if (V.weatherToday.severity > 3) {
 			if (V.secExpEnabled > 0 && V.SecExp.buildings.transportHub) {
 				if (V.SecExp.buildings.transportHub.surfaceTransport < 4) {
 					_weatherFreeze = 1;
-					V.weatherAwareness = 1;
 					$(el).append(App.UI.DOM.makeElement("div", `The terrible weather is <span class="red">preventing people from entering or leaving</span> your arcology. Improving your transport infrastructure will prevent this from happening.`, "note"));
-				} else {
-					_weatherFreeze = 0;
 				}
 			} else if (V.antiWeatherFreeze < 2) {
 				_weatherFreeze = 1;
 				$(el).append(App.UI.DOM.makeElement("div", `The terrible weather is <span class="red">preventing people from entering or leaving</span> your arcology. Improving your transport infrastructure will prevent this from happening.`, "note"));
-			} else {
-				_weatherFreeze = 0;
 			}
 		} else if (V.weatherToday.severity > 2) {
 			if (V.secExpEnabled > 0 && V.SecExp.buildings.transportHub) {
 				if (V.SecExp.buildings.transportHub.surfaceTransport < 3) {
 					_weatherFreeze = 1;
 					$(el).append(App.UI.DOM.makeElement("div", `The terrible weather is <span class="red">preventing people from entering or leaving</span> your arcology. Improving your transport infrastructure will prevent this from happening.`, "note"));
-				} else {
-					_weatherFreeze = 0;
 				}
 			} else if (V.antiWeatherFreeze < 1) {
 				_weatherFreeze = 1;
-				V.weatherAwareness = 1;
 				$(el).append(App.UI.DOM.makeElement("div", `The terrible weather is <span class="red">preventing people from entering or leaving</span> your arcology. Improving your transport infrastructure will prevent this from happening.`, "note"));
-			} else {
-				_weatherFreeze = 0;
 			}
-		} else {
-			_weatherFreeze = 0;
 		}
-
-		/* For enslavement that happens despite the weather*/
-		if (_weatherFreeze === 1) {
-			enslavement();
+		if (_weatherFreeze) {
+			V.weatherAwareness = 1;
 		}
+		return _weatherFreeze;
 	}
 
 	function enslavement() {
@@ -1469,7 +1459,7 @@ globalThis.arcmgmt = function() {
 		}
 	}
 
-	function weatherFreeze() {
+	function transport() {
 		_FSScore = _FSScore / V.FSCreditCount;
 		_transportHub = 1;
 		_crime = 0.8;
@@ -1753,21 +1743,16 @@ globalThis.arcmgmt = function() {
 		}
 
 		/* Top Class Citizens*/
-		/* Setting GDP depending on population*/
-		V.GDP = Math.trunc(((V.NPCSlaves + V.menials) * 0.35 * _slaveProductivity) + (V.lowerClass * 0.35) + (V.middleClass * 0.75) + (V.upperClass * 2) + (V.topClass * 10)) / 10;
 		/* Top Class Interest in living in your arcology*/
 		if (V.eliteFailTimer > 0) {
 			/* when you fail the eugenics Elite and they leave this triggers*/
 			_TCD = Math.trunc((V.GDP / 15 + _topClass) * V.rentEffectT * _topClassP + V.TCBase - (V.eliteFail / 15 * V.eliteFailTimer));
 			V.eliteFailTimer -= 1;
-			if (V.classSatisfied.topClass !== 0) {
-				_TCD *= 1 + V.classSatisfied.topClass * 0.06;
-			}
 		} else {
 			_TCD = Math.trunc((V.GDP / 15 + _topClass) * V.rentEffectT * _topClassP + V.TCBase);
-			if (V.classSatisfied.topClass !== 0) {
-				_TCD *= 1 + V.classSatisfied.topClass * 0.06;
-			}
+		}
+		if (V.classSatisfied.topClass !== 0) {
+			_TCD *= 1 + V.classSatisfied.topClass * 0.06;
 		}
 		if (_TCD < 15) {
 			_TCD = 15;
-- 
GitLab