:: attackOptions [nobr]

<<if ndef $SecExp.settings.unitDescriptions>>
	<<set $SecExp.settings.unitDescriptions = 0>>
<</if>>
<<set $nextButton = " ", $nextLink = "attackOptions", $encyclopedia = "Battles">>

<<set _options = new App.UI.OptionsGroup()>>
<<run _options.addOption("Unit descriptions are", "unitDescriptions", $SecExp.settings)
.addValueList([["Abbreviated", 1], ["Summarized", 0]])>>
<<includeDOM _options.render()>>

<br>

<<if $majorBattle == 0>>
	<strong>Attack Imminent</strong>
<<else>>
	<strong>Major Attack Imminent</strong>
<</if>>
<hr>
<<if $majorBattle == 0>>
	<<if $hasFoughtOnce == 1>>
		The ominous message dominates the screens of your office, <<print $assistant.name>> quickly gathers all information available to prepare for battle.
		<<if $attackType == "raiders">>
			<<if App.SecExp.battle.recon() >= 1>>
				A disorganized horde of raiders is coming to your city. To such jackals your arcology surely looks like an appetizing morsel.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				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.
			<</if>>
			<br>
			Raiders 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.
		<<elseif $attackType == "free city">>
			<<if App.SecExp.battle.recon() >= 1>>
				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.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				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.
			<</if>>
			<br>
			Free City expeditions 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.
		<<elseif $attackType == "freedom fighters">>
			<<if App.SecExp.battle.recon() >= 1>>
				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.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				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.
			<</if>>
			<br>
			Freedom Fighters 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.
		<<elseif $attackType == "old world">>
			<<if App.SecExp.battle.recon() >= 1>>
				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.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				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.
			<</if>>
			<br>
			Old world expeditions 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.
		<</if>>
	<<else>>
		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.
		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 $hasFoughtMajorBattleOnce == 1>>
		The ominous message dominates the screens of your office, <<print $assistant.name>> quickly gathers all information available to prepare for battle.
		<<if $attackType == "raiders">>
			<<if App.SecExp.battle.recon() >= 1>>
				A massive, disorganized horde of raiders is coming to your city. It seems a warlord of the wastelands amassed enough men to try and obtain a slice of territory of his own; if he's not defeated there won't be a tomorrow for the arcology.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				Some of your citizens saw the massive, disorganized horde of raiders coming towards the city and quickly reported it. It seems a warlord of the wastelands amassed enough men to try and obtain a slice of territory of his own; if he's not defeated there won't be a tomorrow for the arcology.
			<</if>>
			<br>
			Raiders 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.
		<<elseif $attackType == "free city">>
			<<if App.SecExp.battle.recon() >= 1>>
				A massive, menacing column of slavers and hired mercenaries is coming to your city. The quantity of money invested in this assault is staggering; it seems you made some very powerful enemies. If they're not defeated your story will end this day.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				Some of your citizens saw the massive, menacing column of slavers and hired mercenaries and rushed to your office to bring the grim news. The quantity of money invested in this assault is staggering; it seems you made some very powerful enemies. If they're not defeated your story will end this day.
			<</if>>
			<br>
			Free City expeditions 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 low numbers.
		<<elseif $attackType == "freedom fighters">>
			<<if App.SecExp.battle.recon() >= 1>>
				A massive, dangerous army of guerrillas is gathering just outside the arcology. A huge ocean of fanatics and idealists armed with dead men's words and hope, set on erasing your fledgling empire once and for all. And this time they won't stop until your body is burnt to a crisp.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				Some of your citizens saw the massive, dangerous army of guerrillas is gathering just outside the arcology. A huge ocean of fanatics and idealists armed with dead men's words and hope, set on erasing your fledgling empire once and for all. And this time they won't stop until your body is burnt to a crisp.
			<</if>>
			<br>
			Freedom Fighters 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.
		<<elseif $attackType == "old world">>
			<<if App.SecExp.battle.recon() >= 1>>
				A massive, disciplined old world army is approaching the confines of your arcology. It seems one of the nations of the old world is determined to put your arcology to rest once and for all or die trying.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				Some of your citizens saw the massive, disciplined old world army is approaching the confines of your arcology. It seems one of the nations of the old world is determined to put your arcology to rest once and for all or die trying.
			<</if>>
			<br>
			Old world expeditions 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.
		<</if>>
	<<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.
		<br>
		<br>
		<<if $attackType == "raiders">>
			<<if App.SecExp.battle.recon() >= 1>>
				A massive, disorganized horde of raiders is coming to your city. It seems a warlord of the wastelands amassed enough men to try and obtain a slice of territory of his own; if he's not defeated there won't be a tomorrow for the arcology.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				Some of your citizens saw the massive, disorganized horde of raiders coming towards the city and quickly reported it. It seems a warlord of the wastelands amassed enough men to try and obtain a slice of territory of his own; if he's not defeated there won't be a tomorrow for the arcology.
			<</if>>
			<br>
			Raiders 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.
		<<elseif $attackType == "free city">>
			<<if App.SecExp.battle.recon() >= 1>>
				A massive, menacing column of slavers and hired mercenaries is coming to your city. The quantity of money invested in this assault is staggering; it seems you made some very powerful enemies. If they're not defeated your story will end this day.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				Some of your citizens saw the massive, menacing column of slavers and hired mercenaries and rushed to your office to bring the grim news. The quantity of money invested in this assault is staggering; it seems you made some very powerful enemies. If they're not defeated your story will end this day.
			<</if>>
			<br>
			Free City expeditions 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.
		<<elseif $attackType == "freedom fighters">>
			<<if App.SecExp.battle.recon() >= 1>>
				A massive, dangerous army of guerrillas is gathering just outside the arcology. A huge ocean of fanatics and idealists armed with dead men's words and hope, set on erasing your fledgling empire once and for all. And this time they won't stop until your body is burnt to a crisp.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				Some of your citizens saw the massive, dangerous army of guerrillas is gathering just outside the arcology. A huge ocean of fanatics and idealists armed with dead men's words and hope, set on erasing your fledgling empire once and for all. And this time they won't stop until your body is burnt to a crisp.
			<</if>>
			<br>
			Freedom Fighters 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.
		<<elseif $attackType == "old world">>
			<<if App.SecExp.battle.recon() >= 1>>
				A massive, disciplined old world army is approaching the confines of your arcology. It seems one of the nations of the old world is determined to put your arcology to rest once and for all or die trying.
				Fortunately you knew of their coming, thanks to your recon systems.
			<<else>>
				Some of your citizens saw the massive, disciplined old world army is approaching the confines of your arcology. It seems one of the nations of the old world is determined to put your arcology to rest once and for all or die trying.
			<</if>>
			<br>
			Old world expeditions 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.
		<</if>>
	<</if>>
