From f057b1795e247a10e73fa426ab518817ecd9057c Mon Sep 17 00:00:00 2001
From: Blank_Alt <12406-Blank_Alt@users.noreply.gitgud.io>
Date: Mon, 21 Sep 2020 17:40:32 -0700
Subject: [PATCH] secExp-fixesAndMinorBackPorting [Ready to merge]

---
 js/003-data/gameVariableData.js               | 33 +++-------
 src/002-config/fc-version.js                  |  2 +-
 .../SecExp/SecExpBackwardCompatibility.tw     | 21 +------
 src/Mods/SecExp/attackGenerator.tw            | 10 +--
 src/Mods/SecExp/attackHandler.tw              |  2 +-
 src/Mods/SecExp/attackOptions.tw              | 30 +++------
 src/Mods/SecExp/attackReport.tw               | 20 +++---
 src/Mods/SecExp/buildings/secBarracks.tw      |  4 +-
 .../SecExp/buildings/weaponsManufacturing.tw  |  2 +-
 src/Mods/SecExp/edicts.tw                     |  2 +-
 src/Mods/SecExp/js/Unit.js                    |  6 +-
 src/Mods/SecExp/js/buildingsJS.js             | 56 ++++++++---------
 src/Mods/SecExp/js/secExp.js                  | 19 +++---
 src/Mods/SecExp/js/secExpBC.js                | 63 +++++++++----------
 .../SecExp/{widgets => }/miscSecExpWidgets.tw |  0
 src/Mods/SecExp/potentialToDo.txt             |  6 +-
 src/Mods/SecExp/rebellionGenerator.tw         |  6 +-
 src/Mods/SecExp/rebellionReport.tw            | 11 ++--
 src/Mods/SecExp/securityReport.tw             |  7 ++-
 src/Mods/SecExp/tradeReport.tw                | 10 +--
 src/uncategorized/manageArcology.tw           | 26 ++++----
 src/uncategorized/scheduledEvent.tw           |  6 +-
 22 files changed, 148 insertions(+), 194 deletions(-)
 rename src/Mods/SecExp/{widgets => }/miscSecExpWidgets.tw (100%)

diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js
index b6df49922f8..7a796698e8a 100644
--- a/js/003-data/gameVariableData.js
+++ b/js/003-data/gameVariableData.js
@@ -372,15 +372,8 @@ App.Data.resetOnNGPlus = {
 	boomerangStats: {},
 	FSNonconformist: "",
 	econAdvantage: 0,
-	attackType: "none",
-	attackThisWeek: 0,
-	lastAttackWeeks: 0,
-	lastRebellionWeeks: 0,
-	majorBattle: 0,
-	PCvictoryStreak: 0,
-	PClossStreak: 0,
+	
 	foughtThisWeek: 0,
-
 	/* rebellions */
 	slaveRebellionEventFires: 0,
 	citizenRebellionEventFires: 0,
@@ -391,10 +384,6 @@ App.Data.resetOnNGPlus = {
 	repairTime: 3,
 	arcRepairTime: 0,
 	garrison: {},
-	rebellionsCount: 0,
-	PCrebWon: 0,
-	PCrebLoss: 0,
-
 	/* armed forces stats */
 	militiaFreeManpower: 0,
 	militiaTotalCasualties: 0,
@@ -404,19 +393,20 @@ App.Data.resetOnNGPlus = {
 	createdSlavesUnits: 0,
 	createdMilitiaUnits: 0,
 	createdMercUnits: 0,
-
 	/* battle relevant vars */
+	attackType: "none",
+	attackThisWeek: 0,
+	majorBattle: 0,
+	PCvictoryStreak: 0,
+	PClossStreak: 0,
 	slaveVictories: [],
-	battlesCount: 0,
-	majorBattlesCount: 0,
 	chosenTactic: "none",
 	leadingTroops: "none",
 	attackTroops: 0,
 	attackEquip: 0,
 	battleTerrain: "none",
 	maxTurns: 10,
-	battleResult: 4,
-	/* sets battleResult value outside accepted range (-3,3) to avoid evaluation problems */
+	battleResult: 4, // sets battleResult value outside accepted range (-3,3) to avoid evaluation problems
 	losses: 0,
 	enemyLosses: 0,
 	battleTurns: 0,
@@ -428,25 +418,20 @@ App.Data.resetOnNGPlus = {
 	rebellingID: [],
 	saveValid: 0,
 	lastSelection: [],
-
-	/* units *//** @type {FC.SecExp.PlayerUnitData} */
+	/* units */
+	/** @type {FC.SecExp.PlayerUnitData} */
 	secBots: {},
-
 	/** @type {FC.SecExp.PlayerHumanUnitData[]} */
 	militiaUnits: [],
 	/** @type {FC.SecExp.PlayerHumanUnitData[]} */
 	slaveUnits: [],
 	/** @type {FC.SecExp.PlayerHumanUnitData[]} */
 	mercUnits: [],
-
 	/* SFanon additions */
 	SavedLeader: 0,
 	SavedSFI: 0,
-	sectionInFirebase: 0,
 	/* base vars */
 	SecExp: {},
-	PCvictories: 0,
-	PClosses: 0,
 
 	reminderEntry: "",
 	reminderWeek: "",
diff --git a/src/002-config/fc-version.js b/src/002-config/fc-version.js
index bf9c0ae5341..7bcd452c066 100644
--- a/src/002-config/fc-version.js
+++ b/src/002-config/fc-version.js
@@ -2,5 +2,5 @@ App.Version = {
 	base: "0.10.7.1", // The vanilla version the mod is based off of, this should never be changed.
 	pmod: "3.8.0",
 	commitHash: null,
-	release: 1101 // When gettting close to 2000,  please remove the check located within the onLoad() function defined at line five of src/js/eventHandlers.js.
+	release: 1102 // When gettting close to 2000,  please remove the check located within the onLoad() function defined at line five of src/js/eventHandlers.js.
 };
diff --git a/src/Mods/SecExp/SecExpBackwardCompatibility.tw b/src/Mods/SecExp/SecExpBackwardCompatibility.tw
index 0a2fcc1cd7a..ceca54865e8 100644
--- a/src/Mods/SecExp/SecExpBackwardCompatibility.tw
+++ b/src/Mods/SecExp/SecExpBackwardCompatibility.tw
@@ -1,23 +1,6 @@
 :: SecExpBackwardCompatibility [nobr]
 
 <<set $nextButton = "Continue", $nextLink = "Main", $returnTo = "Main">>
-
-/* base stats */
-<<run App.SecExp.generalBC()>>
-<<set $lastRebellionWeeks = Number($lastRebellionWeeks) || 0>>
-
-/* if we had the old one-time battle flags, make sure the counters are set to at least one */
-<<if $battlesCount == 0 && $hasFoughtOnce == 1>>
-	<<set $battlesCount = 1>>
-<</if>>
-<<if $majorBattlesCount == 0 && $hasFoughtMajorBattleOnce == 1>>
-	<<set $majorBattlesCount = 1>>
-<</if>>
-<<if $rebellionsCount == 0 && $hasRebelledOnce == 1>>
-	<<set $rebellionsCount = 1>>
-<</if>>
-
-/* recalculation widgets */
-<<fixBrokenStats>>
-
+<<run App.SecExp.generalBC()>> /* base stats */
+<<fixBrokenStats>> /* recalculation widgets */
 <br>Missing Security Expansion variables set. All done!
\ No newline at end of file
diff --git a/src/Mods/SecExp/attackGenerator.tw b/src/Mods/SecExp/attackGenerator.tw
index 399ff775a58..980c5d57480 100644
--- a/src/Mods/SecExp/attackGenerator.tw
+++ b/src/Mods/SecExp/attackGenerator.tw
@@ -2,7 +2,7 @@
 
 /* _attackChance value is the chance out of 100 of an attack happening this week */
 /* attacks are deactivated if the arcology is in the middle of the ocean, security drones are not around yet, there is not a rebellion this week or the last attack/rebellion happened within 3 weeks */
-<<if $terrain == "oceanic" || $arcologyUpgrade.drones != 1 || $lastAttackWeeks <= 3 || $citizenRebellion == 1 || $slaveRebellion == 1 || $lastRebellionWeeks <= 3>>
+<<if $terrain == "oceanic" || $arcologyUpgrade.drones != 1 || $SecExp.battles.lastEncounterWeeks <= 3 || $citizenRebellion == 1 || $slaveRebellion == 1 || $SecExp.rebellions.lastEncounterWeeks <= 3>>
 	<<set _attackChance = 0>>
 <<else>>
 	<<if $week < 30>>
@@ -16,10 +16,10 @@
 	<<else>>
 		<<set _attackChance = 20>>
 	<</if>>
-	<<if $battlesCount > 0>>
+	<<if $SecExp.battles.victories + $SecExp.battles.losses > 0>>
 		<<set _attackChance = 25>>
 	<</if>>
-	<<if $lastAttackWeeks >= 10>>
+	<<if $SecExp.battles.lastEncounterWeeks >= 10>>
 		<<set _attackChance += 5>>
 	<</if>>
 <</if>>
@@ -37,7 +37,7 @@
 /* freedom fighters by high slave/citizen ratio */
 <<if random(1,100) <= _attackChance>>
 	<<set $attackThisWeek = 1>>
-	<<set $lastAttackWeeks = 0>>
+	<<set $SecExp.battles.lastEncounterWeeks = 0>>
 	<<set $leadingTroops = "assistant">>
 	<<set $chosenTactic = either("Bait and Bleed", "Blitzkrieg", "Choke Points", "Defense In Depth", "Guerrilla", "Human Wave", "Interior Lines", "Pincer Maneuver")>>
 	/* _type is the chance out of 100 of an attack of that type happening */
@@ -106,7 +106,7 @@
 		<<set $attackType = "freedom fighters">>
 	<</if>>
 <<else>>
-	<<set $lastAttackWeeks++>>
+	<<set $SecExp.battles.lastEncounterWeeks++>>
 <</if>>
 
 /* if an attack happens */
diff --git a/src/Mods/SecExp/attackHandler.tw b/src/Mods/SecExp/attackHandler.tw
index a2a2007ccdd..6f4ab74b1dd 100644
--- a/src/Mods/SecExp/attackHandler.tw
+++ b/src/Mods/SecExp/attackHandler.tw
@@ -7,7 +7,7 @@
 		<<if $battleResult == 1>>Bribery<<else>>Surrender<</if>> chosen
 	<</if>>
 	<<if $battleResult == 1>>
-		<<if $cash >= $bribeCost>>						/* if there's enough cash there's a 10% chance bribery fails. If there isn't there's instead a 50% chance it fails */
+		<<if $cash >= App.SecExp.battle.bribeCost()>> /* if there's enough cash there's a 10% chance bribery fails. If there isn't there's instead a 50% chance it fails */
 			<<if $attackType == "freedom fighters" && random(1,100) <= 50 || random(1,100) <= 10>>
 				<<set $battleResult = 0>>
 			<</if>>
diff --git a/src/Mods/SecExp/attackOptions.tw b/src/Mods/SecExp/attackOptions.tw
index 1d0c840eec3..71be491baea 100644
--- a/src/Mods/SecExp/attackOptions.tw
+++ b/src/Mods/SecExp/attackOptions.tw
@@ -14,7 +14,7 @@
 <strong> <<if $majorBattle == 1>>Major<</if>> Attack Imminent</strong>
 <hr>
 <<if $majorBattle == 0>>
-	<<if $battlesCount > 0>>
+	<<if $SecExp.battles.victories + $SecExp.battles.losses > 0>>
 		The ominous message dominates the screens of your office, and <<print $assistant.name>> quickly gathers all information available to prepare for battle.
 		<<if $attackType == "raiders">>
 			<<if App.SecExp.battle.recon() >= 1>>
@@ -54,7 +54,7 @@
 		Due to their great wealth, Free Cities inevitably become tasty morsels for anyone able to field armed men. Considering the particular needs of arcologies their supply lines tend to be delicate lifelines, often preyed upon by those who stand to gain from the free city downfall.
 	<</if>>
 <<else>>
-	<<if $majorBattlesCount > 0>>
+	<<if $SecExp.battles.major > 0>>
 		The ominous message dominates the screens of your office, and <<print $assistant.name>> quickly gathers all information available to prepare for the major battle ahead.
 	<<else>>
 		Your assistant interrupted your rest to bring the grim news. You quickly rush to your console, where you can see the satellite images coming in of the force about to crash against your arcology. It's not the first time your armies fought for the survival of your empire, but this time it seems it will be a fight for life or death.
@@ -276,28 +276,14 @@ approximately <strong><<print _estimatedMen>> men</strong> are coming, they seem
 </div>
 
 <<if _leaderFound === 1>>
-	<br>
 	<<if App.SecExp.battle.deployedUnits() > 0>>
-		<<link "Send your orders" "attackHandler">>
-			<<set $battleResult = 4>>						/* sets $battleResult value outside accepted range to avoid evaluation problems */
-			<<set $foughtThisWeek = 1>>
-		<</link>>
+		<br>[[Send your orders|attackHandler][$battleResult = 4, $foughtThisWeek = 1]] /* sets $battleResult value outside accepted range (-3, 3) to avoid evaluation problems */
 	<<else>>
-		You need at least a unit in your roster to proceed to battle.
+		<br>You need at least a unit in your roster to proceed to battle.
 	<</if>>
-	<br>
-	<<link "Surrender" "attackReport">>
-		<<set $battleResult = -1>>
-		<<set $foughtThisWeek = 1>>
-	<</link>>
-	<br>
-	
-	<<set $bribeCost = App.SecExp.battle.bribeCost()>>
-	<<link "Attempt to bribe" "attackHandler">>
-		<<set $battleResult = 1>>
-		<<set $foughtThisWeek = 1>>
-	<</link>>
-	 //Will cost around <<print cashFormat(Math.round($bribeCost * (1 + either(-1,1) * random(2) * 0.1)))>> (estimate).//
+	<br>[[Surrender|attackReport][$battleResult = -1, $foughtThisWeek = 1]]
+	<br>[[Attempt to bribe|attackHandler][$battleResult = 1, $foughtThisWeek = 1]]
+	 //Will cost around <<print cashFormat(Math.round(App.SecExp.battle.bribeCost() * (1 + either(-1,1) * random(2) * 0.1)))>> (estimate).//
 <<else>>
 	Your leader needs to be present to proceed.
 <</if>>
@@ -441,4 +427,4 @@ approximately <strong><<print _estimatedMen>> men</strong> are coming, they seem
 			<<includeDOM App.SecExp.deployUnitMenu($mercUnits[_i], "mercs", _i)>>
 		<</for>>
 	</div>
-</div>
\ No newline at end of file
+</div>
diff --git a/src/Mods/SecExp/attackReport.tw b/src/Mods/SecExp/attackReport.tw
index 43f197998b9..c7187a119f3 100644
--- a/src/Mods/SecExp/attackReport.tw
+++ b/src/Mods/SecExp/attackReport.tw
@@ -14,38 +14,37 @@
 <<set _loot = 0>>
 
 /* result */
-<<set $battlesCount++>>
 <<if $majorBattle == 0>>
 	<<set _majorBattleMod = 1>>
 <<else>>
 	<<set _majorBattleMod = 2>>
-	<<set $majorBattlesCount++>>
+	<<set $SecExp.battles.major++>>
 <</if>>
 <<if $battleResult == 3>>
 	<strong>Victory!</strong>
 	<<set $PClossStreak = 0>>
 	<<set $PCvictoryStreak += 1>>
-	<<set $PCvictories++>>
+	<<set $SecExp.battles.victories++>>
 <<elseif $battleResult == -3>>
 	<strong>Defeat!</strong>
 	<<set $PClossStreak += 1>>
 	<<set $PCvictoryStreak = 0>>
-	<<set $PClosses++>>
+	<<set $SecExp.battles.losses++>>
 <<elseif $battleResult == 2>>
 	<strong>Partial victory!</strong>
-	<<set $PCvictories++>>
+	<<set $SecExp.battles.victories++>>
 <<elseif $battleResult == -2>>
 	<strong>Partial defeat!</strong>
-	<<set $PClosses++>>
+	<<set $SecExp.battles.losses++>>
 <<elseif $battleResult == -1>>
 	<strong>We surrendered</strong>
-	<<set $PClosses++>>
+	<<set $SecExp.battles.losses++>>
 <<elseif $battleResult == 0>>
 	<strong>Failed bribery!</strong>
-	<<set $PClosses++>>
+	<<set $SecExp.battles.losses++>>
 <<elseif $battleResult == 1>>
 	<strong>Successful bribery!</strong>
-	<<set $PCvictories++>>
+	<<set $SecExp.battles.victories++>>
 <</if>>
 <hr>
 
@@ -668,7 +667,7 @@
 	<<elseif $attackType == "old world">>
 		<<run repX(750 * _majorBattleMod, "war")>>
 	<</if>>
-	<<run cashX(forceNeg($bribeCost), "war")>>
+	<<run cashX(forceNeg(App.SecExp.battle.bribeCost()), "war")>>
 <</if>>
 <<if !Number.isInteger($lowerClass)>>
 	<<if isNaN($lowerClass)>>
@@ -1508,7 +1507,6 @@
 <</if>>
 
 /* resets variables */
-<<run delete $bribeCost>>
 <<set $leaderWounded = 0>>
 <<set $gainedWarfare = 0>>
 <<set $tacticsSuccessful = 0>>
diff --git a/src/Mods/SecExp/buildings/secBarracks.tw b/src/Mods/SecExp/buildings/secBarracks.tw
index e1242f9f549..fcce979b6db 100644
--- a/src/Mods/SecExp/buildings/secBarracks.tw
+++ b/src/Mods/SecExp/buildings/secBarracks.tw
@@ -56,7 +56,7 @@ While this a sore sight for many citizens of $arcologies[0].name, the barracks s
 		<<set _reasons = [], _cost = Math.ceil((750000*(1.15+(App.SF.upgrades.total()/1000))*(1.15+($SF.Squad.Firebase/10)))*App.SF.env())>>
 		<br> _capSF might be able to provide assistance.
 		<<if $SF.Squad.Firebase > 5 && $SecExp.edicts.SFSupportLevel >= 4 && App.SecExp.battle.maxUnits() === 18 && App.SecExp.battle.deploySpeed() <= 10>>
-			<br>_capSF [[will provide the security force their own section in the Firebase.|secBarracks][$sectionInFirebase = 1, cashX(-_cost, "specialForcesCap")]]
+			<br>_capSF [[will provide the security force their own section in the Firebase.|secBarracks][$SecExp.sectionInFirebase = 1, cashX(-_cost, "specialForcesCap")]]
 			@@.red;<<print cashFormat(_cost)>>@@
 		<</if>>
 		<<if $SF.Squad.Firebase < 5>>
@@ -433,4 +433,4 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> (
 			<</capture>>
 		<</for>>
 	</div>
-</div>
\ No newline at end of file
+</div>
diff --git a/src/Mods/SecExp/buildings/weaponsManufacturing.tw b/src/Mods/SecExp/buildings/weaponsManufacturing.tw
index 540ef735116..4c7ac55361e 100644
--- a/src/Mods/SecExp/buildings/weaponsManufacturing.tw
+++ b/src/Mods/SecExp/buildings/weaponsManufacturing.tw
@@ -235,4 +235,4 @@ You own <<print num($menials)>> free menial slaves. This manufacturing complex c
 	</p>
 <</if>>
 <<set _cost = Math.trunc(10000*$upgradeMultiplierArcology)>>
-<p>[[Return this sector to standard manufacturing|Main][delete $SecExp.buildings.weapManu, cashX(-_cost), "capEx"), App.Arcology.cellUpgrade($building, App.Arcology.Cell.Manufacturing, "Weapon Manufacturing", "Manufacturing")]] //Costs <<print cashFormat(_cost)>>//</p>
\ No newline at end of file
+<p>[[Return this sector to standard manufacturing|Main][delete $SecExp.buildings.weapManu, cashX(-_cost, "capEx"), App.Arcology.cellUpgrade($building, App.Arcology.Cell.Manufacturing, "Weapon Manufacturing", "Manufacturing")]] //Costs <<print cashFormat(_cost)>>//</p>
\ No newline at end of file
diff --git a/src/Mods/SecExp/edicts.tw b/src/Mods/SecExp/edicts.tw
index 9ad6f9596fb..398f19b8ab5 100644
--- a/src/Mods/SecExp/edicts.tw
+++ b/src/Mods/SecExp/edicts.tw
@@ -6,7 +6,7 @@
 <<run App.UI.tabBar.handlePreSelectedTab($tabChoice.edicts)>>
 <br>
 <button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Society')" id="tab Society">Society</button>
-<<if $battlesCount > 0 || $rebellionsCount > 0 || $mercenaries > 0>>
+<<if $SecExp.battles.victories + $SecExp.battles.losses > 0 || $SecExp.rebellions.victories + $SecExp.rebellions.losses > 0 || $mercenaries > 0>>
 	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Military')" id="tab Military">Military</button>
 <</if>>
 
diff --git a/src/Mods/SecExp/js/Unit.js b/src/Mods/SecExp/js/Unit.js
index ab68e5e9e5b..5dbe25fe50a 100644
--- a/src/Mods/SecExp/js/Unit.js
+++ b/src/Mods/SecExp/js/Unit.js
@@ -424,7 +424,7 @@ App.SecExp.trainingValueToBonusFactor = function(value) {
 
 /** Gets the bonus values provided for completing weapon manufacturing upgrades.
  * @param {string} type - unit type to check.
- * @returns {Object} bouns values after checking for completed upgrades.
+ * @returns {object} bouns values after checking for completed upgrades.
  */
 App.SecExp.getAppliedUpgrades = function(type) {
 	let hp = 0, morale = 0, def = 0, attack = 0;
@@ -472,7 +472,9 @@ App.SecExp.getAppliedUpgrades = function(type) {
 			}
 		}
 	}
-	return {attack: attack, defense: def, hp: hp, morale: morale};
+	return {
+		attack: attack, defense: def, hp: hp, morale: morale
+	};
 };
 
 App.SecExp.getEdictUpgradeVal = (function() {
diff --git a/src/Mods/SecExp/js/buildingsJS.js b/src/Mods/SecExp/js/buildingsJS.js
index 32cdf028b41..389e6a63090 100644
--- a/src/Mods/SecExp/js/buildingsJS.js
+++ b/src/Mods/SecExp/js/buildingsJS.js
@@ -164,10 +164,10 @@ App.SecExp.weapManuUpgrade = (function() {
 
 App.SecExp.propHub = (function() {
 	return {
-		Init:Init,
-		BC:BC
+		Init,
+		BC
 	};
-	
+
 	function Init() {
 		V.SecExp.buildings.propHub = {
 			recuriterOffice: 0,
@@ -183,7 +183,7 @@ App.SecExp.propHub = (function() {
 			focus: "social engineering",
 		};
 	}
-	
+
 	function BC() {
 		if (V.SecExp.buildings.pr === null) {
 			delete V.SecExp.buildings.pr;
@@ -202,12 +202,12 @@ App.SecExp.propHub = (function() {
 			V.SecExp.buildings.propHub = V.SecExp.buildings.propHub || {};
 			V.SecExp.buildings.propHub.upgrades = V.SecExp.buildings.propHub.upgrades || {};
 			V.SecExp.buildings.propHub.recruiterOffice = V.SecExp.buildings.propHub.recruiterOffice || V.recuriterOffice || V.RecuriterOffice || 0;
-			
+
 			V.SecExp.buildings.propHub.upgrades.campaign = V.SecExp.buildings.propHub.upgrades.campaign || V.SecExp.buildings.propHub.campaign || V.propCampaign || 0;
 			delete V.SecExp.buildings.propHub.campaign;
 			V.SecExp.buildings.propHub.upgrades.miniTruth = V.SecExp.buildings.propHub.upgrades.miniTruth || V.SecExp.buildings.propHub.miniTruth || V.miniTruth || 0;
 			delete V.SecExp.buildings.propHub.miniTruth;
-			
+
 			V.SecExp.buildings.propHub.upgrades.secretService = V.SecExp.buildings.propHub.upgrades.secretService || V.SecExp.buildings.propHub.secretService || V.SecExp.buildings.propHub.SS || V.secretService || 0;
 			delete V.SecExp.buildings.propHub.secretService;
 			delete V.SecExp.buildings.propHub.SS;
@@ -233,10 +233,10 @@ App.SecExp.propHub = (function() {
 
 App.SecExp.barracks = (function() {
 	return {
-		Init:Init,
-		BC:BC
+		Init,
+		BC
 	};
-	
+
 	function Init() {
 		V.SecExp.buildings.barracks = {
 			size: 0,
@@ -245,7 +245,7 @@ App.SecExp.barracks = (function() {
 			loyaltyMod: 0
 		};
 	}
-	
+
 	function BC() {
 		if (V.SecExp.buildings.barracks) {
 			delete V.SecExp.buildings.barracks.active;
@@ -265,10 +265,10 @@ App.SecExp.barracks = (function() {
 
 App.SecExp.secHub = (function() {
 	return {
-		Init:Init,
-		BC:BC
+		Init,
+		BC
 	};
-	
+
 	function Init() {
 		V.SecExp.buildings.secHub = {
 			menials: 0,
@@ -300,7 +300,7 @@ App.SecExp.secHub = (function() {
 			}
 		};
 	}
-	
+
 	function BC() {
 		if (V.secHQ || (V.SecExp.buildings.secHub && Object.entries(V.SecExp.buildings.secHub).length > 0)){
 			V.SecExp.buildings.secHub = V.SecExp.buildings.secHub || {};
@@ -341,10 +341,10 @@ App.SecExp.secHub = (function() {
 
 App.SecExp.riotCenter = (function() {
 	return {
-		Init:Init,
-		BC:BC
+		Init,
+		BC
 	};
-	
+
 	function Init() {
 		V.SecExp.buildings.riotCenter = {
 			upgrades: {
@@ -363,7 +363,7 @@ App.SecExp.riotCenter = (function() {
 			brainImplantProject: 0,
 		};
 	}
-	
+
 	function BC() {
 		if (V.riotCenter || (V.SecExp.buildings.riotCenter && Object.entries(V.SecExp.buildings.riotCenter).length > 0)) {
 			V.SecExp.buildings.riotCenter = V.SecExp.buildings.riotCenter || {};
@@ -391,8 +391,8 @@ App.SecExp.riotCenter = (function() {
 
 App.SecExp.weapManu = (function() {
 	return {
-		Init:Init,
-		BC:BC
+		Init,
+		BC,
 	};
 
 	function Init() {
@@ -406,12 +406,10 @@ App.SecExp.weapManu = (function() {
 				oldWorld: 1,
 				FC: 1,
 			},
-			upgrades: {
-				completed: [],
-			}
+			upgrades: {completed: []}
 		};
 	}
-	
+
 	function BC() {
 		if (V.weapManu || (V.SecExp.buildings.weapManu && Object.entries(V.SecExp.buildings.weapManu).length > 0)) {
 			V.SecExp.buildings.weapManu = V.SecExp.buildings.weapManu || {};
@@ -466,7 +464,7 @@ App.SecExp.weapManu = (function() {
 					}
 					V.SecExp.buildings.weapManu.upgrades.queue.push({ID: V.currentUpgrade.ID, time: V.currentUpgrade.time});
 				}
-				
+
 				if (jsDef(V.SecExp.buildings.weapManu.upgrades.current)) {
 					if (V.SecExp.buildings.weapManu.upgrades.current.time > 0) {
 						V.SecExp.buildings.weapManu.upgrades.queue.push(V.SecExp.buildings.weapManu.upgrades.current);
@@ -482,10 +480,10 @@ App.SecExp.weapManu = (function() {
 
 App.SecExp.transportHub = (function() {
 	return {
-		Init:Init,
-		BC:BC
+		Init,
+		BC
 	};
-	
+
 	function Init() {
 		V.SecExp.buildings.transportHub = {
 			airport: 1,
@@ -493,7 +491,7 @@ App.SecExp.transportHub = (function() {
 			surfaceTransport: 1,
 		};
 	}
-	
+
 	function BC() {
 		if (V.transportHub || (V.SecExp.buildings.transportHub && Object.entries(V.SecExp.buildings.transportHub).length > 0)) {
 			V.SecExp.buildings.transportHub = V.SecExp.buildings.transportHub || {};
diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js
index 2756eec8496..8fd76af1053 100644
--- a/src/Mods/SecExp/js/secExp.js
+++ b/src/Mods/SecExp/js/secExp.js
@@ -21,24 +21,23 @@ App.SecExp.generalInit = function(){
 	}
 
 	Object.assign(V.SecExp, {
-		/*
 		battles: {
 			major: 0,
-			slaveVictories : [],
+			// slaveVictories : [],
 			victories: 0,
-			victoryStreak: 0,
+			// victoryStreak: 0,
 			losses: 0,
-			lossStreak: 0,
+			// lossStreak: 0,
 			lastEncounterWeeks: 0,
-			saved: {}
-		}, */
+			// saved: {}
+		},
 		rebellions: {
 			tension: 0,
 			slaveProgress: 0,
 			citizenProgress: 0,
-			// victories: 0,
-			// losses: 0,
-			// lastEncounterWeeks: 0
+			victories: 0,
+			losses: 0,
+			lastEncounterWeeks: 0
 		},
 		core: {
 			trade: 0,
@@ -387,7 +386,7 @@ App.SecExp.battle = (function() {
 				init += 2;
 			}
 		}
-		if (V.SF.Toggle && V.SF.Active >= 1 && V.sectionInFirebase >= 1) {
+		if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.sectionInFirebase >= 1) {
 			init += 2;
 		}
 		return init;
diff --git a/src/Mods/SecExp/js/secExpBC.js b/src/Mods/SecExp/js/secExpBC.js
index 4cf9326b5b6..34e6f705c65 100644
--- a/src/Mods/SecExp/js/secExpBC.js
+++ b/src/Mods/SecExp/js/secExpBC.js
@@ -99,15 +99,16 @@ App.SecExp.generalBC = function() {
 		for (let i = 0; i < V.slaveUnits; i++) {
 			App.SecExp.fixBrokenUnit(V.slaveUnits[i]);
 		}
+
 		// V.SecExp.units.milita = V.SecExp.units.milita || {};
 		// V.SecExp.units.milita.created = V.SecExp.units.milita.created || V.createdMilitiaUnits || 0;
 		// V.SecExp.units.milita.free = V.SecExp.units.milita.free || V.militiaFreeManpower || 0;
 		// V.SecExp.units.milita.casualties = V.SecExp.units.milita.casualties || V.militiaTotalCasualties || 0;
 		// V.SecExp.units.milita.sqauds = V.SecExp.units.milita.sqauds || V.militiaUnits || [];
-
 		for (let i = 0; i < V.militiaUnits; i++) {
 			App.SecExp.fixBrokenUnit(V.militiaUnits[i]);
 		}
+
 		// V.SecExp.units.mercs = V.SecExp.units.mercs || {};
 		// V.SecExp.units.mercs.created = V.SecExp.units.mercs.created || V.createdMercUnits || 0;
 		// V.SecExp.units.mercs.free = V.SecExp.units.mercs.free || V.mercFreeManpower || 0;
@@ -149,13 +150,13 @@ App.SecExp.generalBC = function() {
 				V.SecExp.smilingMan.globalCrisisWeeks = V.globalCrisisWeeks;
 			}
 		}
-		
+
 		V.SecExp.core = V.SecExp.core || {};
 		delete V.SecExp.core.crimeCap;
 
 		V.SecExp.core.trade = V.SecExp.core.trade || V.trade || 0;
 		App.SecExp.initTrade();
-		
+
 		V.SecExp.core.authority = V.SecExp.core.authority || V.authority || 0;
 		V.SecExp.core.security = V.SecExp.core.security || V.security || 100;
 		if (jsDef(V.SecExp.security)) {
@@ -172,31 +173,33 @@ App.SecExp.generalBC = function() {
 			V.SecExp.core.crimeLow = V.crime;
 		}
 
-		/*
-		if (V.sectionInFirebase) {
-			V.SecExp.sectionInFirebase = V.sectionInFirebase;
-		}
-
 		V.SecExp.battles = V.SecExp.battles || {};
-		V.SecExp.battles.slaveVictories = V.SecExp.battles.slaveVictories || V.slaveVictories || [];
-		V.SecExp.battles.major = V.SecExp.battles.major || V.majorBattlesCount || 0;
+		// V.SecExp.battles.slaveVictories = V.SecExp.battles.slaveVictories || V.slaveVictories || [];
+		V.SecExp.battles.major = V.SecExp.battles.major || 0;
+		if (jsDef(V.majorBattlesCount)) {
+			if (V.majorBattlesCount === 0 && V.hasFoughtMajorBattleOnce === 1) {
+				V.SecExp.battles.major = 1;
+			} else {
+				V.SecExp.battles.major = V.majorBattlesCount;
+			}
+		}
 		V.SecExp.battles.victories = V.SecExp.battles.victories || V.PCvictories || 0;
-		V.SecExp.battles.victoryStreak = V.SecExp.battles.victoryStreak || V.PCvictoryStreak || 0;
+		// V.SecExp.battles.victoryStreak = V.SecExp.battles.victoryStreak || V.PCvictoryStreak || 0;
 		V.SecExp.battles.losses = V.SecExp.battles.losses || V.PClosses || 0;
-		V.SecExp.battles.lossStreak = V.SecExp.battles.lossStreak || V.PClossStreak || 0;
+		// V.SecExp.battles.lossStreak = V.SecExp.battles.lossStreak || V.PClossStreak || 0;
 		V.SecExp.battles.lastEncounterWeeks = V.SecExp.battles.lastEncounterWeeks || V.lastAttackWeeks || 0;
-		V.SecExp.battles.lastSelection = V.SecExp.battles.lastSelection || V.lastSelection || [];
-		V.SecExp.battles.saved = V.SecExp.battles.saved || {};
-		V.SecExp.battles.saved.commander = V.SecExp.battles.saved.commander || V.SavedLeader || "";
-		V.SecExp.battles.saved.sfSupport = V.SecExp.battles.saved.sfSupport || V.SavedSFI || 0;
-		*/
+		// V.SecExp.battles.lastSelection = V.SecExp.battles.lastSelection || V.lastSelection || [];
+		// V.SecExp.battles.saved = V.SecExp.battles.saved || {};
+		// V.SecExp.battles.saved.commander = V.SecExp.battles.saved.commander || V.SavedLeader || "";
+		// V.SecExp.battles.saved.sfSupport = V.SecExp.battles.saved.sfSupport || V.SavedSFI || 0;
+
 		V.SecExp.rebellions = V.SecExp.rebellions || {};
 		V.SecExp.rebellions.tension = V.SecExp.rebellions.tension || V.tension || 0;
 		V.SecExp.rebellions.slaveProgress = V.SecExp.rebellions.slaveProgress || V.slaveProgress || 0;
 		V.SecExp.rebellions.citizenProgress = V.SecExp.rebellions.citizenProgress || V.citizenProgress || 0;
-		// V.SecExp.rebellions.victories = V.SecExp.rebellions.victories || V.PCrebWon || 0;
-		// V.SecExp.rebellions.losses = V.SecExp.rebellions.losses || V.PCrebLoss || 0;
-		// V.SecExp.rebellions.lastEncounterWeeks = V.SecExp.rebellions.lastEncounterWeeks || V.lastRebellionWeeks || 0;
+		V.SecExp.rebellions.victories = V.SecExp.rebellions.victories || V.PCrebWon || 0;
+		V.SecExp.rebellions.losses = V.SecExp.rebellions.losses || V.PCrebLoss || 0;
+		V.SecExp.rebellions.lastEncounterWeeks = V.SecExp.rebellions.lastEncounterWeeks || V.lastRebellionWeeks || 0;
 		if (V.SFGear) {
 			V.SecExp.rebellions.sfArmor = V.SFGear;
 		}
@@ -224,11 +227,11 @@ App.SecExp.generalBC = function() {
 		if (jsDef(V.forceBattle)) {
 			V.SecExp.settings.battle.force = V.forceBattle;
 		}
-		
-		if (V.readiness && V.readiness === 10) {
+
+		if (V.readiness && V.readiness === 10 || V.sectionInFirebase) {
 			V.SecExp.sectionInFirebase = 1;
 		}
-		
+
 		V.SecExp.settings.unitDescriptions = V.SecExp.settings.unitDescriptions || 0;
 
 		if (!jsDef(V.SecExp.settings.battle.allowSlavePrestige)) {
@@ -279,11 +282,9 @@ App.SecExp.generalBC = function() {
 			V.SecExp.settings.rebellion.speed = V.rebellionSpeed;
 		}
 
-		if (V.SecExp.settings.battle.enabled + V.SecExp.settings.rebellion.enabled > 0) {
-			V.SecExp.settings.showStats = V.SecExp.settings.showStats || 0;
-			if (jsDef(V.showBattleStatistics)) {
-				V.SecExp.settings.showStats = V.showBattleStatistics;
-			}
+		V.SecExp.settings.showStats = V.SecExp.settings.showStats || 0;
+		if (jsDef(V.showBattleStatistics)) {
+			V.SecExp.settings.showStats = V.showBattleStatistics;
 		}
 
 		V.SecExp.buildings = V.SecExp.buildings || {};
@@ -298,10 +299,8 @@ App.SecExp.generalBC = function() {
 		V.SecExp.proclamation.cooldown = V.SecExp.proclamation.cooldown || V.proclamationsCooldown || 0;
 		V.SecExp.proclamation.currency = V.SecExp.proclamation.currency || V.proclamationCurrency || "";
 		V.SecExp.proclamation.type = V.SecExp.proclamation.type || "crime";
-		if (jsDef(V.proclamationType)) {
-			if (V.proclamationType !== "none") {
-				V.SecExp.proclamation.type = V.proclamationType;
-			}
+		if (jsDef(V.proclamationType) && V.proclamationType !== "none") {
+			V.SecExp.proclamation.type = V.proclamationType;
 		}
 		/*
 		V.SecExp.rebellions.repairTime = V.SecExp.rebellions.repairTime || {};
diff --git a/src/Mods/SecExp/widgets/miscSecExpWidgets.tw b/src/Mods/SecExp/miscSecExpWidgets.tw
similarity index 100%
rename from src/Mods/SecExp/widgets/miscSecExpWidgets.tw
rename to src/Mods/SecExp/miscSecExpWidgets.tw
diff --git a/src/Mods/SecExp/potentialToDo.txt b/src/Mods/SecExp/potentialToDo.txt
index af235af81ba..2ed3f1ca266 100644
--- a/src/Mods/SecExp/potentialToDo.txt
+++ b/src/Mods/SecExp/potentialToDo.txt
@@ -1,5 +1,9 @@
 Hexall90's last merged commit: 52dde0b3
 
+- Remove unit.isDeployed as it is only used in battles and add the IDs to an array. 
+	This would require that units have unique IDs (e.g bots: -1 -> 99, milita: 100 -> 199, slaves: 200 -> 299, mercs: 300 - 399, etc).
+	It would also allow for _*RebelledID to potentially be removed.
+
 - While at it something for barracks(general? commissar?) and riot center([Insert player title there]'s Will?? Big Sister? ) too would be nice
 - While at it decoupling of propaganda slave and recruiter when?
 - Would  it be possible to add option for assigning hacker to security HQ that would work similarly to giving office for recruiter in propaganda hub? Preferably with smiling man slave giving extra bonuses there
@@ -39,4 +43,4 @@ Hexall90's last merged commit: 52dde0b3
 - It would be a start if the tactics talking about the size difference of the armies actually took the size difference into account.
 - How about to start off with option to send one or two of your combat trained slaves to assist the merc's when they are on a raid with the possibility of receiving battle wounds.
 - If there are choices, they should be along the lines of "higher risk, higher reward" (defeating the enemy with fewer casualties and damage if it goes right, but suffering higher casualties and damage if it goes wrong), or things like accepting more/less military casualties for better/worse protection of economic assets (costing money/damaging economy) and civilians (costing reputation/damaging population).
-- The ability to send units to the general to increase relationship as an alternative to sending slaves.
\ No newline at end of file
+- The ability to send units to the general to increase relationship as an alternative to sending slaves.
diff --git a/src/Mods/SecExp/rebellionGenerator.tw b/src/Mods/SecExp/rebellionGenerator.tw
index fa202752b82..43fb8ee5019 100644
--- a/src/Mods/SecExp/rebellionGenerator.tw
+++ b/src/Mods/SecExp/rebellionGenerator.tw
@@ -291,7 +291,7 @@
 /* if a rebellion fires determine amount of rebels and rebelling units */
 <<if $slaveRebellion == 1>>
 	<<set $engageRule = 0>>
-	<<set $lastRebellionWeeks = 0>>
+	<<set $SecExp.rebellions.lastEncounterWeeks = 0>>
 	<<set $leadingTroops = "assistant">>
 	/* calc how many slaves and citizens participate */
 	<<set _authFactor = Math.clamp(1 - ($SecExp.core.authority / 20000),0.4,0.6)>>
@@ -349,7 +349,7 @@
 	<<set $attackEquip = Math.clamp($SecExp.edicts.weaponsLaw + random(-2,1),0,4)>>
 <<elseif $citizenRebellion == 1>>
 	<<set $engageRule = 0>>
-	<<set $lastRebellionWeeks = 0>>
+	<<set $SecExp.rebellions.lastEncounterWeeks = 0>>
 	<<set $leadingTroops = "assistant">>
 	/* calc how many citizens participate */
 	<<set _authFactor = Math.clamp(1 - ($SecExp.core.authority / 20000),0.4,0.6)>>
@@ -406,5 +406,5 @@
 	<</for>>
 	<<set $attackEquip = Math.clamp($SecExp.edicts.weaponsLaw + random(-1,1),0,4)>>
 <<else>>
-	<<set $lastRebellionWeeks++>>
+	<<set $SecExp.rebellions.lastEncounterWeeks++>>
 <</if>>
\ No newline at end of file
diff --git a/src/Mods/SecExp/rebellionReport.tw b/src/Mods/SecExp/rebellionReport.tw
index 1c00ecdf340..c627294c58f 100644
--- a/src/Mods/SecExp/rebellionReport.tw
+++ b/src/Mods/SecExp/rebellionReport.tw
@@ -9,22 +9,21 @@
 <</if>>
 <<set $SecExp.core.totalKills += $enemyLosses>>
 <<set $losses = Math.trunc($losses)>>
-<<set $rebellionsCount++>>
 <<if $battleResult == 3>>
 	<strong>Victory!</strong>
-	<<set $PCrebWon++>>
+	<<set $SecExp.rebellions.victories++>>
 <<elseif $battleResult == -3>>
 	<strong>Defeat!</strong>
-	<<set $PCrebLoss++>>
+	<<set $SecExp.rebellions.losses++>>
 <<elseif $battleResult == 2>>
 	<strong>Partial victory!</strong>
-	<<set $PCrebWon++>>
+	<<set $SecExp.rebellions.victories++>>
 <<elseif $battleResult == -2>>
 	<strong>Partial defeat!</strong>
-	<<set $PCrebLoss++>>
+	<<set $SecExp.rebellions.losses++>>
 <<elseif $battleResult == -1>>
 	<strong>We surrendered</strong>
-	<<set $PCrebLoss++>>
+	<<set $SecExp.rebellions.losses++>>
 <</if>>
 <hr>
 
diff --git a/src/Mods/SecExp/securityReport.tw b/src/Mods/SecExp/securityReport.tw
index 979f0409318..f3c72d51401 100644
--- a/src/Mods/SecExp/securityReport.tw
+++ b/src/Mods/SecExp/securityReport.tw
@@ -142,13 +142,14 @@
 	Your military is the size of a small army. Security is easier to maintain with such forces at your disposal.
 	<<set _secGrowth += 0.5>>
 <</if>>
-<<if $lastAttackWeeks < 3 && $battlesCount > 0>>
+<<set _count = $SecExp.battles.victories + $SecExp.battles.losses>>
+<<if $SecExp.battles.lastEncounterWeeks < 3 && _count > 0>>
 	The recent attack has a negative effect on the security of the arcology.
 	<<set _secGrowth -= 1>>
-<<elseif $lastAttackWeeks < 5 && $battlesCount > 0>>
+<<elseif $SecExp.battles.lastEncounterWeeks < 5 && _count > 0>>
 	While some time has passed, the last attack still has a negative effect on the security of the arcology.
 	<<set _secGrowth -= 0.5>>
-<<elseif $battlesCount > 0>>
+<<elseif _count > 0>>
 	The arcology has not been attacked in a while, which has a positive effect on security.
 	<<set _secGrowth += 0.5>>
 <</if>>
diff --git a/src/Mods/SecExp/tradeReport.tw b/src/Mods/SecExp/tradeReport.tw
index 9ae708d0bec..266aa0a62f7 100644
--- a/src/Mods/SecExp/tradeReport.tw
+++ b/src/Mods/SecExp/tradeReport.tw
@@ -17,17 +17,19 @@
 <</if>>
 
 <<set _tradeChange = 0>>
-<<if $lastAttackWeeks < 2 && $battlesCount > 0>>
+<<set _countBattles = $SecExp.battles.victories + $SecExp.battles.losses>>
+<<set _countRebellions = $SecExp.rebellions.victories + $SecExp.rebellions.losses>>
+<<if $SecExp.battles.lastEncounterWeeks < 2 && _countBattles > 0>>
 	The recent attack has a negative effect on the trade of the arcology.
 	<<set _tradeChange -= 1>>
-<<elseif $lastAttackWeeks < 4 && $battlesCount > 0>>
+<<elseif $SecExp.battles.lastEncounterWeeks < 4 && _countBattles > 0>>
 	While some time has passed, the last attack still has a negative effect on the commercial activity of the arcology.
 	<<set _tradeChange -= 0.5>>
 <</if>>
-<<if $lastRebellionWeeks < 2 && $rebellionsCount > 0>>
+<<if $SecExp.rebellions.lastEncounterWeeks < 2 && _countRebellions > 0>>
 	The recent rebellion has a negative effect on the trade of the arcology.
 	<<set _tradeChange -= 1>>
-<<elseif $lastRebellionWeeks < 4 && $rebellionsCount > 0>>
+<<elseif $SecExp.rebellions.lastEncounterWeeks < 4 && _countRebellions > 0>>
 	While some time has passed, the last rebellion still has a negative effect on the commercial activity of the arcology.
 	<<set _tradeChange -= 0.5>>
 <</if>>
diff --git a/src/uncategorized/manageArcology.tw b/src/uncategorized/manageArcology.tw
index 1c5ce20a3b0..123c752ec21 100644
--- a/src/uncategorized/manageArcology.tw
+++ b/src/uncategorized/manageArcology.tw
@@ -530,29 +530,29 @@
 	</p>
 <</if>>
 
-<<if $secExpEnabled > 0 && $SecExp.settings.battle.enabled == 1>>
+<<if $secExpEnabled > 0>>
+	<<set _countBattles = $SecExp.battles.victories + $SecExp.battles.losses>>
+	<<set _countRebellions = $SecExp.rebellions.victories + $SecExp.rebellions.losses>>
 	<p>
 	<<if $SF.Toggle === 0||$SF.Active === 0>>
 		Your army counts <<print num(App.SecExp.Manpower.employedOverall)>> total soldiers.
 	<<elseif $SF.Toggle && $SF.Active >= 1>>
 		Your army counts <<print num(App.SecExp.Manpower.employedOverall + $SF.ArmySize)>> total soldiers of which <<print num($SF.ArmySize)>> under the special force command and the rest under your direct control.
 	<</if>>
-	<<if $battlesCount > 0>>
-		Your troops were involved in <<print num($battlesCount)>> battles of which <<print num($majorBattlesCount)>> were major engagements. You won
-		<<if $battlesCount == $PCvictories>>
-			all of them.
-		<<elseif $battlesCount == $PClosses>>
-			none of them.
+	<<if $SecExp.settings.battle.enabled === 1 && _countBattles > 0>>
+		Your troops were involved in <<print num(_countBattles)>> battles of which <<print num($SecExp.battles.major)>> were major engagements.
+		<<if _countBattles === $SecExp.battles.victories>>
+			You won all of them.
+		<<elseif _countBattles === $SecExp.battles.losses>>
+			You won none of them.
 		<<else>>
-			<<print num($PCvictories)>> of them, while the enemy managed to gain the upper hand in the other <<print num($PClosses)>>.
+			You won <<print num($SecExp.battles.victories)>> of them, while the enemy managed to gain the upper hand in the other <<print num($SecExp.battles.losses)>>.
 		<</if>>
+		During all battles you lost a total of <<print num($militiaTotalCasualties + $slavesTotalCasualties + $mercTotalCasualties)>> men, while scoring a total of <<print num($SecExp.core.totalKills)>> kills.
 	<</if>>
-
-	<<if $rebellionsCount >= 1>>
-		Your arcology was involved in <<print num($rebellionsCount)>> rebellions. You won <<print num($PCrebWon)>> of them, while the rebels defeated your forces in <<print num($PCrebLoss)>>.
+	<<if $SecExp.settings.battle.enabled === 1 && _countRebellions > 0>>
+		Your arcology was involved in <<print num(_countRebellions)>> rebellions. You won <<print num($SecExp.rebellions.victories)>> of them, while the rebels defeated your forces in <<print num($SecExp.rebellions.losses)>>.
 	<</if>>
-
-	During all battles you lost a total of <<print num($militiaTotalCasualties + $slavesTotalCasualties + $mercTotalCasualties)>> men, while scoring a total of <<print num($totalKills)>> kills.
 	</p>
 <</if>>
 
diff --git a/src/uncategorized/scheduledEvent.tw b/src/uncategorized/scheduledEvent.tw
index f929fe48ef5..8eb66b68f5a 100644
--- a/src/uncategorized/scheduledEvent.tw
+++ b/src/uncategorized/scheduledEvent.tw
@@ -86,10 +86,8 @@
 	<<set $fcnn.push("...evidence of a planned slave uprising, executed all of their arcology's several thousand...")>>
 <</if>>
 
-<<if $secExpEnabled > 0>>
-	<<if $SecExp.settings.battle.enabled > 0>>
-		<<include "attackGenerator">>
-	<</if>>
+<<if $secExpEnabled > 0 && $SecExp.settings.battle.enabled > 0>>
+	<<include "attackGenerator">>
 <</if>>
 
 <<if $rivalOwner == -1>>
-- 
GitLab