From 4cad050cfa648ba2156162e37862178a5d28d7e3 Mon Sep 17 00:00:00 2001
From: x <okp57855@psoxs.com>
Date: Mon, 24 Sep 2018 18:51:23 +1200
Subject: [PATCH] I

---
 src/init/storyInit.tw                         |  65 +------
 .../SecForceEX/Firebase.tw}                   |   0
 src/{js/SFJS.tw => pregmod/SecForceEX/JS.js}  |   0
 .../SecForceEX/Proposal.tw}                   |   0
 .../SecForceEX/Report.tw}                     |   0
 ...cialForceUpgradeOptions.tw => Upgrades.tw} |   0
 src/uncategorized/BackwardsCompatibility.tw   | 166 +++++++++---------
 7 files changed, 81 insertions(+), 150 deletions(-)
 rename src/{uncategorized/SFMBarracks.tw => pregmod/SecForceEX/Firebase.tw} (100%)
 rename src/{js/SFJS.tw => pregmod/SecForceEX/JS.js} (100%)
 rename src/{uncategorized/securityForceProposal.tw => pregmod/SecForceEX/Proposal.tw} (100%)
 rename src/{uncategorized/securityForceEOWReport.tw => pregmod/SecForceEX/Report.tw} (100%)
 rename src/pregmod/SecForceEX/{SpecialForceUpgradeOptions.tw => Upgrades.tw} (100%)

diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw
index 01cbe94b640..58318c9d451 100644
--- a/src/init/storyInit.tw
+++ b/src/init/storyInit.tw
@@ -1319,70 +1319,7 @@ DairyRestraintsSetting($dairyRestraintsSetting)
 
 /* INCORPORATED MODS */
 