<</if>>
<br><br>
__Recon__:
<br>
It seems your troops and your adversary will fight
<<if $battleTerrain == "rural">>
	in <strong>the rural land</strong> surrounding the free city.
<<elseif $battleTerrain == "urban">>
	in the old <strong>abandoned city</strong> surrounding the free city.
<<elseif $battleTerrain == "hills">>
	on <strong>the hills</strong> around the free city.
<<elseif $battleTerrain == "coast">>
	along <strong>the coast</strong> just outside the free city.
<<elseif $battleTerrain == "outskirts">>
	right against <strong>the walls of the arcology.</strong>
<<elseif $battleTerrain == "mountains">>
	in <strong>the mountains</strong> overlooking the arcology.
<<elseif $battleTerrain == "wasteland">>
	in <strong>the wastelands</strong> outside the free city territory.
<<elseif $battleTerrain == "error">>
	<br>@@.red;Error: failed to assign terrain.@@ battleTerrain reads "<<print $battleTerrain>>".
<<else>>
	<br>@@.red;Error: failed to read terrain.@@ battleTerrain reads "<<print $battleTerrain>>".
<</if>>
<<if App.SecExp.battle.recon() == 3>>
	Your recon capabilities are top notch. The information collected will be most likely correct or very close to be so:
<<elseif App.SecExp.battle.recon() == 2>>
	Your recon capabilities are decent. The information collected will be mostly close to the truth:
<<elseif App.SecExp.battle.recon() == 1>>
	Your recon capabilities are fairly low. The information collected will be quite inaccurate:
<<else>>
	Your recon capabilities are almost non-existent. The information collected will be wild guesses at best:
