From 4606b7e4a6fa0122aa73095c3124d9a1a1761162 Mon Sep 17 00:00:00 2001
From: Blank_Alt <>
Date: Mon, 25 Jan 2021 20:40:20 +1300
Subject: [PATCH] SF-fixes

---
 src/Mods/SpecialForce/FirebaseTour.tw   |  4 +-
 src/Mods/SpecialForce/SpecialForce.js   | 88 ++++++++++++-------------
 src/Mods/SpecialForce/SpecialForceBC.js | 11 ++--
 3 files changed, 50 insertions(+), 53 deletions(-)

diff --git a/src/Mods/SpecialForce/FirebaseTour.tw b/src/Mods/SpecialForce/FirebaseTour.tw
index fa6cc268829..090ca75657a 100644
--- a/src/Mods/SpecialForce/FirebaseTour.tw
+++ b/src/Mods/SpecialForce/FirebaseTour.tw
@@ -67,7 +67,7 @@ As you approach, The Colonel
 <<if random(0,100) <= 50>>
 	raises a hand in greeting and nods. She is sprawled on a couch, wearing only her combat suit tank top and fingerless gloves. She's holding a near-empty bottle of strong liquor in her hand and you can see a naked slave _girlU kneeling on the floor between her legs. The Colonel has her legs wrapped tightly around the _girlU's head, forcing the _girlU to service her if _heU wants to breathe. The Colonel is close to her climax then suddenly tenses her lower body, thus gripping the _girlU even tighter, and throws her head back in ecstasy as she orgasms. She lets out a long breath finally releasing the _girlU, giving _himU a hard smack and shouting at _himU to fuck off.
 	<br><br>
-	The Colonel finishes off her bottle, tossing it over her shoulder then leaning back on the couch and spreading her legs wide. You look down briefly, falling into your habits of inspection. Her pussy is completely devoid of hair with heavy labia in with a very large and hard clit peaking out. Beads of moisture, the result of her excitation, are visible, and you can tell from long experience that she would be tight as a vise. You return your gaze to her face to find her smirking at you. "Like what you see, <<= App.SF.ColonelStatus()>>?" She waves her hand at the plaza around her, "So do they. But you're not here for pussy. You're here to talk business. So, what's up?"
+	The Colonel finishes off her bottle, tossing it over her shoulder then leaning back on the couch and spreading her legs wide. You look down briefly, falling into your habits of inspection. Her pussy is completely devoid of hair with heavy labia with a very large and hard clit peaking out. Beads of moisture, the result of her excitation, are visible, and you can tell from long experience that she would be tight as a vise. You return your gaze to her face to find her smirking at you. "Like what you see, <<= App.SF.ColonelStatus()>>?" She waves her hand at the plaza around her, "So do they. But you're not here for pussy. You're here to talk business. So, what's up?"
 <<elseif random(0,100) > 50>>
 	is in no condition initially to greet you. She's naked except for one sock that gives you a very good view of her muscled, taut body while lunging with her feet on the table and the rest on her couch. She is face-down in a drugged-out stupor in the middle of a wide variety of powders and pills. Perhaps sensing your approach, her head suddenly shoots up and looks at you with unfocused, bloodshot eyes. "Sorry, <<= App.SF.ColonelStatus()>>," she slurs, wiping her face and weakly holding up a hand. "Hold on a second, I need something to help me out here. Long fucking night." She struggles to sit on the couch and bending over the table, loudly snorts up some of the white powder on it. "Ahhh, fuck," she says, breathing heavily.
 	<br><br>
@@ -101,7 +101,7 @@ As you approach, The Colonel
 	<<if $SF.Squad.AV+$SF.Squad.TV > 0>> <br>&nbsp;''Vehicles:''
 		<<= App.SF.UnitText('AV')>> <<= App.SF.UnitText('TV')>>
 	<</if>>