-/* Special Force Variables [SFVAR] */
-
-/* Extra content enabling */
-<<set $SFMODToggle = 0>>						/* Does the player want to see the SF module at all? */
-
-/* Initial events and presentation logic */
-<<set $securityForceCreate = 0>> 					/* Has the player chosen to create the SF? Used for initial events */
-<<set $securityForceEventSeen = 0>>					/* Has the player seen the SF event? Used to avoid re-event */
-<<set $securityForceName = "Special Force">>		/* What is the SF called? */
-<<set $securityForceActive = 0>>					/* SF is active - activates end of turn screen logic */
-
-/* SF control panel and logic */
-<<set $securityForceSubsidyActive = 0>>				/* Is the player having to subsidize the SF? */
-<<set $securityForceRecruit = 0>>					/* How many recruits has the SF attracted this week? Used in recruitment calcs */
-<<set $securityForceTrade = 0>>						/* How much trade has the SF encouraged this week? Used for rep calcs */
-<<set $securityForceBooty = 0>>						/* How much money has the SF made this week? Used in money calcs */
-<<set $securityForceIncome = 0>>					/* What was the final, adjusted take for the SF this week? Used for EOW text */
-<<set $securityForceProfitable = 0>>				/* Is the SF profitable? Used for EOW text */
-<<set $securityForceFocus = "recruit">>				/* What is the SF's assigned job? */
-<<set $securityForceRulesOfEngagement = "hold">>	/* What are the SF's ROE outside the arcology? */
-<<set $securityForceAccountability = "strict">>		/* Is the SF being held accountable for its actions outside the arcology? */
-<<set $securityForceDepravity = 0>>					/* How depraved has the SF become? Used for flavor text injections. */
-<<set $securityForceUpgradeToken = 0>>				/* Flag to keep track of single upgrade/week. */
-<<set $securityForceGiftToken = 0>>					/* Flag to keep track of single gift/week. */
-
-/* Personnel/Gear */
-<<set $securityForceArcologyUpgrades = 0>>			/* How many militarized arcology upgrades has the player bought? */
-<<set $securityForcePersonnel = 40>> 				/* How big is the SF? Maxes out at battalion/regimental (~1500) strength */
-<<set $securityForceInfantryPower = 0>>				/* How many infantry upgrades has the player bought? */
-<<set $securityForceStimulantPower = 0>>			/* How many stimulant upgrades has the player bought? */
-<<set $securityForceVehiclePower = 0>>				/* How many vehicle upgrades has the player bought? */
-<<set $securityForceHeavyBattleTank = 0>>			/* Has the SF found a busted down heavy battle tank begging for work? */
-<<set $securityForceAircraftPower = 0>>				/* How many aircraft upgrades has the player bought? */
-<<set $securityForceSpacePlanePower = 0>>			/* Has the SF found a busted down spaceplane begging for work? */
-<<set $securityForceFortressZeppelin = 0>>			/* Has the SF found a busted down fortress zeppelin begging for work? */
-<<set $securityForceAC130 = 0>>						/* Has the SF found a busted down AC-130 begging for work? */
-<<set $securityForceHeavyTransport = 0>>			/* Has the SF found a busted down heavy yransport begging for work? */
-<<set $securityForceDronePower = 0>>				/* How many drone upgrades has the player bought? */
-<<set $securityForceSatellitePower = 0>>			/* Has the SF commendeered a Satellite relay? */
-<<set $securityForceGiantRobot = 0>>				/* Has the player assembled a makeshift giant robot */
-<<set $securityForceMissileSilo = 0>>				/* Has the SF found a disused missile silo in need of reassignement?*/
-<<set $securityForceAircraftCarrier = 0>> 			/* Has the SF found a busted down aircraft carrier begging for work? */
-<<set $securityForceSubmarine = 0>>					/* Has the SF found a busted down submarine begging for work? */
-<<set $securityForceHeavyAmphibiousTransport = 0>>	/* Has the SF found a busted down heavy amphibious transport begging for work? */
-<<set $securityForceMissionEfficiency = 1>>			/* How efficient is the SF at completing its assigned task? (Upgrades*Drug Multiplier) */
-
-/* SupportFacility */
-<<set $SupportFacility = 0>>						/* Is the support facility built ? */
-
-/* Colonel */
-<<set $securityForceSexedColonelToken = 0>>			/* Has the player sexed The Colonel this week? */
-<<set $ColonelCore = "">>							/* What is the core of The Colonel? */
-<<set $securityForceColonelToken = 0>>				/* Flag to keep track of talking to The Colonel. */
-<<set $securityForceColonelSexed = 0>>				/* Has the player sexed The Colonel this week? */
-
-/* TradeShow */
-<<set $TradeShowAttendanceGranted = 0>>				/* Has The Colonel been allowed to go the TradeShow? */
-<<set $OverallTradeShowAttendance = 0>>				/* how many times has The Colonel gone to the TradeShow */
-<<set $CurrentTradeShowAttendance = 0>>				/* Has The Colonel attended the current TradeShow? */
-<<set $TradeShowIncome = 0>>						/* How much was The Colonel able to make at the TradeShow selling generic scematics? */
-<<set $TotalTradeShowIncome = 0>>					/* Total TradeShowIncome */
-<<set $TradeShowHelots = 0>>						/* How many menail slaves were sent as a bonus from generic scematic sales during the current TradeShow?
-<<set $TotalTradeShowHelots = 0>>					/* Total number of menail slaves acquired via the Trade Show */
-
+/*SFVAR*/ <<set $SF = Object.assign({}, $SF, {Toggle:0, Active: -1})>>
 
 /* Misc mod variables */
 <<set $recruiterEugenics = 0>>
