From b9879b6b4f886f1fd58848e98f53270f1812d457 Mon Sep 17 00:00:00 2001
From: Jones <Jones>
Date: Mon, 3 Dec 2018 00:08:11 +0100
Subject: [PATCH] Fixes? Yes.

some $ACitizen stuff that I apparently didn't check and one $ASlaves.
---
 src/SecExp/unitsRebellionReport.tw | 30 +++++++++++++++++++++++++-----
 src/uncategorized/arcmgmt.tw       | 11 ++++++++---
 src/uncategorized/reMalefactor.tw  |  1 -
 src/uncategorized/reputation.tw    |  6 +++++-
 src/uncategorized/seExpiration.tw  | 10 +++++-----
 5 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/src/SecExp/unitsRebellionReport.tw b/src/SecExp/unitsRebellionReport.tw
index 05b27294b69..29da0b465f1 100644
--- a/src/SecExp/unitsRebellionReport.tw
+++ b/src/SecExp/unitsRebellionReport.tw
@@ -300,11 +300,8 @@
 		<br>
 		<br>
 		<<set _loss = _lossesList.pluck()>>
-		<<if _loss < $ACitizens + 100>>
-			<<set $ACitizens -= _loss>>
-		<<else>>
-			<<set $ACitizens = 100>>
-		<</if>>
+		<<if _loss > $ACitizens * 0.95>>
+			<<set _loss = Math.trunc($ACitizens * 0.95>> /* this is unlikely to happen, but might as well be safe*/ 
 		The volunteering citizens were quickly organized into an irregular militia unit and deployed in the arcology:
 		<<if _loss <= 0>>
 			no casualties
@@ -318,6 +315,29 @@
 			catastrophic casualties
 		<</if>>
 		suffered.
+		<<if _loss > $lowerClass * 0.95>> /*I suspect only lower class ever get to fight/die, but being safe*/
+			<<set $lowerClass = Math.trunc($lowerClass * 0.05),
+			_loss -= $lowerClass * 0.95>>
+			<<if _loss > $middleClass * 0.95>>
+				<<set $middleClass = Math.trunc($middleClass * 0.05),
+				_loss -= $middleClass *0.95>>
+				<<if _loss > $upperClass * 0.95>>
+					<<set $upperClass = Math.trunc($upperClass * 0.05),
+					_loss -= $upperClass * 0.95>>
+					<<if _loss > $topClass * 0.95>>
+						<<set $topClass = Math.trunc($topClass * 0.05)>>
+					<<else>>
+						<<set $topClass -= _loss>>
+					<</if>>
+				<<else>>
+					<<set $upperClass -= _loss>>
+				<</if>>
+			<<else>>
+				<<set $middleClass -= _loss>>
+			<</if>>
+		<<else>>
+			<<set $lowerClass -= _loss>>
+		<</if>>
 	<</if>>
 	<<if $secBots.active == 1>>
 		<br>
diff --git a/src/uncategorized/arcmgmt.tw b/src/uncategorized/arcmgmt.tw
index 2538b13c200..9c81a4714a1 100644
--- a/src/uncategorized/arcmgmt.tw
+++ b/src/uncategorized/arcmgmt.tw
@@ -845,9 +845,14 @@ _SCD = Math.trunc(($upperClass * ($slaveDemandU + _slaveDemandU)) + ($topClass *
 
 /*Top Class Citizens*/
 /*Setting GDP depending on population*/
-<<set $GDP = Math.trunc((($NPCSlaves + $helots) * 0.35 * $slaveProductivity) + ($lowerClass * 0.35) + ($middleClass * 0.75) + ($upperClass * 2) + ($topClass * 10)) / 10,
+<<set $GDP = Math.trunc((($NPCSlaves + $helots) * 0.35 * $slaveProductivity) + ($lowerClass * 0.35) + ($middleClass * 0.75) + ($upperClass * 2) + ($topClass * 10)) / 10>>
 /*Top Class Interest in living in your arcology*/
-_TCD = Math.trunc(($GDP / 15 + _topClass) * $rentEffectT * _topClassP + $TCBase)>>
+<<if $eliteFailTimer > 0>> /*when you fail the eugenics elite and they leave this triggers*/
+	<<set _TCD = Math.trunc(($GDP / 15 + _topClass) * $rentEffectT * _topClassP + $TCBase - ($eliteFail / 15 * $eliteFailTimer)),
+	$eliteFailTimer -= 1>>
+<<else>>
+	<<set _TCD = Math.trunc(($GDP / 15 + _topClass) * $rentEffectT * _topClassP + $TCBase)>>
+<</if>>
 /*Top Class Citizens immigrating*/
 <<if $topClass < _TCD>>
 	<<set _TCImmigration = Math.trunc((_TCD - $topClass) * (0.3 * _terrain)) + 1,
@@ -957,7 +962,7 @@ _percTopClass = Math.trunc(($topClass / ($ACitizens + $ASlaves)) * 1000) / 10>>
 <<if $alternativeRents == 1>> /*A silly policy*/
 	Your citizens are allowed to pay their rents in slaves rather than cash and a few financially challenged individuals make use of this.
 	<<set _rentMultiplier *= 0.95>>
-	<<set _movement = random(0,3), $helots += _movement, $ASlaves -= _movement>>
+	<<set _movement = random(0,3), $helots += _movement, $NPCSlaves -= _movement>>
 <</if>>
 <<if $discountMercenaries == 1>>
 	Mercenaries willing to come to your arcology are given a discount on rent.
diff --git a/src/uncategorized/reMalefactor.tw b/src/uncategorized/reMalefactor.tw
index e6e5add1a05..431814431e0 100644
--- a/src/uncategorized/reMalefactor.tw
+++ b/src/uncategorized/reMalefactor.tw
@@ -521,7 +521,6 @@ She is easily taken into custody and her contraband confiscated once the jeering
 			You help the exhausted mother to her feet and hand her her second newborn. She watches you, uncertain of your motives, until you have her escorted to the proper welcoming facility and put in a good word for having her added to your arcology's free population. You announce to the public that such a fertile <<if $activeSlave.physicalAge > 30>>milf<<elseif $activeSlave.physicalAge > 19>>woman<<elseif $activeSlave.physicalAge > 12>>teen<<else>>youth<</if>> will be a boon to Repopulationism, and that the contract she is signing mandates she be on powerful fertility agents whenever she isn't pregnant. During her residency, free or not, she will provide society with dozens of future children. The public @@.green;approves of breeders, free or not,@@ and word spreads that any and all mothers are welcome into your arcology @@.green;adding to its prosperity.@@
 		<<set $rep += 10>>
 		<<set $arcologies[0].prosperity += 1>>
-		<<set $ACitizens++>>
 		<</replace>>
 	<</link>>
 	<</if>>
diff --git a/src/uncategorized/reputation.tw b/src/uncategorized/reputation.tw
index a1e639a1416..40f14cf0679 100644
--- a/src/uncategorized/reputation.tw
+++ b/src/uncategorized/reputation.tw
@@ -767,7 +767,11 @@ On formal occasions, you are announced as $PCTitle.
 		The Societal Elite @@.red;have departed from your arcology in disgust@@.
 		<<run removeFS("FSRestart")>>
 		<<set $rep -= 10000>>
-		<<set $ACitizens = Math.max($ACitizens - random(30,100), 0)>>
+		<<set $eliteFail = random(30,100),
+		$eliteFailTimer = 15>>
+		<<if $eliteFail > $topClass - 20>>
+			<<set $eliteFail = $topClass - 20>>
+		<</if>>
 		<<if $arcologies[0].prosperity > 50>>
 		<<set $arcologies[0].prosperity -= random(20,40)>>
 		<</if>>
diff --git a/src/uncategorized/seExpiration.tw b/src/uncategorized/seExpiration.tw
index a237728edd5..f09e3817ecf 100644
--- a/src/uncategorized/seExpiration.tw
+++ b/src/uncategorized/seExpiration.tw
@@ -9,7 +9,7 @@
 <<run Enunciate($activeSlave)>>
 
 $activeSlave.slaveName's indentured servitude is ending this week, meaning that your arcology is gaining a citizen.
-<<set $ACitizens += 1>>
+<<set $lowerClass += 1>>
 
 <<set _seed = 0>>
 <<for _seexp = 0; _seexp < $slaves.length; _seexp++>>
@@ -36,7 +36,7 @@ $activeSlave.slaveName's indentured servitude is ending this week, meaning that
 			<<replace "#result">>
 				You plead necessity and place $him under another indenture, paying the trivial fees left over once $he has been charged for $his own forecasted upkeep. Naturally, $he offers no response at all to any of this.
 				<<set $cash -= 1000>>
-				<<set $ACitizens -= 1>>
+				<<set $lowerClass -= 1>>
 				<<set $expired = 0, $expiree = 0>>
 				<<for $i = 0; $i < $slaves.length; $i++>>
 					<<if $slaves[$i].indenture == 0>>
@@ -72,7 +72,7 @@ $activeSlave.slaveName's indentured servitude is ending this week, meaning that
 				$He's beside $himself with joy when you accept $his plea and enslave $him. $He's given you the finest proof of loyalty a slave possibly can, having tasted a moment of freedom under the law, and thrown it away with utter contempt. $His $activeSlave.eyeColor eyes <<if canSee($activeSlave)>>watch you<<else>>are wide<</if>> with eager anticipation, radiating gladness that the prospect of separation from you has gone.
 				<<set $activeSlave.indenture = -1, $activeSlave.indentureRestrictions = 0>>
 				<<set $cash -= 1000>>
-				<<set $ACitizens -= 1>>
+				<<set $lowerClass -= 1>>
 				<<set $expired = 0, $expiree = 0>>
 				<<for $i = 0; $i < $slaves.length; $i++>>
 					<<if $slaves[$i].indenture == 0>>
@@ -111,7 +111,7 @@ $activeSlave.slaveName's indentured servitude is ending this week, meaning that
 			<<replace "#result">>
 				$He smiles almost shyly when you offer $him a one year supplementary indenture. The price is reasonable, but definitely favorable to you. $He accepts it anyway, and you transfer the money into an escrow account to be held for $him until $his new indenture is done. Your sex slave once again, $he awaits your pleasure without a hint of fear.
 				<<set $cash -= $slaveCost>>
-				<<set $ACitizens -= 1>>
+				<<set $lowerClass -= 1>>
 				<<set $expired = 0>><<set $expiree = 0>>
 				<<for $i = 0; $i < $slaves.length; $i++>>
 				<<if $slaves[$i].indenture == 0>>
@@ -142,7 +142,7 @@ at the moment of $his scheduled emancipation, $he seems willing to consider a sh
 		<<replace "#result">>
 			$He looks pensive when you offer $him a one year supplementary indenture. The price reflects the market, and is a reasonable compensation for a year of sexual slavery. $He accepts it after some consideration, and you transfer the money into an escrow account to be held for $him until $his new indenture is done. Your sex slave once again, $he awaits orders with complacency.
 			<<set $cash -= $slaveCost>>
-			<<set $ACitizens -= 1>>
+			<<set $lowerClass -= 1>>
 			<<set $expired = 0>><<set $expiree = 0>>
 			<<for $i = 0; $i < $slaves.length; $i++>>
 			<<if $slaves[$i].indenture == 0>>
-- 
GitLab