<</if>>
approximately <strong><<print $estimatedMen>> men</strong> 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.
<<elseif $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.
<<elseif $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.
<<elseif $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.
<<elseif $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.
<</if>>

<hr>
__Battle Plan__:
<br>

<<switch $leadingTroops>>
<<case "PC">>
	<<set _leader = "Personally">>
<<case "assistant">>
	<<set _leader = "$assistant.name will">>
<<case "bodyguard">>
	<<set _leader = "$Bodyguard.slaveName will">>
<<case "headGirl">>
	<<set _leader = "$HeadGirl.slaveName will">>
<<case "citizen">>
	<<set _leader = "The citizens' militia commander will">>
<<case "mercenary">>
	<<set _leader = "The mercenary commander will">>
<<case "colonel">>
	<<set _leader = App.SF.Caps() +"'s Colonel will">>
<</switch>>

/* leader assignment */
<span id="leader"><strong><<print _leader>></strong></span> lead your troops.
	<br>&nbsp;&nbsp;&nbsp;&nbsp;
	<<link "Personally join the battle">>
		<<set $leadingTroops = "PC">>
		<<set _leader = "Personally">>
		<<replace "#leader">><strong><<print _leader>></strong><</replace>>
	<</link>>
	|
	<<link "Let $assistant.name lead the troops">>
		<<set $leadingTroops = "assistant">>
		<<set _leader = "$assistant.name will">>
		<<replace "#leader">><strong><<print _leader>></strong><</replace>>
	<</link>>
	<<if $Bodyguard != 0 && $slavesOfficers == 1>>
		|
		<<link "Let your bodyguard lead your troops">>
			<<set $leadingTroops = "bodyguard">>
			<<set _leader = "$Bodyguard.slaveName will">>
			<<replace "#leader">><strong><<print _leader>></strong><</replace>>
		<</link>>
	<</if>>
	<<if $HeadGirl != 0 && $slavesOfficers == 1>>
		|
		<<link "Let your Head Girl lead your troops">>
			<<set $leadingTroops = "headGirl">>
			<<set _leader = "$HeadGirl.slaveName will">>
			<<replace "#leader">><strong><<print _leader>></strong><</replace>>
		<</link>>
	<</if>>
	<<if $militiaFounded == 1>>
		|
		<<link "Let the citizens' militia officers lead the troops">>
			<<set $leadingTroops = "citizen">>
			<<set _leader = "The citizens' militia commander will">>
			<<replace "#leader">><strong><<print _leader>></strong><</replace>>
		<</link>>
	<</if>>
	<<if $mercenaries > 0>>
		|
		<<link "Let the mercenary officers lead the troops">>
			<<set $leadingTroops = "mercenary">>
			<<set _leader = "The mercenary commander will">>
			<<replace "#leader">><strong><<print _leader>></strong><</replace>>
		<</link>>
	<</if>>
	<<if $SF.Toggle && $SF.Active >= 1 && $SF.MercCon.CanAttend === -1>>
		|
		<<link "Let The Colonel lead the troops">>
			<<set $leadingTroops = "colonel">>
			<<set _leader = App.SF.Caps() +"'s Colonel will">>
			<<replace "#leader">><strong><<print _leader>></strong><</replace>>
		<</link>>
	<</if>>

/* troop deployment */
<br><br>
<<if App.SecExp.battle.deployableUnits() > 0>>
	With your current readiness level you can send an additional <strong><<print App.SecExp.battle.deployableUnits()>></strong> units.
<</if>>
<<set _mL = $militiaUnits.length>>
<<set _sL = $slaveUnits.length>>
<<set _meL = $mercUnits.length>>

<<run App.UI.tabbar.handlePreSelectedTab($tabChoice.Options)>>