diff --git a/src/uncategorized/SFMBarracks.tw b/src/pregmod/SecForceEX/Firebase.tw
similarity index 100%
rename from src/uncategorized/SFMBarracks.tw
rename to src/pregmod/SecForceEX/Firebase.tw
diff --git a/src/js/SFJS.tw b/src/pregmod/SecForceEX/JS.js
similarity index 100%
rename from src/js/SFJS.tw
rename to src/pregmod/SecForceEX/JS.js
diff --git a/src/uncategorized/securityForceProposal.tw b/src/pregmod/SecForceEX/Proposal.tw
similarity index 100%
rename from src/uncategorized/securityForceProposal.tw
rename to src/pregmod/SecForceEX/Proposal.tw
diff --git a/src/uncategorized/securityForceEOWReport.tw b/src/pregmod/SecForceEX/Report.tw
similarity index 100%
rename from src/uncategorized/securityForceEOWReport.tw
rename to src/pregmod/SecForceEX/Report.tw
diff --git a/src/pregmod/SecForceEX/SpecialForceUpgradeOptions.tw b/src/pregmod/SecForceEX/Upgrades.tw
similarity index 100%
rename from src/pregmod/SecForceEX/SpecialForceUpgradeOptions.tw
rename to src/pregmod/SecForceEX/Upgrades.tw
diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw
index 70c89d2a1c4..0337e732933 100644
--- a/src/uncategorized/BackwardsCompatibility.tw
+++ b/src/uncategorized/BackwardsCompatibility.tw
@@ -914,7 +914,6 @@
 /*SFVAR*/
 <<if def $SF && $SFSaveRepair === 1>>
 	<<set $SFMODToggle = $SF.Toggle>>
-	<<set $SF.Toggle = undefined>>
 	<<if $SF.Active >= 1>>
 		<<set $securityForceActive = 1,$securityForceCreate = 1,$securityForceEventSeen = 1>>
 	<<else>>
@@ -952,93 +951,88 @@
 		<<if $securityForceStimulantPower > 5>> <<set $securityForceStimulantPower = 5>> <</if>>
 		<<if $securityForceAircraftPower > 5>> <<set $securityForceAircraftPower = 5>> <</if>>
 	<</if>>
-	<<unset $SF>>
-<</if>>
-
-<<if $SFMODToggle == 1 && $securityForceCreate == 1>>
-	/* SF anon additional Special Force Variables [SFVAR] */
-
-	/* Personnel/Gear */
-	<<if ndef $securityForceHeavyBattleTank>>
-		<<set $securityForceHeavyBattleTank = 0>>
-	<</if>>
-	<<if ndef $securityForceSpacePlanePower>>
-		<<set $securityForceSpacePlanePower = 0>>
-	<</if>>
-	<<if ndef $securityForceFortressZeppelin>>
-		<<set $securityForceFortressZeppelin = 0>>
-	<</if>>
-	<<if ndef $securityForceAC130>>
-		<<set $securityForceAC130 = 0>>
-	<</if>>
-	<<if ndef $securityForceHeavyTransport>>
-		<<set $securityForceHeavyTransport = 0>>
-	<</if>>
-	<<if ndef $securityForceSatellitePower>>
-		<<set $securityForceSatellitePower = 0>>
-	<</if>>
-	<<if $terrain != "oceanic" && $terrain != "marine">>
-		<<if ndef $securityForceGiantRobot>>
-			<<set $securityForceGiantRobot = 0>>
-		<</if>>
-		<<if ndef $securityForceMissileSilo>>
-			<<set $securityForceMissileSilo = 0>>
-		<</if>>
-	<</if>>
-	<<if $terrain == "oceanic" || $terrain == "marine">>
-		<<if ndef $HeavyAmphibiousTransport>>
-			<<set $HeavyAmphibiousTransport = 0>>
+	<<unset $SF, $SFColonel, $SFTradeShow, $SFUnit>>
+	<<set $SFSaveRepair = 0>>
+<<elseif $SFSaveRepair === 0>>
+	<<if $securityForceEventSeen === 0>> <<set $securityForceActive = -1>> <<else>> <<set $securityForceActive = 2>> <</if>>
+		<<set $SF = Object.assign({}, $SF, {Toggle:$SFMODToggle, Active:$securityForceActive})>>
+		<<unset $SFMODToggle, $securityForceActive, $securityForceCreate, $securityForceEventSeen>>
+	<</if>>
+
+	<<if $SF.Toggle === 1 && $SF.Active >= 1>>
+		<<run Object.assign($SF, {Depravity:$securityForceDepravity,
+		Units:$SFAO, MWU:$securityForceUpgradeTokenReset, U:$securityForceUpgradeToken,
+		WG:$securityForceGiftToken, SpecOps:0, SpecOpsLock:0, ROE:$securityForceRulesOfEngagement,
+		Target:$securityForceFocus, Regs:$securityForceAccountability,
+		Caps:"The Special Force", Lower:$securityForceName, Subsidy:$SubsidyActive})>>
+			<<unset $securityForceActive, $securityForceRecruit, $securityForceTrade,
+			$securityForceBooty, $securityForceIncome, $securityForceMissionEfficiency,
+			$securityForceProfitable, $TierTwoUnlock, $securityForceDepravity, $SFAO,
+			$securityForceUpgradeTokenReset, $securityForceUpgradeToken,
+			$securityForceGiftToken, $securityForceRulesOfEngagement, $securityForceFocus,
+			$securityForceAccountability, $securityForceName, $SubsidyActive>>
+		<<if $SF.Lower != "the special force">>
+			<<set $SF.Caps = $SF.Lower.replace("the ", "The ")>>
 		<</if>>
