From a4fba5eb2af49f87d9f17e851b4491dabda42752 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Thu, 29 Apr 2021 22:48:04 -0400
Subject: [PATCH] fixes

---
 src/Mods/SecExp/attackOptions.js | 131 +++++++++++++++++++------------
 1 file changed, 79 insertions(+), 52 deletions(-)

diff --git a/src/Mods/SecExp/attackOptions.js b/src/Mods/SecExp/attackOptions.js
index f7837683649..2f720bc83dc 100644
--- a/src/Mods/SecExp/attackOptions.js
+++ b/src/Mods/SecExp/attackOptions.js
@@ -28,7 +28,10 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 					} else {
 						r.push(`Some of your citizens saw the disorganized horde of raiders coming towards the city and quickly reported it. To such jackals your arcology surely looks like an appetizing morsel.`);
 					}
-					r.push(App.UI.DOM.makeElement("div", `<strong>Raiders</strong> are roaming gangs of bandits, preying on the vulnerable supply lines of Free Cities and old world nations. They are rarely equipped with decent armaments and even more rarely have any formal military training, but they make up for that with high mobility and numbers.`));
+					const div = document.createElement("div");
+					App.UI.DOM.makeElement("span", `Raiders`, "strong");
+					App.UI.DOM.makeElement("span", `are roaming gangs of bandits, preying on the vulnerable supply lines of Free Cities and old world nations. They are rarely equipped with decent armaments and even more rarely have any formal military training, but they make up for that with high mobility and numbers.`);
+					r.push(div);
 				} else if (V.SecExp.war.attacker.type === "free city") {
 					if (App.SecExp.battle.recon() >= 1) {
 						r.push(`A menacing column of slavers and hired mercenaries is coming to your city. Another free city is ready to use their best tools to hit a dangerous competitor where it hurts.`);
@@ -36,7 +39,10 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 					} else {
 						r.push(`Some of your citizens saw the menacing column of slavers and hired mercenaries and rushed to your office to bring the grim news. Another free city is ready to use their best tools to bring down a dangerous competitor.`);
 					}
-					r.push(App.UI.DOM.makeElement("div", `<strong>Free City expeditions</strong> are usually composed of mercenaries hired to take down sensible supplies or infrastructure in order to damage the enemies of their contractor. They have on average good equipment and training, together with decent mobility, making them a formidable force. Their biggest weakness however is their relatively low numbers.`));
+					const div = document.createElement("div");
+					App.UI.DOM.makeElement("span", `Free City expeditions`, "strong");
+					App.UI.DOM.makeElement("span", `are usually composed of mercenaries hired to take down sensible supplies or infrastructure in order to damage the enemies of their contractor. They have on average good equipment and training, together with decent mobility, making them a formidable force. Their biggest weakness however is their relatively low numbers.`);
+					r.push(div);
 				} else if (V.SecExp.war.attacker.type === "freedom fighters") {
 					if (App.SecExp.battle.recon() >= 1) {
 						r.push(`A dangerous looking army of guerrillas is gathering just outside the arcology. Fanatics and idealists armed with dead men's words and hope, set on erasing your fledgling empire.`);
@@ -44,7 +50,10 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 					} else {
 						r.push(`Some of your citizens saw the dangerous looking army of guerrillas is gathering just outside the arcology. Fanatics and idealists armed with dead men's words and hope, set on erasing your fledgling empire.`);
 					}
-					r.push(App.UI.DOM.makeElement("div", `<strong>Freedom Fighters</strong> are groups of individuals fighting to rid the planet of "evils" such as the Free Cities and their way of life. Lacking the strength to assault one directly they fight guerrilla style slowly starving to death their enemies. They are rarely well equipped, but with good training and mobility they are not a threat that can be taken lightly.`));
+					const div = document.createElement("div");
+					App.UI.DOM.makeElement("span", `Freedom Fighters`, "strong");
+					App.UI.DOM.makeElement("span", `are groups of individuals fighting to rid the planet of "evils" such as the Free Cities and their way of life. Lacking the strength to assault one directly they fight guerrilla style slowly starving to death their enemies. They are rarely well equipped, but with good training and mobility they are not a threat that can be taken lightly.`);
+					r.push(div);
 				} else if (V.SecExp.war.attacker.type === "old world") {
 					if (App.SecExp.battle.recon() >= 1) {
 						r.push(`A disciplined yet dusty, scruffy old world army is approaching the confines of your arcology. There's nothing better than a good war to unite the electorate and your arcology is just the perfect target.`);
@@ -52,7 +61,10 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 					} else {
 						r.push(`Some of your citizens saw the disciplined yet dusty, scruffy old world army is approaching the confines of your arcology. There's nothing better than a good war to unite the electorate and your arcology is just the perfect target.`);
 					}
-					r.push(App.UI.DOM.makeElement("div", `<strong>Old world expeditions</strong> are usually sent to secure resources and trade routes for their nation or, more often, to provide their citizens with a bogeyman to be scared of. They are usually decently equipped and trained, which together with their generous numbers make them a tough nut to crack. However, they often lack in mobility.`));
+					const div = document.createElement("div");
+					App.UI.DOM.makeElement("span", `Old world expeditions`, "strong");
+					App.UI.DOM.makeElement("span", `are usually sent to secure resources and trade routes for their nation or, more often, to provide their citizens with a bogeyman to be scared of. They are usually decently equipped and trained, which together with their generous numbers make them a tough nut to crack. However, they often lack in mobility.`);
+					r.push(div);
 				}
 			} else {
 				r.push(`Your assistant interrupted your rest to bring the grim news. You quickly rush to your console, where you can see one of the convoys supplying your arcology has been attacked and looted. It seems a group of desperate looking bandits decided it was a good idea to steal from you.`);
@@ -101,29 +113,29 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 		r.push(App.UI.DOM.makeElement("div", `<br>__Recon__: (AO: ${V.terrain})`));
 		const _estimatedMen = V.SecExp.war.estimatedMen;
 		const _expectedEquip = V.SecExp.war.expectedEquip;
-		r.push(App.UI.DOM.makeElement("div", `It seems your troops and your adversary will fight`));
+		r.push(`It seems your troops and your adversary will fight`);
 		if (V.SecExp.war.terrain === "rural") {
-			r.push(`in <strong>the rural land</strong> surrounding the free city.`);
+			r.push(`in`, App.UI.DOM.makeElement("span", `the rural land`, "strong"), `surrounding the free city.`);
 		} else if (V.SecExp.war.terrain === "urban") {
-			r.push(`in the old <strong>abandoned city</strong> surrounding the free city.`);
+			r.push(`in the old`, App.UI.DOM.makeElement("span", `abandoned city`, "strong"), `surrounding the free city.`);
 		} else if (V.SecExp.war.terrain === "hills") {
-			r.push(`on <strong>the hills</strong> around the free city.`);
+			r.push(`on`, App.UI.DOM.makeElement("span", `the hills`, "strong"), `around the free city.`);
 		} else if (V.SecExp.war.terrain === "coast") {
-			r.push(`along <strong>the coast</strong> just outside the free city.`);
+			r.push(`along`, App.UI.DOM.makeElement("span", `the coast`, "strong"), `just outside the free city.`);
 		} else if (V.SecExp.war.terrain === "outskirts") {
-			r.push(`right against <strong>the walls of the arcology.</strong>`);
+			r.push(`right against`, App.UI.DOM.makeElement("span", `the walls of the arcology.`, "strong"));
 		} else if (V.SecExp.war.terrain === "mountains") {
-			r.push(`in <strong>the mountains</strong> overlooking the arcology.`);
+			r.push(`in`, App.UI.DOM.makeElement("span", `the mountains`, "strong"), `overlooking the arcology.`);
 		} else if (V.SecExp.war.terrain === "wasteland") {
-			r.push(`in <strong>the wastelands</strong> outside the free city territory.`);
+			r.push(`in`, App.UI.DOM.makeElement("span", `the wastelands`, "strong"), `outside the free city territory.`);
 		} else if (V.SecExp.war.terrain === "international waters") {
-			r.push(`in <strong>the water surrounding</strong> the free city.`);
+			r.push(`in`, App.UI.DOM.makeElement("span", `the water surrounding`, "strong"), `the free city.`);
 		} else if (["an underwater cave", "a sunken ship", "an island"].includes(V.SecExp.war.terrain)) {
-			r.push(`in <strong>${V.SecExp.war.terrain}</strong> near the free city.`);
+			r.push(`in`, App.UI.DOM.makeElement("span", `${V.SecExp.war.terrain}`, "strong"), `near the free city.`);
 		} else if (V.SecExp.war.terrain === "error") {
-			r.push(App.UI.DOM.makeElement("div", `<span class="red">Error: failed to assign terrain.</span> SecExp.war.terrain reads: V.SecExp.war.terrain.`));
+			r.push(App.UI.DOM.makeElement("span", `Error: failed to assign terrain.`, "red"), `${V.SecExp.war.terrain} reads: ${V.SecExp.war.terrain}.`);
 		} else {
-			r.push(App.UI.DOM.makeElement("div", `<span class="red">Error: failed to read terrain.</span> SecExp.war.terrain reads: V.SecExp.war.terrain.`));
+			r.push(App.UI.DOM.makeElement("span", `Error: failed to read terrain.`, "red"), `${V.SecExp.war.terrain} reads: ${V.SecExp.war.terrain}.`);
 		}
 		if (App.SecExp.battle.recon() === 3) {
 			r.push(`Your recon capabilities are top notch. The information collected will be most likely correct or very close to be so:`);
@@ -134,31 +146,38 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 		} else {
 			r.push(`Your recon capabilities are almost non-existent. The information collected will be wild guesses at best:`);
 		}
-		r.push(`approximately <strong>_estimatedMen men</strong> are coming, they seem to be`);
+		r.push(`approximately`);
+		r.push(App.UI.DOM.makeElement("span", `${_estimatedMen} men`, "strong"));
+		r.push(`are coming, they seem to be`);
 		if (_expectedEquip <= 0) {
-			// <strong>poorly armed</strong>. Old rusty small arms are the norm with just a few barely working civilian vehicles.
+			r.push(App.UI.DOM.makeElement("span", `poorly armed.`, "strong"));
+			r.push(`Old rusty small arms are the norm with just a few barely working civilian vehicles.`);
 		} else if (_expectedEquip === 1) {
-			// <strong>lightly armed</strong>, mostly with small arms and some repurposed civilian vehicles with scattered machine gun support. There's no sign of heavy vehicles, artillery or aircraft.
+			r.push(App.UI.DOM.makeElement("span", `lightly armed,`, "strong"));
+			r.push(`mostly with small arms and some repurposed civilian vehicles with scattered machine gun support. There's no sign of heavy vehicles, artillery or aircraft.`);
 		} else if (_expectedEquip === 2) {
-			// <strong>decently armed</strong> with good quality small arms, machine guns and a few mortars. There appear to be some heavy military vehicles coming as well.
+			r.push(App.UI.DOM.makeElement("span", `decently armed`, "strong"));
+			r.push(`with good quality small arms, machine guns and a few mortars. There appear to be some heavy military vehicles coming as well.`);
 		} else if (_expectedEquip === 3) {
-			// <strong>well armed</strong> with high quality small arms, snipers, demolitions teams, heavy duty machine guns and mortars. Heavy military vehicles are numerous and a few artillery pieces are accompanying the detachment.
+			r.push(App.UI.DOM.makeElement("span", `well armed`, "strong"));
+			r.push(`with high quality small arms, snipers, demolitions teams, heavy duty machine guns and mortars. Heavy military vehicles are numerous and a few artillery pieces are accompanying the detachment.`);
 		} else if (_expectedEquip >= 4) {
-			// <strong>extremely well armed</strong> with excellent small arms and specialized teams with heavy duty infantry support weapons. Heavy presence of armored military vehicles, artillery pieces and even some attack helicopters.
+			r.push(App.UI.DOM.makeElement("span", `extremely well armed`, "strong"));
+			r.push(`with excellent small arms and specialized teams with heavy duty infantry support weapons. Heavy presence of armored military vehicles, artillery pieces and even some attack helicopters.`);
 		}
 
 		App.UI.DOM.appendNewElement("h2", node, `Battle plan`);
 		if (V.SecExp.war.commander === "bodyguard" && V.BodyguardID === 0 || V.SecExp.war.commander === "headGirl" && V.HeadGirlID === 0) {
-			r.push(`<span class="warning">Chosen leader ${V.SecExp.war.commander} cannot be found, please select another.</span>`);
+			App.UI.DOM.makeElement("span", `Chosen leader ${V.SecExp.war.commander} cannot be found, please select another.`, "warning");
 			V.SecExp.war = "PC";
 		}
+		App.Events.addParagraph(node, r);
+		r = [];
 
 		/* leader assignment */
 		_options = new App.UI.OptionsGroup();
-		let option = _options.addOption("Commander", "commander", V.SecExp.war)
-			.addValueList([["Personal", "PC"], [V.assistant.name, "assistant"]]);
-
-		node.append(_options.render());
+		let option = _options.addOption("Leader of the troops", "commander", V.SecExp.war)
+			.addValueList([["You", "PC"], [V.assistant.name, "assistant"]]);
 
 		if (V.BodyguardID !== 0 && V.SecExp.edicts.defense.slavesOfficers === 1) {
 			option.addValue("Bodyguard", "bodyguard");
@@ -167,10 +186,10 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 			option.addValue("Head Girl", "headGirl");
 		}
 		if (V.SecExp.edicts.defense.militia >= 1) {
-			option.addValue("citizens' militia officers", "citizen");
+			option.addValue("Citizens' militia officers", "citizen");
 		}
 		if (V.mercenaries > 0) {
-			option.addValue("mercenary officers", "mercenary");
+			option.addValue("Mercenary officers", "mercenary");
 		}
 		if (V.SF.Toggle && V.SF.Active >= 1 && V.SF.MercCon.CanAttend === -2) {
 			option.addValue("Colonel", "colonel");
@@ -205,7 +224,6 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 		r.push(` //Will cost around ${cashFormat(Math.round(App.SecExp.battle.bribeCost() * (1 + either(-1, 1) * random(2) * 0.1)))} (estimate).//`);
 
 		if (V.SF.Toggle && V.SF.Active >= 1 && V.majorBattle) {
-			r.push(` <br>`);
 			_options = new App.UI.OptionsGroup();
 			_options.addOption("The incoming attack's scale warrants deploying the special force.", "deploySF", V.SecExp.war)
 				.addValue("Green light", 1).on().addValue("Red light", 0).off()
@@ -299,10 +317,13 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 		} else {
 			r.push(`Clear saved roster`);
 		}
+		node.append(App.UI.DOM.generateLinksStrip(linkArray));
 
 		/* troop deployment */
 		if (App.SecExp.battle.deployableUnits() > 0) {
-			r.push(`With your current readiness level you can send an additional <strong>${App.SecExp.battle.deployableUnits()}</strong> units.`);
+			r.push(`With your current readiness level you can send an additional`);
+			r.push(App.UI.DOM.makeElement("span", String(App.SecExp.battle.deployableUnits()), "strong"));
+			r.push(`units.`);
 		}
 		node.append(App.SecExp.unit.replenishAll());
 
@@ -316,31 +337,13 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 
 		tabBar.addTab("Bots", "bots", App.SecExp.unit.deployMenu(V.SecExp.units.bots, "bots"));
 		if (V.SecExp.units.militia.squads.length > 0) {
-			tabBar.addTab("Militia", "militia", () => {
-				const frag = new DocumentFragment();
-				for (let _i = 0; _i < V.SecExp.units.militia.squads.length; _i++) {
-					node.append(App.SecExp.unit.deployMenu(V.SecExp.units.militia.squads[_i], "militia", _i));
-				}
-				return frag;
-			});
+			tabBar.addTab("Militia", "militia", militia());
 		}
 		if (V.SecExp.units.slaves.squads.length > 0) {
-			tabBar.addTab("Slaves", "slaves", () => {
-				const frag = new DocumentFragment();
-				for (let _i = 0; _i < V.SecExp.units.slaves.squads.length; _i++) {
-					node.append(App.SecExp.unit.deployMenu(V.SecExp.units.slaves.squads[_i], "slaves", _i));
-				}
-				return frag;
-			});
+			tabBar.addTab("Slaves", "slaves", slaves());
 		}
 		if (V.SecExp.units.mercs.squads.length > 0) {
-			tabBar.addTab("Mercs", "mercs", () => {
-				const frag = new DocumentFragment();
-				for (let _i = 0; _i < V.SecExp.units.mercs.squads.length; _i++) {
-					node.append(App.SecExp.unit.deployMenu(V.SecExp.units.mercs.squads[_i], "mercs", _i));
-				}
-				return frag;
-			});
+			tabBar.addTab("Mercs", "mercs", mercs());
 		}
 		node.append(tabBar.render());
 
@@ -349,5 +352,29 @@ App.Events.attackOptions = class attackOptions extends App.Events.BaseEvent {
 			.addValueList([["Abbreviated", 1], ["Summarized", 0]]);
 		node.append(_options.render());
 		return node;
+
+		function militia() {
+			const frag = new DocumentFragment();
+			for (let _i = 0; _i < V.SecExp.units.militia.squads.length; _i++) {
+				frag.append(App.SecExp.unit.deployMenu(V.SecExp.units.militia.squads[_i], "militia", _i));
+			}
+			return frag;
+		}
+
+		function slaves() {
+			const frag = new DocumentFragment();
+			for (let _i = 0; _i < V.SecExp.units.slaves.squads.length; _i++) {
+				frag.append(App.SecExp.unit.deployMenu(V.SecExp.units.slaves.squads[_i], "slaves", _i));
+			}
+			return frag;
+		}
+
+		function mercs() {
+			const frag = new DocumentFragment();
+			for (let _i = 0; _i < V.SecExp.units.mercs.squads.length; _i++) {
+				frag.append(App.SecExp.unit.deployMenu(V.SecExp.units.mercs.squads[_i], "mercs", _i));
+			}
+			return frag;
+		}
 	}
 };
-- 
GitLab