<<if App.SecExp.battle.deployableUnits() > 0>> <br>
	<<if $secBots.active == 1 && $secBots.isDeployed == 0 && $secBots.troops > 0>>
		<br> <<= App.SecExp.unit.dec($secBots, "Bots")>> <br>
		<<link "Deploy the unit" "attackOptions">>
			<<set $secBots.isDeployed = 1, $saveValid = 0>>
		<</link>>
		<br><br>
	<</if>>

	<<if $militiaUnits.length > 0 && App.SecExp.battle.deployableUnits() > 0>>
		<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'militia')" id="tab militia">Militia: ($militiaUnits.length)</button>
	<</if>>
	<<if $slaveUnits.length > 0 && App.SecExp.battle.deployableUnits() > 0>>
		<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'slaves')" id="tab slaves">Slaves: ($slaveUnits.length)</button>
	<</if>>
	<<if $mercUnits.length > 0 && App.SecExp.battle.deployableUnits() > 0>>
		<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'mercs')" id="tab mercs">Mercs: ($mercUnits.length)</button>
	<</if>>

	<div id="militia" class="tabcontent">
		<div class="content">
			<<for _i = 0; _i < _mL; _i++>>
				<<capture _i>>
				<<if $militiaUnits[_i].active == 1 && $militiaUnits[_i].isDeployed == 0 && $militiaUnits[_i].troops > 0>>
					<<= App.SecExp.unit.dec($militiaUnits[_i], "Militia")>>
					<br>
					<<link "Deploy the unit" "attackOptions">>
						<<set $militiaUnits[_i].isDeployed = 1, $saveValid = 0>>
					<</link>>
					<br>
				<</if>>
				<</capture>>
			<</for>>
		</div>
	</div>

	<div id="slaves" class="tabcontent">
		<div class="content">
			<<for _i = 0; _i < _sL; _i++>>
			<<capture _i>>
			<<if $slaveUnits[_i].active == 1 && $slaveUnits[_i].isDeployed == 0 && $slaveUnits[_i].troops > 0>>
				<<= App.SecExp.unit.dec($slaveUnits[_i], "Slaves")>>
				<br>
				<<link "Deploy the unit" "attackOptions">>
					<<set $slaveUnits[_i].isDeployed = 1, $saveValid = 0>>
				<</link>>
				<br>
			<</if>>
			<</capture>>
			<</for>>
		</div>
	</div>

	<div id="mercs" class="tabcontent">
		<div class="content">
			<<for _i = 0; _i < _meL; _i++>>
			<<capture _i>>
			<<if $mercUnits[_i].active == 1 && $mercUnits[_i].isDeployed == 0 && $mercUnits[_i].troops > 0>>
				<<= App.SecExp.unit.dec($mercUnits[_i], "Mercs")>>
				<br>
				<<link "Deploy the unit" "attackOptions">>
					<<set $mercUnits[_i].isDeployed = 1, $saveValid = 0>>
				<</link>>
				<br>
			<</if>>
			<</capture>>
			<</for>>
		</div>
	</div>
<<else>>
	<strong>Unit roster full.</strong>
<</if>>

<<if App.SecExp.conflict.deployedUnits() > 0>> <br>
		<<if App.SecExp.conflict.deployedUnits('bots')>>
			<<= App.SecExp.unit.dec($secBots, "Bots")>>
			<br>
			<<link "Remove the unit" "attackOptions">>
				<<set $secBots.isDeployed = 0, $saveValid = 0>>
			<</link>>
			<br>
		<</if>>
	<<for _i = 0; _i < _mL; _i++>>
		<<capture _i>>
		<<if $militiaUnits[_i].isDeployed == 1>>
			<<= App.SecExp.unit.dec($militiaUnits[_i], "Militia")>>
			<br>
			<<link "Remove the unit" "attackOptions">>
				<<set $militiaUnits[_i].isDeployed = 0, $saveValid = 0>>
			<</link>>
			<br>
		<</if>>
		<</capture>>
	<</for>>
	<<for _i = 0; _i < _sL; _i++>>
		<<capture _i>>
		<<if $slaveUnits[_i].isDeployed == 1>>
			<<= App.SecExp.unit.dec($slaveUnits[_i], "Slaves")>>
			<br>
			<<link "Remove the unit" "attackOptions">>
				<<set $slaveUnits[_i].isDeployed = 0, $saveValid = 0>>
			<</link>>
			<br>
		<</if>>
		<</capture>>
	<</for>>
	<<for _i = 0; _i < _meL; _i++>>
		<<capture _i>>
		<<if $mercUnits[_i].isDeployed == 1>>
			<<= App.SecExp.unit.dec($mercUnits[_i], "Mercs")>>
			<br>
			<<link "Remove the unit" "attackOptions">>
				<<set $mercUnits[_i].isDeployed = 0, $saveValid = 0>>
			<</link>>
			<br>
		<</if>>
		<</capture>>
	<</for>>
