From a37b0504a6351eca6aee1d1cd539ea519aecebac Mon Sep 17 00:00:00 2001
From: hexall90 <hexall90@gmail.com>
Date: Mon, 9 Oct 2017 22:51:19 +0200
Subject: [PATCH] adjustments and PC wound

---
 src/SecExp/SecExpBackwardCompatibility.tw |  2 +-
 src/SecExp/attackHandler.tw               |  1 +
 src/SecExp/attackReport.tw                | 11 +++++++++--
 src/SecExp/authorityReport.tw             |  4 ++++
 src/SecExp/secInit.tw                     |  2 +-
 src/SecExp/securityReport.tw              |  2 ++
 src/js/economyJS.tw                       |  9 +++------
 src/uncategorized/economics.tw            | 16 ++++++++++++----
 src/uncategorized/options.tw              | 10 +++++++++-
 src/uncategorized/persBusiness.tw         | 23 +++++++++++++++++++++--
 src/uncategorized/reputation.tw           |  6 ------
 src/utility/descriptionWidgets.tw         |  4 ++++
 12 files changed, 67 insertions(+), 23 deletions(-)

diff --git a/src/SecExp/SecExpBackwardCompatibility.tw b/src/SecExp/SecExpBackwardCompatibility.tw
index 61f2514a823..962754d4e7f 100644
--- a/src/SecExp/SecExpBackwardCompatibility.tw
+++ b/src/SecExp/SecExpBackwardCompatibility.tw
@@ -5,7 +5,7 @@
 <<set $authority = 0>>
 <</if>>
 <<if ndef $security>>
-<<set $security = 50>>
+<<set $security = 35>>
 <</if>>
 <<if ndef $secRestPoint>>
 <<set $secRestPoint = 40>>
diff --git a/src/SecExp/attackHandler.tw b/src/SecExp/attackHandler.tw
index b583fe7696e..bcee3d121b2 100644
--- a/src/SecExp/attackHandler.tw
+++ b/src/SecExp/attackHandler.tw
@@ -124,6 +124,7 @@
 		<<set _mercMod -= 0.2>>
 		<<set _enemyMod += 0.2>>
 		<<set $PCWounded = 1>>
+		<<set $woundCooldown = 3>>
 	<</if>>
 <<elseif $leadingTroops == "assistant">>
 	<<if $rep < 10000 && $authority < 10000>>
diff --git a/src/SecExp/attackReport.tw b/src/SecExp/attackReport.tw
index 437a4909334..d48ae99e3bb 100644
--- a/src/SecExp/attackReport.tw
+++ b/src/SecExp/attackReport.tw
@@ -646,7 +646,7 @@
 	<</if>>
 	<<if $PCWounded == 1>>
 		During the fighting @@.red;you were wounded@@. Your medics assure you it's nothing life threatening, but you'll be weakened for a few weeks.
-		<<set $PCWoundCooldown = 6>>
+		<<set $PCWoundCooldown = 3>>
 	<</if>>
 <<elseif $leadingTroops == "assistant">>
 	<<if $auto == 1>>$assistantName<<else>>You<</if>> let your personal assistant lead the troops.
@@ -742,6 +742,7 @@
 		<<elseif $woundType >= 4>>
 			While grave wounds, it seems she will be able to fully recover, given enough time.
 		<</if>>
+		Your troops were greatly affected by the loss of their leader.
 	<</if>>
 <<elseif $leadingTroops == "headGirl">>
 	<<if $auto == 1>>$assistantName<<else>>You<</if>> decided it will be your head girl to lead the troops.
@@ -821,6 +822,7 @@
 		<<elseif $woundType >= 4>>
 			While grave wounds, it seems she will be able to fully recover, given enough time.
 		<</if>>
+		Your troops were greatly affected by the loss of their leader.
 	<</if>>
 <<elseif $leadingTroops == "citizen">>
 	<<if $auto == 1>>$assistantName<<else>>You<</if>> decided to appoint one of your volunteers as the commander.