-		<<if ndef $securityForceAircraftCarrier>>
-			<<set $securityForceAircraftCarrier = 0>>
-		<</if>>
-		<<if ndef $securityForceSubmarine>>
-			<<set $securityForceSubmarine = 0>>
-		<</if>>
-	<</if>>
-
-	/* FacilitySupport */
-	<<if ndef $SupportFacility>>
-		<<set $SupportFacility = 0>>
-	<</if>>
-
-	/* Colonel /*
-	<<if ndef $ColonelCore>>
-		<<set $ColonelCore = "">>
-	<</if>>
-	<<if ndef $securityForceColonelToken>>
-		<<set $securityForceColonelToken = 0>>
-	<</if>>
-	<<if ndef $securityForceSexedColonelToken>>
-		<<set $securityForceSexedColonelToken = 0>>
-	<</if>>
-	<<if ndef $securityForceColonelSexed>>
-		<<set $securityForceColonelSexed = 0>>
-	<</if>>
-
-	/* TradeShow */
-	<<if ndef $TradeShowAttendanceGranted>>
-		<<set $TradeShowAttendanceGranted = 0>>
-	<</if>>
-	<<if ndef $OverallTradeShowAttendance>>
-		<<set $OverallTradeShowAttendance = 0>>
-	<</if>>
-	<<if ndef $CurrentTradeShowAttendance>>
-		<<set $CurrentTradeShowAttendance = 0>>
-	<</if>>
-	<<if ndef $TradeShowIncome>>
-		<<set $TradeShowIncome = 0>>
-	<</if>>
-	<<if ndef $TotalTradeShowIncome>>
-		<<set $TotalTradeShowIncome = 0>>
-	<</if>>
-	<<if ndef $TradeShowHelots>>
-		<<set $TradeShowHelots = 0>>
-	<</if>>
-	<<if ndef $TotalTradeShowHelots>>
-		<<set $TotalTradeShowHelots = 0>>
-	<</if>>
 