<</if>>

<<if $SF.Toggle && $SF.Active >= 1 && $majorBattle>> <br>
	<<set _options = new App.UI.OptionsGroup()>>
	<<run _options.addOption("The incoming attack's scale warrants deploying the special force.", "SFIntervention")
	.addValue("Green light", 1).on().addValue("Red light", 0).off()
	.addComment("Some upgrades will be able to support your troops even if the special force is not deployed in the fight.")>>
	<<includeDOM _options.render()>>
<</if>>

<<if $lastSelection.length > 0>> <br>
	<<link "Restore saved roster" "attackOptions">>
		<<for _i = 0; _i < $lastSelection.length; _i++>>
			<<if $lastSelection[_i] == -1>>
				<<set $secBots.isDeployed = 1>>
			<<else>>
				<<for _j = 0; _j < $militiaUnits.length; _j++>>
					<<if $lastSelection[_i] == $militiaUnits[_j].ID>>
						<<set $militiaUnits[_j].isDeployed = 1>>
						<<break>>
					<</if>>
				<</for>>
				<<for _j = 0; _j < $slaveUnits.length; _j++>>
					<<if $lastSelection[_i] == $slaveUnits[_j].ID>>
						<<set $slaveUnits[_j].isDeployed = 1>>
						<<break>>
					<</if>>
				<</for>>
				<<for _j = 0; _j < $mercUnits.length; _j++>>
					<<if $lastSelection[_i] == $mercUnits[_j].ID>>
						<<set $mercUnits[_j].isDeployed = 1>>
						<<break>>
					<</if>>
				<</for>>
			<</if>>
		<</for>>
		<<set $saveValid = 1,$leadingTroops = $SavedLeader, $SFIntervention = $SavedSFI>>
	<</link>>
<<else>>
	Restore saved roster
<</if>>
|
<<if $saveValid != 1>>
	<<link "Save current roster" "attackOptions">>
		<<if App.SecExp.conflict.deployedUnits('bots')>>
			<<set _tmp = -1>>
			<<set $lastSelection.push(_tmp)>>
		<</if>>
		<<for _i = 0; _i < $militiaUnits.length; _i++>>
			<<if $militiaUnits[_i].isDeployed == 1>>
				<<set $lastSelection.push($militiaUnits[_i].ID)>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $slaveUnits.length; _i++>>
			<<if $slaveUnits[_i].isDeployed == 1>>
				<<set $lastSelection.push($slaveUnits[_i].ID)>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $mercUnits.length; _i++>>
			<<if $mercUnits[_i].isDeployed == 1>>
				<<set $lastSelection.push($mercUnits[_i].ID)>>
			<</if>>
		<</for>>
		<<set $saveValid = 1,$SavedLeader = $leadingTroops,$SavedSFI = $SFIntervention>>
	<</link>>
<<else>>
	Save current roster
<</if>>
|
<<if App.SecExp.conflict.deployedUnits() > 0>>
	<<link "Clear current roster" "attackOptions">>
		<<set $secBots.isDeployed = 0>>
		<<for _i = 0; _i < $militiaUnits.length; _i++>>
			<<set $militiaUnits[_i].isDeployed = 0>>
		<</for>>
		<<for _i = 0; _i < $slaveUnits.length; _i++>>
			<<set $slaveUnits[_i].isDeployed = 0>>
		<</for>>
		<<for _i = 0; _i < $mercUnits.length; _i++>>
			<<set $mercUnits[_i].isDeployed = 0>>
		<</for>>
		<<set $saveValid = 0>>
	<</link>>
<<else>>
	Clear current roster
<</if>>
|
<<if $lastSelection.length > 0>>
	<<link "Clear saved roster" "attackOptions">>
		<<unset $lastSelection>>
		<<set $lastSelection = []>>
		<<set $saveValid = 0>>
	<</link>>
<<else>>
	Clear saved roster
<</if>>
<<replenishAllUnits>>