@@ -851,6 +853,9 @@
 	<<else>>
 		You mercenaries are not thrilled to be lead by a civilian without any formal martial training or education.
 	<</if>>
+	<<if $leaderWounded == 1>>
+		During the battle a stray bullet managed to reach the leader. Your troops were greatly affected by the loss.
+	<</if>>
 <<elseif $leadingTroops == "mercenary">>
 	<<if $deployingMercs == 1>>
 		Your mercenaries of course approve of your decision.
@@ -863,6 +868,9 @@
 	<<if $arcologies[0].FSDegradationist != "unset" && $deployingSlaves == 1>>
 		Because of your degradationist society, your slave soldiers are highly distrustful of the gun for hire you forced them to accept as leader.
 	<</if>>
+	<<if $leaderWounded == 1>>
+		During the battle a stray bullet managed to reach the mercenary. Your troops were greatly affected by the loss of their leader.
+	<</if>>
 <</if>>
 
 <br><br>
@@ -1262,7 +1270,6 @@
 	
 /* resets variables */
 <<set $leaderWounded = 0>>
-<<set $PCWounded = 0>>
 <<set $gainedWarfare = 0>>
 <<set $woundType = 0>>
 <<set $tacticsSuccessful == 0>>
diff --git a/src/SecExp/authorityReport.tw b/src/SecExp/authorityReport.tw
index f37349b2566..2c3e1cbd3f4 100644
--- a/src/SecExp/authorityReport.tw
+++ b/src/SecExp/authorityReport.tw
@@ -1,5 +1,9 @@
 :: authorityReport [nobr]
 
+<<if $useTabs == 0>>__Authority__<</if>>
+<br>
+
+
 <<if $authority > 19500>>
 	Your authority is nearly absolute. The arcology is yours to command as it pleases you.
 <<elseif $authority > 15000>>
diff --git a/src/SecExp/secInit.tw b/src/SecExp/secInit.tw
index cafe26bb084..0053d967653 100644
--- a/src/SecExp/secInit.tw
+++ b/src/SecExp/secInit.tw
@@ -2,7 +2,7 @@
 
 /* base vars */
 <<set $authority = 0>>
-<<set $security = 50>>
+<<set $security = 35>>
 <<set $secRestPoint = 40>>
 <<set $crime = 20>>
 <<set $crimeCap = 100>>
diff --git a/src/SecExp/securityReport.tw b/src/SecExp/securityReport.tw
index 06dbf5ae1ca..697c3debb11 100644
--- a/src/SecExp/securityReport.tw
+++ b/src/SecExp/securityReport.tw
@@ -104,6 +104,8 @@
 <</if>>
 <<if _secRest < $secRestPoint && $secHQ == 1>>
 	The limited staff assigned to the HQ hampers the improvements to security achieved this week.
+<<elseif _secRest < $secRestPoint>>
+	The limited infrastructure available slowly erodes the security level of the arcology.  
 <</if>>
 <<set _restGrowth = (_secRest - $security) * 0.2>>
 <<set _newSec = Math.trunc($security + _secGrowth + _secRest)>>
