From 0ff7c8d8bdf9403141eaea9a164dbdfd03485df8 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Wed, 5 Aug 2020 17:56:14 -0400
Subject: [PATCH] fixes for bc

---
 js/003-data/gameVariableData.js | 45 -------------------------
 src/Mods/SecExp/js/secExp.js    | 58 +++++++++++++++++++--------------
 src/Mods/SecExp/js/secExpBC.js  |  3 ++
 src/js/futureSocietyJS.js       | 28 ++++++++++++----
 4 files changed, 58 insertions(+), 76 deletions(-)

diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js
index b8c33e62905..274db428506 100644
--- a/js/003-data/gameVariableData.js
+++ b/js/003-data/gameVariableData.js
@@ -379,51 +379,6 @@ App.Data.resetOnNGPlus = {
 	PCvictoryStreak: 0,
 	PClossStreak: 0,
 	foughtThisWeek: 0,
-	/* edicts */
-	edicts: {
-		alternativeRents: 0,
-		enslavementRights: 0,
-		sellData: 0,
-		propCampaignBoost: 0,
-		tradeLegalAid: 0,
-		taxTrade: 0,
-		slaveWatch: 0,
-		subsidyChurch: 0,
-		SFSupportLevel: 0,
-		limitImmigration: 0,
-		openBorders: 0,
-		weaponsLaw: 3,
-		defense: {
-			soldierWages: 1,
-			slavesOfficers: 0,
-			discountMercenaries: 0,
-			militiaFounded: 0,
-			recruitVolunteers: 0,
-			conscription: 0,
-			militaryService: 0,
-			militarizedSociety: 0,
-			militaryExemption: 0,
-			noSubhumansInArmy: 0,
-			pregExemption: 0,
-			liveTargets: 0,
-			privilege: {
-				militiaSoldier: 0,
-				slaveSoldier: 0,
-				mercSoldier: 0,
-			},
-			// Soldiers
-			martialSchool: 0,
-			eliteOfficers: 0,
-			lowerRequirements: 0,
-			// FS soldiers
-			legionTradition: 0,
-			eagleWarriors: 0,
-			ronin: 0,
-			sunTzu: 0,
-			mamluks: 0,
-			pharaonTradition: 0,
-		}
-	},
 	/* buildings */
 	secHQ: 0,
 	secMenials: 0,
diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js
index d1c3077c279..4309947856c 100644
--- a/src/Mods/SecExp/js/secExp.js
+++ b/src/Mods/SecExp/js/secExp.js
@@ -9,40 +9,50 @@ App.SecExp.generalInit = function(){
 
 	Object.assign(V.SecExp, {
 		edicts: {
-			militia: 0,
 			alternativeRents: 0,
 			enslavementRights: 0,
-			securityExemption: 0,
 			sellData: 0,
 			propCampaignBoost: 0,
+			tradeLegalAid: 0,
+			taxTrade: 0,
 			slaveWatch: 0,
 			subsidyChurch: 0,
+			SFSupportLevel: 0,
 			limitImmigration: 0,
 			openBorders: 0,
-			slavesOfficers: 0,
-			martialSchool: 0,
-			discountMercenaries: 0,
-			militaryExemption: 0,
-			lowerRquirements: 0,
-			noSubhumansInArmy: 0,
-			pregExemption: 0,
-			eliteOfficers: 0,
-			liveTargets: 0,
-			legionTradition: 0,
-			eagleWarriors: 0,
-			ronin: 0,
-			sunTzu: 0,
-			mamluks: 0,
-			pharaonTradition: 0,
 			weaponsLaw: 3,
-			soldierWages: 1,
-			militiaSoldierPrivilege: 0,
-			slaveSoldierPrivilege: 0,
-			mercSoldierPrivilege: 0,
-			tradeLegalAid: 0,
-			taxTrade: 0
+			defense: {
+				soldierWages: 1,
+				slavesOfficers: 0,
+				discountMercenaries: 0,
+				militiaFounded: 0,
+				recruitVolunteers: 0,
+				conscription: 0,
+				militaryService: 0,
+				militarizedSociety: 0,
+				militaryExemption: 0,
+				noSubhumansInArmy: 0,
+				pregExemption: 0,
+				liveTargets: 0,
+				privilege: {
+					militiaSoldier: 0,
+					slaveSoldier: 0,
+					mercSoldier: 0,
+				},
+				// Soldiers
+				martialSchool: 0,
+				eliteOfficers: 0,
+				lowerRequirements: 0,
+				// FS soldiers
+				legionTradition: 0,
+				eagleWarriors: 0,
+				ronin: 0,
+				sunTzu: 0,
+				mamluks: 0,
+				pharaonTradition: 0,
+			}
 		},
-	});
+		});
 };
 
 App.SecExp.upkeep = (function() {
diff --git a/src/Mods/SecExp/js/secExpBC.js b/src/Mods/SecExp/js/secExpBC.js
index 46a3083c947..79c59a1e7ce 100644
--- a/src/Mods/SecExp/js/secExpBC.js
+++ b/src/Mods/SecExp/js/secExpBC.js
@@ -25,6 +25,8 @@ App.SecExp.generalBC = function (){
 	V.SecExp.edicts.limitImmigration = V.SecExp.edicts.limitImmigration || V.limitImmigration || 0;
 	V.SecExp.edicts.openBorders = V.SecExp.edicts.openBorders || V.openBorders || 0;
 	V.SecExp.edicts.weaponsLaw = V.SecExp.edicts.weaponsLaw || V.weaponsLaw || 3;
+
+	V.SecExp.edicts.defense = V.SecExp.edicts.defense || {};
 	V.SecExp.edicts.defense.soldierWages = V.SecExp.edicts.defense.soldierWages || V.soldierWages || 1;
 	V.SecExp.edicts.defense.slavesOfficers = V.SecExp.edicts.defense.slavesOfficers || V.slavesOfficers || 0;
 	V.SecExp.edicts.defense.discountMercenaries = V.SecExp.edicts.defense.discountMercenaries  || V.discountMercenaries || 0;
@@ -51,6 +53,7 @@ App.SecExp.generalBC = function (){
 	V.SecExp.edicts.defense.pharaonTradition = V.SecExp.edicts.defense.pharaonTradition || V.pharaonTradition || 0;
 
 	// Priv
+	V.SecExp.edicts.defense.privilege = V.SecExp.edicts.defense.privilege || {};
 	V.SecExp.edicts.defense.privilege.militiaSoldier = V.SecExp.edicts.defense.privilege.militiaSoldier || V.militiaSoldier || 0;
 	V.SecExp.edicts.defense.privilege.slaveSoldier = V.SecExp.edicts.defense.privilege.slaveSoldier || V.slaveSoldier || 0;
 	V.SecExp.edicts.defense.privilege.mercSoldier = V.SecExp.edicts.defense.privilege.mercSoldier || V.mercSoldier || 0;
diff --git a/src/js/futureSocietyJS.js b/src/js/futureSocietyJS.js
index d1e121b9050..944ec9fc022 100644
--- a/src/js/futureSocietyJS.js
+++ b/src/js/futureSocietyJS.js
@@ -297,12 +297,16 @@ globalThis.FutureSocieties = (function() {
 			case "FSPaternalist":
 				arcology[FSLaw] = 0;
 				arcology[FSSMR] = 0;
-				V.SecExp.edicts.slaveWatch = 0;
+				if (_.get(V.SecExp.edicts)) {
+					V.SecExp.edicts.slaveWatch = 0;
+				}
 				break;
 			case "FSDegradationist":
 				arcology[FSLaw] = 0;
 				arcology[FSSMR] = 0;
-				V.SecExp.edicts.defense.liveTargets = 0;
+				if (_.get(V.SecExp.edicts)) {
+					V.SecExp.edicts.defense.liveTargets = 0;
+				}
 				break;
 			case "FSGenderRadicalist":
 				arcology.FSGenderRadicalistLawBeauty = 0;
@@ -316,7 +320,9 @@ globalThis.FutureSocieties = (function() {
 			case "FSSupremacist":
 				arcology[FSLaw] = 0;
 				arcology[FSSMR] = 0;
-				V.SecExp.edicts.defense.noSubhumansInArmy = 0;
+				if (_.get(V.SecExp.edicts)) {
+					V.SecExp.edicts.defense.noSubhumansInArmy = 0;
+				}
 				break;
 			case "FSTransformationFetishist":
 			case "FSAssetExpansionist":
@@ -326,7 +332,9 @@ globalThis.FutureSocieties = (function() {
 				arcology.FSPhysicalIdealistLaw = 0;
 				arcology.FSPhysicalIdealistSMR = 0;
 				arcology.FSPhysicalIdealistStrongFat = 0;
-				V.SecExp.edicts.defense.martialSchool = 0;
+				if (_.get(V.SecExp.edicts)) {
+					V.SecExp.edicts.defense.martialSchool = 0;
+				}
 				break;
 			case "FSHedonisticDecadence":
 				arcology.FSHedonisticDecadenceLaw = 0;
@@ -338,18 +346,24 @@ globalThis.FutureSocieties = (function() {
 				arcology.FSChattelReligionistLaw = 0;
 				arcology.FSChattelReligionistSMR = 0;
 				arcology.FSChattelReligionistCreed = 0;
-				V.SecExp.edicts.subsidyChurch = 0;
+				if (_.get(V.SecExp.edicts)) {
+					V.SecExp.edicts.subsidyChurch = 0;
+				}
 				break;
 			case "FSRepopulationFocus":
 				arcology[FSLaw] = 0;
 				arcology[FSSMR] = 0;
 				V.universalRulesChildrenBecomeBreeders = 0;
-				V.SecExp.edicts.defense.pregExemption = 0;
+				if (_.get(V.SecExp.edicts)) {
+					V.SecExp.edicts.defense.pregExemption = 0;
+				}
 				break;
 			case "FSRestart":
 				arcology[FSLaw] = 0;
 				arcology[FSSMR] = 0;
-				V.SecExp.edicts.defense.eliteOfficers = 0;
+				if (_.get(V.SecExp.edicts)) {
+					V.SecExp.edicts.defense.eliteOfficers = 0;
+				}
 				V.propOutcome = 0;
 				V.failedElite = 0;
 				break;
-- 
GitLab