<br><br>
/* tactics */
For this battle you choose to follow <span id="tactic"><strong><<print $chosenTactic>></strong></span> tactics.
<br>
<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'defensiveTactics')" id="tab defensive tactics">Defensive tactics</button>
<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'offensiveTactics')" id="tab offensiveTactics">Offensive Tactics</button>

<div id="defensiveTactics" class="tabcontent">
	<div class="content">
		<<link "Bait and Bleed">>
			<<set $chosenTactic = "Bait and Bleed">>
			<<replace "#tactic">><strong><<print $chosenTactic>></strong><</replace>>
		<</link>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;//Combines bait and switch tactics with guerrilla style assaults, with the objective of slowly bleed the enemy.//
		<br>
		<<link "Guerrilla">>
			<<set $chosenTactic = "Guerrilla">>
			<<replace "#tactic">><strong><<print $chosenTactic>></strong><</replace>>
		<</link>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;//Involves using terrain knowledge and small fast attacks to hinder and weaken the enemy.//
		<br>
		<<link "Choke Points">>
			<<set $chosenTactic = "Choke Points">>
			<<replace "#tactic">><strong><<print $chosenTactic>></strong><</replace>>
		<</link>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;//Involves using terrain knowledge and strong fortifications in order to stop the enemy on its track.//
		<br>
		<<link "Interior Lines">>
			<<set $chosenTactic = "Interior Lines">>
			<<replace "#tactic">><strong><<print $chosenTactic>></strong><</replace>>
		<</link>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;//Involves exploiting a defender's shorter logistics lines and redeployment times in order to keep the enemy pressured.//
		<br>
		<<link "Pincer Maneuver">>
			<<set $chosenTactic = "Pincer Maneuver">>
			<<replace "#tactic">><strong><<print $chosenTactic>></strong><</replace>>
		<</link>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;//Involves letting the enemy push back the center in order to envelop their formation.//
		<br>
		<<link "Defense In Depth">>
			<<set $chosenTactic = "Defense In Depth">>
			<<replace "#tactic">><strong><<print $chosenTactic>></strong><</replace>>
		<</link>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;//Involves letting the enemy gain terrain to gain tactical superiority by alternating between delaying actions and small counterattacks.//
	</div>
</div>

<div id="offensiveTactics" class="tabcontent">
	<div class="content">
		<<link "Blitzkrieg">>
			<<set $chosenTactic = "Blitzkrieg">>
			<<replace "#tactic">><strong><<print $chosenTactic>></strong><</replace>>
		<</link>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;//Involves breaking the front of the enemy with a fast armored force concentrated into a small area.//
		<br>
		<<link "Human Wave">>
			<<set $chosenTactic = "Human Wave">>
			<<replace "#tactic">><strong><<print $chosenTactic>></strong><</replace>>
		<</link>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;//Involves assaulting the enemy with large numbers of infantry to overwhelm their lines.//
	</div>
</div>

<br>
<<if App.SecExp.conflict.deployedUnits() > 0>>
	<<link "Send your orders" "attackHandler">>
		<<set $battleResult = 4>>						/* sets $battleResult value outside accepted range to avoid evaluation problems */
		<<if $hasFoughtOnce == 0>>
			<<set $hasFoughtOnce = 1>>
		<</if>>
		<<set $foughtThisWeek = 1>>
	<</link>>
<<else>>
	You need at least a unit in your roster to proceed to battle.
<</if>>
<br>
<<link "Surrender" "attackReport">>
	<<set $battleResult = -1>>
	<<if $hasFoughtOnce == 0>>
		<<set $hasFoughtOnce = 1>>
	<</if>>
	<<set $foughtThisWeek = 1>>
<</link>>
<br>

<<set $bribeCost = App.SecExp.battle.bribeCost()>>

/* calculates bribe cost */
<<link "Attempt to bribe" "attackHandler">>
	<<set $battleResult = 1>>
	<<if $hasFoughtOnce == 0>>
		<<set $hasFoughtOnce = 1>>
	<</if>>
	<<set $foughtThisWeek = 1>>
<</link>>
<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will cost around <<print cashFormat(Math.round($bribeCost * (1 + either(-1,1) * random(2) * 0.1)))>> (estimate).//

src/Mods/SecExp/attackOptions.tw