diff --git a/src/js/economyJS.tw b/src/js/economyJS.tw
index 05c28390404..0ebbb368580 100644
--- a/src/js/economyJS.tw
+++ b/src/js/economyJS.tw
@@ -19,9 +19,6 @@ window.getCost = function(array) {
 	var dairy = State.variables.dairy;
 	var servantsQuarters = State.variables.servantsQuarters;
 	var incubator = State.variables.incubator;
-	var propHQ = State.variables.propHub;
-	var secHQ = State.variables.secHQ;
-	var secBarracks = State.variables.secBarracks;
 	var mercCosts = State.variables.mercenaries * 2000;
 	var policyCost = State.variables.policyCost;
 	var costs = (State.variables.brothel * facilityCost)
@@ -65,13 +62,13 @@ window.getCost = function(array) {
 	}
 	
 	//security expansion
-	if(propHQ > 0) {
+	if(State.variables.propHub > 0) {
 		costs += State.variables.propHubUpkeep;
 	}
-	if(secHQ > 0) {
+	if(State.variables.secHQ > 0) {
 		costs += State.variables.secHQUpkeep + 20 * state.variables.secHelots;
 	}
-	if(secBarracks > 0) {
+	if(State.variables.secBarracks > 0) {
 		costs += State.variables.secBarracksUpkeep;
 	}
 	for (var i = 0; i < State.variables.militiaUnits.length; i++) {
diff --git a/src/uncategorized/economics.tw b/src/uncategorized/economics.tw
index 81c80254dd6..72bf11e1368 100644
--- a/src/uncategorized/economics.tw
+++ b/src/uncategorized/economics.tw
@@ -37,7 +37,10 @@
 <</if>>
 <<include "Reputation">>
 
-
+<<if $secExp == 1>>
+<br><br>
+<<include "authorityReport">>
+<</if>>
 
 <br><br>
 
@@ -68,10 +71,9 @@
 	<<if $corpAnnounced == 1>>
 	<button class="tablinks" onclick="opentab(event, 'Corporation')">Corporation</button>
 	<</if>>
-	<<if $secExp == 1>>
-	<button class="tablinks" onclick="opentab(event, 'Reputation')">Reputation and Authority</button>
-	<<else>>
 	<button class="tablinks" onclick="opentab(event, 'Reputation')">Reputation</button>
+	<<if $secExp == 1>>
+	<button class="tablinks" onclick="opentab(event, 'Authority')">Authority</button>
 	<</if>>
 	<button class="tablinks" onclick="opentab(event, 'Management')">Arcology Management</button>
 	<<if ($PC.boobs == 1 && $PC.boobsBonus > 0) || $PC.pregKnown == 1 || $playerAging != 0>>
@@ -117,6 +119,12 @@ You have not yet committed funds to create a publicly traded slave trading corpo
 </div>
 </div>
 
+<div id="Authority" class="tabcontent">
+<div class="content">
+<<include "authorityReport">>
+</div>
+</div>
+
 <div id="Management" class="tabcontent">
 <div class="content">
 <<include "Arcology Management">>
diff --git a/src/uncategorized/options.tw b/src/uncategorized/options.tw
index aab2870f4d7..2f2665c8356 100644
--- a/src/uncategorized/options.tw
+++ b/src/uncategorized/options.tw
@@ -357,10 +357,18 @@ Curative side effects are @@.red;DISABLED@@. [[Enable|Options][$curativeSideEffe
 		<<include "SecExpBackwardCompatibility">>
 		<<goto "Options">>
 	<</link>>
+<<elseif ndef $secExp>>
+	<<set $secExp = 0>>
+	The Security Expansion mod is @@.red;DISABLED@@.
+	<<link "Enable">>
+		<<set $secExp = 1>>
+		<<include "SecExpBackwardCompatibility">>
+		<<goto "Options">>
+	<</link>>
 <<else>>
 	The Security Expansion Mod is currently @@.cyan;ENABLED@@. [[Disable|Options][$secExp = 0]]
 <</if>> 
-//The mod can be activated in any moment, but it may result in unbalanced gameplay if activated very late in the game. If this is the first time activating the mod or you are updating an old save, please run backward compatibility.//
+//The mod can be activated in any moment, but it may result in unbalanced gameplay if activated very late in the game.//
 
 <br><br>
 ''CHEATING/DEV OPTIONS''
diff --git a/src/uncategorized/persBusiness.tw b/src/uncategorized/persBusiness.tw
index 64ddb494c16..8b48a124580 100644
--- a/src/uncategorized/persBusiness.tw
+++ b/src/uncategorized/persBusiness.tw
@@ -3,6 +3,21 @@
 <<if $useTabs == 0>>__Personal Business__<</if>>
 <br>
 
+<<if $PCWounded == 1>>
+	<<set $PCWoundCooldown-->>
+	<<if $PCWoundCooldown > 0>>
+		The injuries received in the recent battle prevents you from engaging in tiring endeavours.
+	<</if>>
+	<<if $PCWoundCooldown == 1>>
+		You are starting to feel better. It's very likely you will be back to full working order within the next week.
+	<<elseif $PCWoundCooldown == 0>>
+		<<set $PCWounded = 0>>
+		You finally recovered from your injuries.
+	<<else>>
+		Your trusted physician believes it will still take a few weeks to fully recover.
+	<</if>>
+<</if>>
+
 <<if $cash < 0>>
 	@@.red;You are in debt.@@ This week, interest came to ¤<<print (1+Math.trunc(Math.abs($cash)/100))>>.
 	<<set $cash -= (1+Math.trunc(Math.abs($cash)/100))>>
@@ -22,6 +37,8 @@
 		<<set $gameover = "debt">><<goto "Gameover">>
 		<</if>>
 	<</if>>
+<<elseif $PCWounded == 1>>
+	/* does nothing for this week */
 <<elseif ($personalAttention == "whoring")>>
 	<<if $PC.belly >= 1500>>
 		<<if $arcologies[0].FSRepopulationFocus != "unset">>
@@ -356,7 +373,9 @@
 	You have enough cash to manage your affairs, but not enough to do much business.
 <</if>>
 
-<<if ($personalAttention == "trading")>>
+<<if $PCWounded == 1>>
+ /* does nothing this week */
+<<elseif ($personalAttention == "trading")>>
 	<<set _oldSkill = $PC.trading>>
 	<<set $PC.trading += random(1,3)>>
 	<<if _oldSkill <= 10>>
@@ -576,7 +595,7 @@
 <<if $marketInfiltration == 1>>
 	Your secret service makes use of black markets and illegal streams of goods to make a profit, making you @@.yellowgreen;¤a discreet sum@@. This however allows @@.red;crime to flourish@@ in the underbelly of the arcology.
 	<<set $cash += 1000>>
-	<<set $crime += random(0,1)>>
+	<<set $crime += random(0,2)>>
 <</if>>
 
 Routine upkeep of your demesne costs @@.yellow;¤$costs.@@
diff --git a/src/uncategorized/reputation.tw b/src/uncategorized/reputation.tw
index 480aa8567be..7074419738e 100644
--- a/src/uncategorized/reputation.tw
+++ b/src/uncategorized/reputation.tw
@@ -667,10 +667,4 @@ On formal occasions, you are announced as $PCTitle.
 	<<elseif $failedElite > 50>>
 		The Societal Elite @@.red;mutter about you@@.
 	<</if>>
-<</if>>
-
-<br><br>
-
-<<if $secExp == 1>>
-<<include "authorityReport">>
 <</if>>
\ No newline at end of file
diff --git a/src/utility/descriptionWidgets.tw b/src/utility/descriptionWidgets.tw
index a2b1c8e7116..f0b8d1498c0 100644
--- a/src/utility/descriptionWidgets.tw
+++ b/src/utility/descriptionWidgets.tw
@@ -2,6 +2,9 @@
 
 <<widget "MainLinks">>
 <center>
+<<if $PCWounded == 1>>
+	The injuries received in the recent battle prevent you from undertaking tiring efforts.
+<<else>>
 <<switch $personalAttention>>
 <<case "business">>You plan to focus on business this week.
 <<case "whoring">>You plan to focus on earning extra money this week.
@@ -175,6 +178,7 @@
 			<br>@@.yellow;For your first purchase, @@<strong>[[The Futanari Sisters][$slavesSeen += 1]]</strong>@@.yellow; will sell at half price this week.@@
 		<</if>>
 	<</if>>
+<</if>>	/* closes wound check */
 </center>
 <</widget>>
 
-- 
GitLab