From aeae803523e7d9312f45c3727b140a6966e4c86e Mon Sep 17 00:00:00 2001
From: Blank_Alt <12406-Blank_Alt@users.noreply.gitgud.io>
Date: Thu, 6 Feb 2020 11:47:05 -0800
Subject: [PATCH] Supply policies report

---
 src/js/economyJS.js          |  41 +++++++++-
 src/uncategorized/arcmgmt.tw | 149 +----------------------------------
 2 files changed, 43 insertions(+), 147 deletions(-)

diff --git a/src/js/economyJS.js b/src/js/economyJS.js
index 2611c180888..79fab073eb7 100644
--- a/src/js/economyJS.js
+++ b/src/js/economyJS.js
@@ -1997,13 +1997,50 @@ window.agentBonus = function(arcology) {
 };
 
 /**
- * Charge for subsidies and supply barriers and report the results
+ * Report supply market status, charge for subsidies and supply barriers and report the results
  * @param {string} NPCclass One of "lower", "middle", "upper", or "top"
  * @returns {string}
  */
-window.chargeSupplyPolicies = function(NPCclass) {
+window.supplyPoliciesReport = function(NPCclass) {
 	let r = ``;
 	const varName = `${NPCclass}Class`;
+	const className = NPCclass !== 'top' ? `${NPCclass} class citizens` : `arcology's millionaires`;
+	const classNameShort = NPCclass === 'top' ? `millionaire` : `${className.replace('citizens', '')}`;
+ let overSupply = 0;
+
+	if (V.sexDemandResult[varName] < 350) {
+		r += `Your ${className} have <span class='red'>far too few options for sexual relief</span> inside your arcology.`;
+		if (V.classSatisfied[varName] === 0) {
+			r += ` They trust you will take care of this issue as soon as you are settled in.`;
+		} else {
+			r += ` It is <span class='red'>causing dissatisfaction</span> among your ${classNameShort + NPCclass === 'top' ? `s` : ``}.`;
+		}
+	} else if (V.sexDemandResult[varName] < 550) {
+		r += `Your ${className} need <span class='red'>some more avenues for sexual relief</span> inside your arcology.`;
+		if (V.classSatisfied[varName] === 1) {
+			r += ` They see <span class='green'>you are on the right track</span> and anticipate further improvements.`;
+		} else if (V.classSatisfied[varName] === 0) {
+			r += ` Their patience is being tested.`;
+		} else {
+			r += ` It is <span class='red'>causing dissatisfaction</span> among your ${classNameShort + NPCclass === 'top' ? `s` : ``}.`;
+		}
+	} else if (V.sexDemandResult[varName] < 750) {
+			r += `Your ${className} have no issue finding the sexual relief they need inside your arcology.`;
+			if (V.classSatisfied[varName] === 1) {
+				r += ` They are <span class='green'>delighted</span> with how quickly you've provided for them.`;
+			}
+	} else {
+		r += `Your ${className} are <span class='green'>${V.sexDemandResult[varName] < 950 ? `happy with the availability` : `delighted with the abundance`} of sexual services</span> inside your arcology.`;
+	}
+
+	if (V.sexDemandResult[varName] > 1000) {
+		overSupply = V.sexDemandResult[varName] - 1000; V.sexDemandResult[varName] = 1000;
+	}
+	r += `<br>${capFirstChar(classNameShort)} satisfaction is at ${V.sexDemandResult[varName]/10}%`;
+	if (overSupply > 0) {
+		r += ` and the arcology provides ${overSupply/10}% more sexual services than required which <span class='red'>drives prices down</span>`;
+	}
+ r += `, ${V.NPCMarketShare[varName]/10 === V.sexDemandResult[varName]/10 ? `the entire` : `${V.NPCMarketShare[varName]/10}% of the`} market is serviced by other suppliers operating inside your arcology.<br>`;
 
 	// charge supply barriers (unreported, since it's a flat amount that you were told when you enacted the policy)
 	const supplyCosts = [0, 1000, 5000, 20000, 60000];
diff --git a/src/uncategorized/arcmgmt.tw b/src/uncategorized/arcmgmt.tw
index ede128d6f91..d856b62f643 100644
--- a/src/uncategorized/arcmgmt.tw
+++ b/src/uncategorized/arcmgmt.tw
@@ -6,8 +6,6 @@
 <<= ownershipReport({sidebar: false})>> <br><br>
 
 /* Sexual Satisfaction */
-<<set _overSupply = {lowerClass: 0, middleClass: 0, upperClass: 0, topClass: 0}>>
-
 <<if $arcologies[0].FSDegradationist !== "unset">>
 	<<if $arcadeDemandDegResult == 1>>
 		Your endeavors to see slaves as less than human are hampered as citizens find that there are too few slaves ready to be treated as sexual objects around. @@.red;Development towards a degradationist society is damaged@@ as a result.<br>
@@ -21,150 +19,11 @@
 		You are providing your citizens with an adequate amount of slaves to be used as sexual objects, as is expected in your degradationist society.<br>
 	<</if>>
 <</if>>
-<<if $sexDemandResult.lowerClass < 350>>
-	Your lower class citizens have @@.red;far too few options for sexual relief@@ inside your arcology.
-	<<if $classSatisfied.lowerClass == 0>>
-		They trust you will take care of this issue as soon as you are settled in.<br>
-	<<else>>
-		It is @@.red;causing dissatisfaction@@ among your lower class.<br>
-	<</if>>
-<<elseif $sexDemandResult.lowerClass < 550>>
-	Your lower class citizens need @@.red;some more avenues for sexual relief@@ inside your arcology.
-	<<if $classSatisfied.lowerClass == 1>>
-		They see @@.green;you are on the right track@@ and anticipate further improvements.<br>
-	<<elseif $classSatisfied.lowerClass == 0>>
-		Their patience is being tested.<br>
-	<<else>>
-		It is @@.red;causing dissatisfaction@@ among your lower class.<br>
-	<</if>>
-<<elseif $sexDemandResult.lowerClass < 750>>
-	Your lower class citizens have no issue finding the sexual relief they need inside your arcology.
-	<<if $classSatisfied.lowerClass == 1>>
-		They are @@.green;delighted@@ with how quickly you've provided for them.<br>
-	<<else>>
-		<br>
-	<</if>>
-<<elseif $sexDemandResult.lowerClass < 950>>
-	Your lower class citizens are @@.green;happy with the availability of sexual services@@ inside your arcology.<br>
-<<elseif $sexDemandResult.lowerClass >= 950>>
-	Your lower class citizens are @@.green;delighted with the abundance of sexual services@@ inside your arcology.<br>
-<</if>>
-<<if $sexDemandResult.lowerClass > 1000>>
-	<<set _overSupply.lowerClass = $sexDemandResult.lowerClass - 1000,
-	$sexDemandResult.lowerClass = 1000>>
-<</if>>
-Lower class satisfaction is at <<print $sexDemandResult.lowerClass/10>>%<<if _overSupply.lowerClass > 0>> and the arcology provides <<print _overSupply.lowerClass/10>>% more sexual services than required which @@.red;drives prices down@@<</if>>, <<print $NPCMarketShare.lowerClass/10>>% of the market is serviced by other suppliers operating inside your arcology.<br>
-
-<<= chargeSupplyPolicies("lower") >>
-
-<<if $sexDemandResult.middleClass < 350>>
-	Your middle class citizens have @@.red;far too few options for sexual relief@@ inside your arcology.
-	<<if $classSatisfied.middleClass == 0>>
-		They trust you will take care of this issue as soon as you are settled in.<br>
-	<<else>>
-		It is @@.red;causing dissatisfaction@@ among your middle class.<br>
-	<</if>>
-<<elseif $sexDemandResult.middleClass < 550>>
-	Your middle class citizens need @@.red;some more avenues for sexual relief@@ inside your arcology.
-	<<if $classSatisfied.middleClass == 1>>
-		They see @@.green;you are on the right track@@ and anticipate further improvements.<br>
-	<<elseif $classSatisfied.middleClass == 0>>
-		Their patience is being tested.<br>
-	<<else>>
-		It is @@.red;causing dissatisfaction@@ among your middle class.<br>
-	<</if>>
-<<elseif $sexDemandResult.middleClass < 750>>
-	Your middle class citizens have no issue finding the sexual relief they need inside your arcology.
-	<<if $classSatisfied.middleClass == 1>>
-		They are @@.green;delighted@@ with how quickly you've provided for them.<br>
-	<<else>>
-		<br>
-	<</if>>
-<<elseif $sexDemandResult.middleClass < 950>>
-	Your middle class citizens are @@.green;happy with the availability of sexual services@@ inside your arcology.<br>
-<<elseif $sexDemandResult.middleClass >= 950>>
-	Your middle class citizens are @@.green;delighted with the abundance of sexual services@@ inside your arcology.<br>
-<</if>>
-<<if $sexDemandResult.middleClass > 1000>>
-	<<set _overSupply.middleClass = $sexDemandResult.middleClass - 1000,
-	$sexDemandResult.middleClass = 1000>>
-<</if>>
-Middle class satisfaction is at <<print $sexDemandResult.middleClass/10>>%<<if _overSupply.middleClass > 0>> and the arcology provides <<print _overSupply.middleClass/10>>% more sexual services than required which @@.red;drives prices down@@<</if>>, <<print $NPCMarketShare.middleClass/10>>% of the market is serviced by other suppliers operating inside your arcology.<br>
-
-<<= chargeSupplyPolicies("middle") >>
-
-<<if $sexDemandResult.upperClass < 350>>
-	Your upper class citizens have @@.red;far too few options for sexual relief@@ inside your arcology.
-	<<if $classSatisfied.upperClass == 0>>
-		They trust you will take care of this issue as soon as you are settled in.<br>
-	<<else>>
-		It is @@.red;causing dissatisfaction@@ among your upper class.<br>
-	<</if>>
-<<elseif $sexDemandResult.upperClass < 550>>
-	Your upper class citizens need @@.red;some more avenues for sexual relief@@ inside your arcology.
-	<<if $classSatisfied.upperClass == 1>>
-		They see @@.green;you are on the right track@@ and anticipate further improvements.<br>
-	<<elseif $classSatisfied.upperClass == 0>>
-		Their patience is being tested.<br>
-	<<else>>
-		It is @@.red;causing dissatisfaction@@ among your upper class.<br>
-	<</if>>
-<<elseif $sexDemandResult.upperClass < 750>>
-	Your upper class citizens have no issue finding the sexual relief they need inside your arcology.
-	<<if $classSatisfied.upperClass == 1>>
-		They are @@.green;delighted@@ with how quickly you've provided for them.<br>
-	<<else>>
-		<br>
-	<</if>>
-<<elseif $sexDemandResult.upperClass < 950>>
-	Your upper class citizens are @@.green;happy with the availability of sexual services@@ inside your arcology.<br>
-<<elseif $sexDemandResult.upperClass >= 950>>
-	Your upper class citizens are @@.green;delighted with the abundance of sexual services@@ inside your arcology.<br>
-<</if>>
-<<if $sexDemandResult.upperClass > 1000>>
-	<<set _overSupply.upperClass = $sexDemandResult.upperClass - 1000,
-	$sexDemandResult.upperClass = 1000>>
-<</if>>
-Upper class satisfaction is at <<print $sexDemandResult.upperClass/10>>%<<if _overSupply.upperClass > 0>> and the arcology provides <<print _overSupply.upperClass/10>>% more sexual services than required which @@.red;drives prices down@@<</if>>, <<print $NPCMarketShare.upperClass/10>>% of the market is serviced by other suppliers operating inside your arcology.<br>
-
-<<= chargeSupplyPolicies("upper") >>
-
-<<if $sexDemandResult.topClass < 350>>
-	Your arcology's millionaires have @@.red;far too few options for sexual relief@@ inside your arcology.
-	<<if $classSatisfied.topClass == 0>>
-		They trust you will take care of this issue as soon as you are settled in.<br>
-	<<else>>
-		It is @@.red;causing dissatisfaction@@ among your millionaires.<br>
-	<</if>>
-<<elseif $sexDemandResult.topClass < 550>>
-	Your arcology's millionaires need @@.red;some more avenues for sexual relief@@ inside your arcology.
-	<<if $classSatisfied.topClass == 1>>
-		They see @@.green;you are on the right track@@ and anticipate further improvements.<br>
-	<<elseif $classSatisfied.topClass == 0>>
-		Their patience is being tested.<br>
-	<<else>>
-		It is @@.red;causing dissatisfaction@@ among your millionaires.<br>
-	<</if>>
-<<elseif $sexDemandResult.topClass < 750>>
-	Your arcology's millionaires have no issue finding the sexual relief they need inside your arcology.
-	<<if $classSatisfied.topClass == 1>>
-		They are @@.green;delighted@@ with how quickly you've provided for them.<br>
-	<<else>>
-		<br>
-	<</if>>
-<<elseif $sexDemandResult.topClass < 950>>
-	Your arcology's millionaires are @@.green;happy with the availability of sexual services@@ inside your arcology.<br>
-<<elseif $sexDemandResult.topClass >= 950>>
-	Your arcology's millionaires are @@.green;delighted with the abundance of sexual services@@ inside your arcology.<br>
-<</if>>
-<<if $sexDemandResult.topClass > 1000>>
-	<<set _overSupply.topClass = $sexDemandResult.topClass - 1000,
-	$sexDemandResult.topClass = 1000>>
-<</if>>
-Millionaire satisfaction is at <<print $sexDemandResult.topClass/10>>%<<if _overSupply.topClass > 0>> and the arcology provides <<print _overSupply.topClass/10>>% more sexual services than required which @@.red;drives prices down@@<</if>>, <<print $NPCMarketShare.topClass/10>>% of the market is serviced by other suppliers operating inside your arcology.<br>
-
-<<= chargeSupplyPolicies("top") >>
 
+<<= supplyPoliciesReport("lower")>>
+<<= supplyPoliciesReport("middle")>>
+<<= supplyPoliciesReport("upper")>>
+<<= supplyPoliciesReport("top")>>
 <br>
 
 /* New Population
-- 
GitLab