-	<<= App.SF.UnitText('PGT')>>
+	/* <<= App.SF.UnitText('PGT')>> */
 	<<= App.SF.fsIntegration.flavourText(60)>>
 	<<= App.SF.fsIntegration.flavourText(65)>>
 <</if>>
diff --git a/src/Mods/SpecialForce/SpecialForce.js b/src/Mods/SpecialForce/SpecialForce.js
index 2dbfd07e672..d1dff861ed0 100644
--- a/src/Mods/SpecialForce/SpecialForce.js
+++ b/src/Mods/SpecialForce/SpecialForce.js
@@ -168,13 +168,12 @@ App.SF.Init = function() {
 			}
 		});
 
-		for (let i = 0; i < App.SF.upgrades.list('all').length; i++) {
-			V.SF.Squad[App.SF.upgrades.list('all')[i]] = 0;
+		for (const upgrade of App.SF.upgrades.list('all')) {
+			V.SF.Squad[upgrade] = 0;
 		}
 
-		const FS_OPTIONS = App.SF.fsIntegration.list().all;
-		for (let i = 0; i < FS_OPTIONS.length; i++) {
-			V.SF.FS[FS_OPTIONS[i]] = {lv: 0, gift: 0};
+		for (const currentFS of App.SF.fsIntegration.list().all) {
+			V.SF.FS[currentFS] = {lv: 0, gift: 0};
 		}
 	}
 	// V.arcologies[0].SFRaid = 1; V.arcologies[0].SFRaidTarget = -1;
@@ -950,13 +949,12 @@ App.SF.fsIntegration = (function() {
 		} else if (V.SF.FS.Tension < 100) {
 			words += `You walk past The Colonel and move towards the common area to meet with an exclusive group of her very influential officers that are currently relaxing at their favorite table. These men and women are known for their competence, popularity, and authority within their respective divisions of ${V.SF.Lower}, they are hard to replace, and they are always looking to earn more coin; they are the perfect weak link for trickling your Future Society influences down into the Firebase. As the officers make room at their table for you to sit and join them for discussion, you spot The Colonel staring at you from afar, and she does not look happy with you. As you are her employer, she cannot stop you from speaking with her soldiers or moving around as you please, but she can tell that you are up to no good.`;
 			const confictingFSs = validityTester();
-			const FS_OPTIONS = App.SF.fsIntegration.list().all;
-			for (let i = 0; i < FS_OPTIONS.length; i++) {
-				if (!confictingFSs.includes(V.SF.FS[FS_OPTIONS]) && V.SF.FS[FS_OPTIONS[i]].lv < 100) {
-					words += createLink(FS_OPTIONS[i]);
+			for (const currentFS of App.SF.fsIntegration.list().all) {
+				if (!confictingFSs.includes(V.SF.FS[currentFS]) && V.SF.FS[currentFS].lv < 100) {
+					words += createLink(currentFS);
 				}
-				if (V.SF.FS[FS_OPTIONS[i]].gift === 0) {
-					words += createLink(FS_OPTIONS[i], 0);
+				if (V.SF.FS[currentFS].gift === 0) {
+					words += createLink(currentFS, 0);
 				}
 			}
 		}
@@ -965,7 +963,6 @@ App.SF.fsIntegration = (function() {
 
 	function flavourText(textDisplay) {
 		let words = ``, choice;
-		const FS_OPTIONS = App.SF.fsIntegration.list().all;
 
 		if (textDisplay === 5) {
 			words += `\n__FS Foods__`; choice = 'foods';
@@ -1027,12 +1024,12 @@ App.SF.fsIntegration = (function() {
 		if (textDisplay === 200) {
 			words += `\n__Colonel's gift(s)__`;
 		}
-		for (let i = 0; i < FS_OPTIONS.length; i++) {
-			if (textDisplay === 200 && V.SF.FS[FS_OPTIONS[i]].gift > 0) {
-				words += `\n` + selectedFSText(FS_OPTIONS[i]).gift + `\n`;
+		for (const currentFS of App.SF.fsIntegration.list().all) {
+			if (textDisplay === 200 && V.SF.FS[currentFS].gift > 0) {
+				words += `\n${selectedFSText(currentFS).gift}\n`;
 			}
-			if (V.SF.FS[FS_OPTIONS[i]].lv >= textDisplay) {
-				words += `\n` + selectedFSText(FS_OPTIONS[i])[choice] + `\n`;
+			if (V.SF.FS[currentFS].lv >= textDisplay) {
+				words += `\n${selectedFSText(currentFS)[choice]}\n`;
 			}
 		}
 		return words;
@@ -1620,6 +1617,7 @@ App.SF.Interactions = function() {
 };
 
 App.SF.UnitText = function(input) {
+	let text = ``;
 	const S = V.SF.Squad;
 	// Sorted by case
 	let appear = `is currently constructed in a haphazard fashion.`;
@@ -2009,9 +2007,9 @@ App.SF.UnitText = function(input) {
 				if (S.Drones >= 10) {
 					k = `A drone-to-drone network has been installed, allowing drones to swarm, maneuver, and attack targets autonomously.`;
 				}
-				return `${text4} Surveillance drones ${a}. During combat, they supply aerial intel to commanders and act as the communications network for ground forces${b} ${c} ${d} ${e} ${f} ${g} ${h} ${i} ${j} ${k}`;
+				text += `${text4} Surveillance drones ${a}. During combat, they supply aerial intel to commanders and act as the communications network for ground forces${b} ${c} ${d} ${e} ${f} ${g} ${h} ${i} ${j} ${k}`;
 			}
-			break;
+			return text;
 		case 'AV':
 			if (S.AV >= 1) {
 				const text5 = `<br>&nbsp;&nbsp;<b>Assault:</b>`;
@@ -2048,9 +2046,9 @@ App.SF.UnitText = function(input) {
 				if (S.AV >= 10) {
 					MG = `140 mm main gun can quash anything even the greatest old world nations could muster.`;
 				}
-				return `${text5} A fleet of main battle tanks ${activate} are parked in the garage${mechanics}. ${turret} The ${MG} ${ammo1} ${mg} ${fireC0} ${fireC2} ${fireC3} ${fireC1} ${engine1} ${armor2} ${armor22}`;
+				text += `${text5} A fleet of main battle tanks ${activate} are parked in the garage${mechanics}. ${turret} The ${MG} ${ammo1} ${mg} ${fireC0} ${fireC2} ${fireC3} ${fireC1} ${engine1} ${armor2} ${armor22}`;
 			}
-			break;
+			return text;
 		case 'TV':
 			if (S.TV >= 1) {
 				const text6 = `<br>&nbsp;&nbsp;<b>Transport:</b>`;
@@ -2088,9 +2086,9 @@ App.SF.UnitText = function(input) {
 				if (S.TV >= 10) {
 					engine3 = `${e0} replaced with the newest model, allowing the vehicle to get in and out of the conflict extremely quickly.`;
 				}
-				return `${text6} A fleet of infantry fighting vehicles ${B} are parked in the garage${C}. The IFVs can carry ${squad} of 6 to a firezone. The ${G1} mm autocannon supports infantry ${G2}. ${pod1} ${pod2} ${engine3} ${armor3} ${tires} ${m1} ${m2}`;
+				text += `${text6} A fleet of infantry fighting vehicles ${B} are parked in the garage${C}. The IFVs can carry ${squad} of 6 to a firezone. The ${G1} mm autocannon supports infantry ${G2}. ${pod1} ${pod2} ${engine3} ${armor3} ${tires} ${m1} ${m2}`;
 			}
-			break;
+			return text;
 		case 'PGT':
 			if (S.PGT >= 1) {
 				const text7 = `<br>&nbsp;<b>Prototype Goliath Tank:</b>`;
@@ -2126,9 +2124,9 @@ App.SF.UnitText = function(input) {
 				if (S.PGT >= 10) {
 					gun0 = `a twin-barreled railgun capable of rapidly`;
 				}
-				return `${text7} A prototype Goliath tank ${b1}${c1} its own garage housing built outside the arcology. The massive bulk is spread out over 8 tracks, two for each corner of the tank${engines4}. The turret is equipped with ${gun0} ${gun1} ${gun2}. ${cannon} ${armor5} ${armor6} ${laser} ${PGTframe}`;
+				text += `${text7} A prototype Goliath tank ${b1}${c1} its own garage housing built outside the arcology. The massive bulk is spread out over 8 tracks, two for each corner of the tank${engines4}. The turret is equipped with ${gun0} ${gun1} ${gun2}. ${cannon} ${armor5} ${armor6} ${laser} ${PGTframe}`;
 			}
-			break;
+			return text;
 		case 'AA':
 			if (S.AA >= 1) {
 				const text8 = `<br>&nbsp;&nbsp;<b>Assault:</b>`;
@@ -2163,9 +2161,9 @@ App.SF.UnitText = function(input) {
 				if (S.AA >= 10) {
 					PAI = `A piloting AI has been installed, allowing the VTOLs to perform impossible maneuvers that cannot be done by a human pilot. This removes the need for a human in the aircraft altogether.`;
 				}
-				return `${text8} ${group}. Several of the landing pads around ${V.arcologies[0].name} host groups of four fighters, ready to defend the arcology. ${scramble} The attack VTOL are currently ${W1} with a Gatling cannon${W2} ${W3}${support}. ${TAI} ${PAI} ${engines} ${lock} ${stealth}`;
+				text += `${text8} ${group}. Several of the landing pads around ${V.arcologies[0].name} host groups of four fighters, ready to defend the arcology. ${scramble} The attack VTOL are currently ${W1} with a Gatling cannon${W2} ${W3}${support}. ${TAI} ${PAI} ${engines} ${lock} ${stealth}`;
 			}
-			break;
+			return text;
 		case 'TA':
 			if (S.TA >= 1) {
 				const text9 = `<br>&nbsp;&nbsp;<b>Transport:</b>`;
@@ -2199,9 +2197,9 @@ App.SF.UnitText = function(input) {
 					engines01 = ``;
 					engines0 = `The tiltrotors have been replaced with tiltjets, allowing for much greater airspeed and acceleration.`;
 				}
-				return `${text9} A ${Num} of transport ${type} VTOL have been recommissioned for use by ${V.SF.Lower}. The VTOLs are resting on large pads near the base, ready to load either a ${capacity} tons of material. ${engines0} ${engines01} ${Armor} ${landing} ${counter} ${Radar} ${miniguns}`;
+				text += `${text9} A ${Num} of transport ${type} VTOL have been recommissioned for use by ${V.SF.Lower}. The VTOLs are resting on large pads near the base, ready to load either a ${capacity} tons of material. ${engines0} ${engines01} ${Armor} ${landing} ${counter} ${Radar} ${miniguns}`;
 			}
-			break;
+			return text;
 		case 'SP':
 			if (S.SpacePlane >= 1) {
 				const text10 = `<br>&nbsp;<b>Spaceplane:</b>`;
@@ -2234,9 +2232,9 @@ App.SF.UnitText = function(input) {
 					engine2 = ` and liquid rocket engines in orbit that can reach an equivalent Mach 25`;
 					engine20 = `experimental scramjet engines in the atmosphere that can reach Mach 15`;
 				}
-				return `${text10} A prototype spaceplane ${b5} rests in the hangar, its black fuselage gleaming. The craft is powered by ${engine20}${engine2}. ${efficiency} ${shield} ${camera} ${camera2} ${drag} ${crew} ${skin}`;
+				text += `${text10} A prototype spaceplane ${b5} rests in the hangar, its black fuselage gleaming. The craft is powered by ${engine20}${engine2}. ${efficiency} ${shield} ${camera} ${camera2} ${drag} ${crew} ${skin}`;
 			}
-			break;
+			return text;
 		case 'GunS':
 			if (S.GunS >= 1) {
 				const text11 = `<br>&nbsp;<b>Gunship:</b>`;
@@ -2273,9 +2271,9 @@ App.SF.UnitText = function(input) {
 					DFA = `; both light and heavy vehicles, and most enemy cover from above`;
 					autocannon = `; a 40 mm autocannon, and a 105 mm howitzer are mounted on`;
 				}
-				return `${text11} A large gunship ${activate2} is being refueled in the hangar. ${barrels}${autocannon} the port side of the fuselage${distance}${DFA}. ${b4} ${ammunition} ${gsSpeed} ${c2}${countermeasures} ${fuel}`;
+				text += `${text11} A large gunship ${activate2} is being refueled in the hangar. ${barrels}${autocannon} the port side of the fuselage${distance}${DFA}. ${b4} ${ammunition} ${gsSpeed} ${c2}${countermeasures} ${fuel}`;
 			}
-			break;
+			return text;
 		case 'sat':
 			if (S.Satellite.lv >= 1) {
 				const text12 = `<br>&nbsp;<b>Satellite:</b>`;
@@ -2313,9 +2311,9 @@ App.SF.UnitText = function(input) {
 				if (S.Satellite.lv >= 10) {
 					kin = `A magazine of directable tungsten rods have been mounted to the exterior of the satellite, allowing for kinetic bombardment roughly equal to a series of nuclear blasts.`;
 				}
-				return `${text12} ${loc1} ${gyro} ${thrusters} ${telemetry} ${solar} ${reactor} ${surviv} ${laser1} ${heat} ${lens} ${kin}`;
+				text += `${text12} ${loc1} ${gyro} ${thrusters} ${telemetry} ${solar} ${reactor} ${surviv} ${laser1} ${heat} ${lens} ${kin}`;
 			}
-			break;
+			return text;
 		case 'GR':
 			if (S.GiantRobot >= 1) {
 				const text13 = `<br>&nbsp;<b>Giant Robot:</b>`;
@@ -2349,9 +2347,9 @@ App.SF.UnitText = function(input) {
 				if (S.GiantRobot >= 10) {
 					missile = `Missile pods have been mounted on the shoulders.`;
 				}
-				return `${text13} A prototype giant robot ${loc} rests in a gantry along the side of the arcology. The robot is as tall as a medium-sized office building, focusing on speed over other factors. ${power} ${armor8} ${actuator} ${heatsink} The main armament is ${knife} ${cannon1}${ammo2} ${missile}`;
+				text += `${text13} A prototype giant robot ${loc} rests in a gantry along the side of the arcology. The robot is as tall as a medium-sized office building, focusing on speed over other factors. ${power} ${armor8} ${actuator} ${heatsink} The main armament is ${knife} ${cannon1}${ammo2} ${missile}`;
 			}
-			break;
+			return text;
 		case 'ms':
 			if (S.MissileSilo >= 1) {
 				const text14 = `<br>&nbsp;<b>Cruise Missile:</b>`;
@@ -2383,9 +2381,9 @@ App.SF.UnitText = function(input) {
 				if (S.MissileSilo >= 10) {
 					c8 = ` that can be tipped with either a conventional or nuclear warhead`;
 				}
-				return `${text14} ${a4} the arcology. The current missile armament is ${b2}${c8}. ${d1} ${e1} ${f1} ${g1} ${h1}`;
+				text += `${text14} ${a4} the arcology. The current missile armament is ${b2}${c8}. ${d1} ${e1} ${f1} ${g1} ${h1}`;
 			}
-			break;
+			return text;
 		case 'AC':
 			if (S.AircraftCarrier >= 1) {
 				const text15 = `<br>&nbsp;<b>Aircraft Carrier:</b>`;
@@ -2417,9 +2415,9 @@ App.SF.UnitText = function(input) {
 				if (S.AircraftCarrier >= 10) {
 					jets = `Attack VTOL from the converted for carrier capability`;
 				}
-				return `${text15} An aircraft carrier ${recom1} ${loc2}. ${jets} serve as its airpower. ${scramble1} ${power1} ${radar} ${AAG} ${torp} ${prop} ${armor9}`;
+				text += `${text15} An aircraft carrier ${recom1} ${loc2}. ${jets} serve as its airpower. ${scramble1} ${power1} ${radar} ${AAG} ${torp} ${prop} ${armor9}`;
 			}
-			break;
+			return text;
 		case 'Sub':
 			if (S.Sub >= 1) {
 				const text16 = `<br>&nbsp;<b>Submarine:</b>`;
@@ -2453,9 +2451,9 @@ App.SF.UnitText = function(input) {
 				if (S.Sub >= 10) {
 					missiles = `The submarine has been outfitted with several cruise missiles to attack land or sea-based targets.`;
 				}
-				return `${text16} An attack submarine ${recom} ${loc2}. ${reactor0}${reactor1} ${cal} ${hull} ${tubes}${torpedoes} ${sonar} ${control} ${missiles}`;
+				text += `${text16} An attack submarine ${recom} ${loc2}. ${reactor0}${reactor1} ${cal} ${hull} ${tubes}${torpedoes} ${sonar} ${control} ${missiles}`;
 			}
-			break;
+			return text;
 		case 'HAT':
 			if (S.HAT >= 1) {
 				const text17 = `<br>&nbsp;<b>Amphibious Transport:</b>`;
@@ -2491,8 +2489,8 @@ App.SF.UnitText = function(input) {
 				if (S.HAT >= 10) {
 					loadout = `An experimental loadout sacrifices all carrying capacity to instead act as a floating gun platform by mounting several rotary autocannons the deck, should the need arise.`;
 				}
-				return `${text17} An air cushion transport vehicle, or hovercraft; ${recom2}${loc2}. ${guns} ${guns2} ${fans} ${turbines} ${speed} ${skirt} ${armor10} ${ramps} ${HATframe} ${loadout}`;
+				text += `${text17} An air cushion transport vehicle, or hovercraft; ${recom2}${loc2}. ${guns} ${guns2} ${fans} ${turbines} ${speed} ${skirt} ${armor10} ${ramps} ${HATframe} ${loadout}`;
 			}
-			break;
+			return text;
 	}
 };
diff --git a/src/Mods/SpecialForce/SpecialForceBC.js b/src/Mods/SpecialForce/SpecialForceBC.js
index f749985c71a..8c7f793cece 100644
--- a/src/Mods/SpecialForce/SpecialForceBC.js
+++ b/src/Mods/SpecialForce/SpecialForceBC.js
@@ -196,12 +196,11 @@ App.SF.BC = function() {
 		V.SF.FS.Tension = V.SF.FS.Tension || -1;
 
 		if (V.SF.Toggle && V.SF.Active >= 1) {
-			const FS_OPTIONS = App.SF.fsIntegration.list().all;
-			for (let i = 0; i < FS_OPTIONS.length; i++) {
-				V.SF.FS[FS_OPTIONS[i]] = V.SF.FS[FS_OPTIONS[i]] || {};
-				V.SF.FS[FS_OPTIONS[i]].lv = V.SF.FS[FS_OPTIONS[i]].lv || 0;
-				V.SF.FS[FS_OPTIONS[i]].gift = V.SF.FS[FS_OPTIONS[i]].gift || 0;
-				delete V.SF.FS[FS_OPTIONS[i]].validOption;
+			for (const currentFS of App.SF.fsIntegration.list().all) {
+				V.SF.FS[currentFS] = V.SF.FS[currentFS] || {};
+				V.SF.FS[currentFS].lv = V.SF.FS[currentFS].lv || 0;
+				V.SF.FS[currentFS].gift = V.SF.FS[currentFS].gift || 0;
+				delete V.SF.FS[currentFS].validOption;
 			}
 
 			V.SF.UC = V.SF.UC || {};
-- 
GitLab