+		<<if ndef $ColonelCore>> <<set $ColonelCore = "">> <</if>>
+		<<if ndef $ColonelDiscussion>> <<set $ColonelDiscussion = 0>> <</if>>
+		<<if ndef $ColonelSexed>> <<set $ColonelSexed = 0>> <</if>>
+		<<set $SFColonel = Object.assign({}, $SFColonel = {Core:$ColonelCore, Talk:$securityForceColonelToken,
+		Fun:$securityForceColonelSexed, Status:$ColonelRelationship})>>
+			<<unset $ColonelCore, $securityForceColonelToken, securityForceColonelSexed,
+			ColonelRelationship>>
+
+		<<if ndef $TradeShowIncome>> <<set $TradeShowIncome = 0>> <</if>>
+		<<if ndef $TotalTradeShowIncome>> <<set $TotalTradeShowIncome = 0>> <</if>>
+		<<if ndef $TradeShowHelots>> <<set $TradeShowHelots = 0>> <</if>>
+		<<if ndef $TotalTradeShowHelots>> <<set $TotalTradeShowHelots = 0>> <</if>>
+		<<set $SFTradeShow = Object.assign({}, $SFTradeShow, {History:$OverallTradeShowAttendance,
+		CanAttend:$CurrentTradeShowAttendance, Income:$TradeShowIncome,
+		Revenue:$TotalTradeShowIncome, Helots:$TradeShowHelots,
+		TotalHelots:$TotalTradeShowHelots, Mercs:0, TotalMercs:0})>>
+			<<unset $OverallTradeShowAttendance, $CurrentTradeShowAttendance,
+			$TradeShowIncome, $TotalTradeShowIncome, $TradeShowHelots,
+			$TotalTradeShowHelots>>
+		<<if $SFTradeShow.History > 0>> <<set $SFTradeShow.View = 1>> <</if>>
+
+		<<if ndef $securityForceHeavyBattleTank>>
+			<<set $securityForceHeavyBattleTank = 0>> <</if>>
+		<<if ndef $securityForceSpacePlanePower>>
+			<<set $securityForceSpacePlanePower = 0>> <</if>>
+		<<if ndef $securityForceAC130>> <<set $securityForceAC130 = 0>> <</if>>
+		<<if ndef $securityForceSatellitePower>>
+			<<set $securityForceSatellitePower = 0>> <</if>>
+	<<if ndef $securityForceGiantRobot>>
+				<<set $securityForceGiantRobot = 0>> <</if>>
+			<<if ndef $securityForceMissileSilo>>
+				<<set $securityForceMissileSilo = 0>> <</if>>
+	<<if ndef $securityForceAircraftCarrier>>
+			<<set $securityForceAircraftCarrier = 0>> <</if>>
+		<<if ndef $securityForceSubmarine>>
+			<<set $securityForceSubmarine = 0>> <</if>>
+		<<if ndef $securityForceHeavyAmphibiousTransport>>
+			<<set $securityForceHeavyAmphibiousTransport = 0>> <</if>>
+	<<set $SFUnit = Object.assign({}, $SFUnit, {Troops:$securityForcePersonnel,
+	Armoury:$securityForceInfantryPower, Firebase:$securityForceArcologyUpgrades,
+	AV:$securityForceVehiclePower, TV:$securityForceVehiclePower,
+	Drones:$securityForceDronePower, Drugs:$securityForceStimulantPower,
+	PGT:$securityForceHeavyBattleTank,AA:$securityForceAircraftPower,
+	TA:$securityForceAircraftPower, SpacePlane:$securityForceSpacePlanePower,
+	GunS:$securityForceAC130, Satellite:$securityForceSatellitePower,
+	GiantRobot:$securityForceGiantRobot, MissileSilo:$securityForceMissileSilo,
+	AircraftCarrier:$securityForceAircraftCarrier, Sub:$securityForceSubmarine,
+	HAT:$securityForceHeavyAmphibiousTransport})>> <<set $SatLaunched = 0>>
+		<<unset $securityForcePersonnel, $securityForceInfantryPower,
+		$securityForceArcologyUpgrades, $securityForceVehiclePower,
+		$securityForceDronePower, $securityForceStimulantPower,
+		$securityForceHeavyBattleTank, $securityForceAircraftPower,
+		$securityForceSpacePlanePower,$securityForceAC130, $securityForceSatellitePower,
+		$securityForceGiantRobot, $securityForceMissileSilo,
+		$securityForceAircraftCarrier, $securityForceSubmarine, $securityForceHeavyAmphibiousTransport>>
+<</if>>
+<<if def $SF>>
+	<<if $SF.Active >= 1 && passage() === "New Game Plus">> <<silently>> <<include "Security Force Proposal">> <</silently>> <</if>>
 <</if>>
 
 <<if ndef $useSlaveSummaryTabs>>
-- 
GitLab