code:
:: rebellionOptions [nobr]

<<set $nextButton = " ", $nextLink = "rebellionOptions", $showEncyclopedia = 1, $encyclopedia = "Battles">>

<<if $slaveRebellion == 1>>
	Slave Rebellion!
<<else>>
	Citizen Rebellion!
<</if>>

<<if $slaveRebellion == 1>>
	In the end it happened, the slaves of your arcology dared took up arms and raised up against their betters. Your penthouse is flooded with reports from all over the arcology of small skirmishes between the rioting slaves and the security forces.
	It appears <<print commaNum(Math.trunc($attackTroops))>> rebels are in the streets right now, building barricades and freeing their peers. They are
	<<if $attackEquip <= 0>>
		poorly armed.
	<<elseif $attackEquip == 1>>
		lightly armed.
	<<elseif $attackEquip == 2>>
		decently armed.
	<<elseif $attackEquip == 3>>
		well armed.
	<<elseif $attackEquip >= 4>>
		extremely well armed.
	<</if>>
	<<if $irregulars > 0>>
		<<print commaNum(Math.trunc($irregulars))>> of your citizens took up arms to defend their arcology owner.
	<</if>>
	<<set _count = 0>>
	<<if $rebellingID.length > 0>>

		<<for _i = 0; _i < $militiaUnits.length; _i++>>
			<<if $militiaUnits[_i].active == 1 && ($rebellingID.includes($militiaUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $rebellingID.length>>
					$militiaUnits[_i].platoonName,
				<<else>>
					$militiaUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $slaveUnits.length; _i++>>
			<<if $slaveUnits[_i].active == 1 && ($rebellingID.includes($slaveUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $rebellingID.length>>
					$slaveUnits[_i].platoonName,
				<<else>>
					$slaveUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $mercUnits.length; _i++>>
			<<if $mercUnits[_i].active == 1 && ($rebellingID.includes($mercUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $rebellingID.length>>
					$mercUnits[_i].platoonName,
				<<else>>
					$mercUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		betrayed you and joined the insurrection.
	<</if>>
	<<set _count = 0>>
	<<if $loyalID.length > 0>>

		<<if $arcologyUpgrade.drones == 1>>Your security drones,<</if>>
		<<for _i = 0; _i < $militiaUnits.length; _i++>>
			<<if $militiaUnits[_i].active == 1 && ($loyalID.includes($militiaUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $loyalID.length>>
					$militiaUnits[_i].platoonName,
				<<else>>
					$militiaUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $slaveUnits.length; _i++>>
			<<if $slaveUnits[_i].active == 1 && ($loyalID.includes($slaveUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $loyalID.length>>
					$slaveUnits[_i].platoonName,
				<<else>>
					$slaveUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $mercUnits.length; _i++>>
			<<if $mercUnits[_i].active == 1 && ($loyalID.includes($mercUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $loyalID.length>>
					$mercUnits[_i].platoonName,
				<<else>>
					$mercUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<if $securityForceActive == 1>>and $securityForceName, <<print commaNum($securityForcePersonnel)>> strong<</if>>
		are called to defend the arcology from this menace.
	<<else>>
		<<if $arcologyUpgrade.drones == 1>>Your security drones<<if $securityForceActive == 1>>and <<print commaNum($securityForceName, $securityForcePersonnel)>> strong<</if>><</if>>
		are called to defend the arcology from this menace.
	<</if>>

<<else>>
	In the end it happened, the citizens of your arcology dared took up arms and raised up against their betters. Your penthouse is flooded with reports from all over the arcology of small skirmishes between the rioting residents and the security forces.
	It appears <<print commaNum(Math.trunc($attackTroops))>> rebels are in the streets right now, building barricades and destroying your property. They are
	<<if $attackEquip <= 0>>
		poorly armed.
	<<elseif $attackEquip == 1>>
		lightly armed.
	<<elseif $attackEquip == 2>>
		decently armed.
	<<elseif $attackEquip == 3>>
		well armed.
	<<elseif $attackEquip >= 4>>
		extremely well armed.
	<</if>>
	<<if $irregulars > 0>>
		<<print commaNum(Math.trunc($irregulars))>> of your citizens took up arms to defend their arcology owner.
	<</if>>
	<<set _count = 0>>

	<<if $rebellingID.length > 0>>

		<<for _i = 0; _i < $militiaUnits.length; _i++>>
			<<if $militiaUnits[_i].active == 1 && ($rebellingID.includes($militiaUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $rebellingID.length>>
					$militiaUnits[_i].platoonName,
				<<else>>
					$militiaUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $slaveUnits.length; _i++>>
			<<if $slaveUnits[_i].active == 1 && ($rebellingID.includes($slaveUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $rebellingID.length>>
					$slaveUnits[_i].platoonName,
				<<else>>
					$slaveUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $mercUnits.length; _i++>>
			<<if $mercUnits[_i].active == 1 && ($rebellingID.includes($mercUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $rebellingID.length>>
					$mercUnits[_i].platoonName,
				<<else>>
					$mercUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		betrayed you and joined the insurrection.
	<</if>>

	<<set _count = 0>>
	<<if $loyalID.length > 0>>

		<<if $arcologyUpgrade.drones == 1>>Your security drones,<</if>>
		<<for _i = 0; _i < $militiaUnits.length; _i++>>
			<<if $militiaUnits[_i].active == 1 && ($loyalID.includes($militiaUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $loyalID.length>>
					$militiaUnits[_i].platoonName,
				<<else>>
					$militiaUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $slaveUnits.length; _i++>>
			<<if $slaveUnits[_i].active == 1 && ($loyalID.includes($slaveUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $loyalID.length>>
					$slaveUnits[_i].platoonName,
				<<else>>
					$slaveUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $mercUnits.length; _i++>>
			<<if $mercUnits[_i].active == 1 && ($loyalID.includes($mercUnits[_i].ID))>>
				<<set _count++>>
				<<if _count < $loyalID.length>>
					$mercUnits[_i].platoonName,
				<<else>>
					$mercUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<if $securityForceActive == 1>>and $securityForceName, <<print commaNum($securityForcePersonnel)>> strong<</if>>
		are called to defend the arcology from this menace.
	<<else>>
		<<if $arcologyUpgrade.drones == 1>>Your security drones<<if $securityForceActive == 1>>and $securityForceName, <<print commaNum($securityForcePersonnel)>> strong<</if>><</if>>
		are called to defend the arcology from this menace.
	<</if>>

<</if>>

The confined spaces of the arcology and the number of vital yet delicate systems within its walls do not allow a lot of tactical flexibility. This will be a long and strenuous fight, street after street, barricade after barricade.
In order to preserve the structural integrity of the building and the lives of our civilians, we will have to limit our firepower.

<<link "Only light firearms and non lethal weapons">>
	<<set $engageRule = 0>>
	<<replace "#engage">>

Your troops will use only non lethal weapons or light firearms to limit to the maximum the collateral damage. This will however weaken our troops considerably.
	<</replace>>
<</link>>

<<link "No heavy ordnance">>
	<<set $engageRule = 1>>
	<<replace "#engage">>

Your troops will limit the use of explosives and heavy weapons to limit considerably the collateral damage. This will however weaken our troops.
	<</replace>>
<</link>>

<<link "Normal engagement rules">>
	<<set $engageRule = 2>>
	<<replace "#engage">>

Your troops will not limit their arsenal. This will put the structure and your citizens at risk, but our troops will be at full capacity.
	<</replace>>
<</link>>

<<if $advancedRiotEquip == 1>>

<<link "Advanced riot protocol">>
		<<set $engageRule = 3>>
		<<replace "#engage">>

Your troops will make use of the special weaponry, equipment and infrastructure developed by the riot control center to surgically eliminate rebels and dissidents with little to no collateral damage.
		<</replace>>
	<</link>>
<</if>>

Your troops will use only non lethal weapons or light firearms to limit to the maximum the collateral damage. This will however weaken our troops considerably.

We can dedicate some of our forces to the protection of the vital parts of the arcology, doing so will prevent the failure of said systems, but will also take away strength from our assault.
<<if $garrison.penthouse == 0>>

<<link "Garrison the penthouse">>
		<<set $garrison.penthouse = 1>>
		<<goto "rebellionOptions">>
	<</link>>
<<else>>

Troops will be dispatched to the penthouse.
	<<link "Discard the order">>
		<<set $garrison.penthouse = 0>>
		<<goto "rebellionOptions">>
	<</link>>
<</if>>
<<if $garrison.reactor == 0>>

<<link "Garrison the reactors">>
		<<set $garrison.reactor = 1>>
		<<goto "rebellionOptions">>
	<</link>>
<<else>>

Troops will be dispatched to the reactors.
	<<link "Discard the order">>
		<<set $garrison.reactor = 0>>
		<<goto "rebellionOptions">>
	<</link>>
<</if>>
<<if $garrison.assistant == 0>>

<<link "Garrison the assistant's central CPU">>
		<<set $garrison.assistant = 1>>
		<<goto "rebellionOptions">>
	<</link>>
<<else>>

Troops will be dispatched to the assistant's central CPU.
	<<link "Discard the order">>
		<<set $garrison.assistant = 0>>
		<<goto "rebellionOptions">>
	<</link>>
<</if>>
<<if $garrison.waterway == 0>>

<<link "Garrison the waterways">>
		<<set $garrison.waterway = 1>>
		<<goto "rebellionOptions">>
	<</link>>
<<else>>

Troops will be dispatched to the waterways.
	<<link "Discard the order">>
		<<set $garrison.waterway = 0>>
		<<goto "rebellionOptions">>
	<</link>>
<</if>>

<<replenishAllUnits>>

<<link "Proceed">>
	<<set $battleResult = 4>>						/* sets $battleResult value outside accepted range to avoid evaluation problems */
	<<if $hasFoughtOnce == 0>>
		<<set $hasFoughtOnce = 1>>
	<</if>>
	<<set $foughtThisWeek = 1>>
	<<goto "rebellionHandler">>
<</link>>

<<link "Surrender">>
	<<set $battleResult = -1>>
	<<if $hasFoughtOnce == 0>>
		<<set $hasFoughtOnce = 1>>
	<</if>>
	<<set $foughtThisWeek = 1>>
	<<goto "rebellionHandler">>
<</link>>


code:
:: rebellionReport [nobr]

<<set $nextButton = "Continue", $nextLink = "Scheduled Event", $showEncyclopedia = 1, $encyclopedia = "Battles">>

<<set _oldRep = $rep>>
<<set _oldAuth = $authority>>
<<set $enemyLosses = Math.trunc($enemyLosses)>>
<<if $enemyLosses > $attackTroops>>
	<<set $enemyLosses = $attackTroops>>
<</if>>
<<set $totalKills += $enemyLosses>>
<<set $losses = Math.trunc($losses)>>
<<set $rebellionsCount++>>
<<if $battleResult == 3>>
	Victory!
	<<set $PCrebWon++>>
<<elseif $battleResult == -3>>
	Defeat!
	<<set $PCrebLoss++>>
<<elseif $battleResult == 2>>
	Partial victory!
	<<set $PCrebWon++>>
	<<elseif $battleResult == -2>>
	Partial defeat!
	<<set $PCrebLoss++>>
<<elseif $battleResult == -1>>
	We surrendered
	<<set $PCrebLoss++>>
<</if>>
<<set _day = $day + random(0,7)>>
<<set _month = $month>>
<<set _year = $year>>
<<switch _month>>
<<case "January">>
<<if _day > 31>>
	<<set _day -= 31, _month = "February">>
<</if>>
<<case "February">>
<<if _day > 28>>
	<<set _day -= 28, _month = "March">>
<</if>>
<<case "March">>
<<if _day > 31>>
	<<set _day -= 31, _month = "April">>
<</if>>
<<case "April">>
<<if _day > 30>>
	<<set _day -= 30, _month = "May">>
<</if>>
<<case "May">>
<<if _day > 31>>
	<<set _day -= 31, _month = "June">>
<</if>>
<<case "June">>
<<if _day > 30>>
	<<set _day -= 30, _month = "July">>
<</if>>
<<case "July">>
<<if _day > 31>>
	<<set _day -= 31, _month = "August">>
<</if>>
<<case "August">>
<<if _day > 31>>
	<<set _day -= 31, _month = "September">>
<</if>>
<<case "September">>
<<if _day > 30>>
	<<set _day -= 30, _month = "October">>
<</if>>
<<case "October">>
<<if _day > 31>>
	<<set _day -= 31, _month = "November">>
<</if>>
<<case "November">>
<<if _day > 30>>
	<<set _day -= 30, _month = "December">>
<</if>>
<<default>>
<<if _day > 31>>
	<<set _day -= 31, _month = "January", _year += 1>>
<</if>>
<</switch>>

<<if $slaveRebellion == 1>>
	Today, the _day of _month _year, our arcology was inflamed by the fires of rebellion. <<print commaNum(Math.trunc($attackTroops))>> rebels from all over the structure dared rise up against their owners and conquer their freedom through blood. Our defense force, <<print commaNum(Math.trunc($troopCount))>> strong, fought with them street by street
	<<if $enemyLosses != $attackTroops>>
		inflicting <<print commaNum(Math.trunc($enemyLosses))>> casualties, while sustaining <<if $losses > 1>> <<print commaNum(Math.trunc($losses))>> casualties <<else>> a casualty<</if>> themselves.
	<<else>>
		completely annihilating their troops, while sustaining <<if $losses > 1>> <<print commaNum(Math.trunc($losses))>> casualties <<else>> a casualty.<</if>>
	<</if>>
	<<set $ASlaves -= $enemyLosses>>
	<<if $battleResult == 3>>
		<<if $battleTurns <= 5>>
			The fight was quick and one sided, our men easily stopped the disorganized revolt in a few well aimed assaults.
		<<elseif $battleTurns <= 7>>
			The fight was hard, but in the end our men stopped the disorganized revolt with several well aimed assaults.
		<<else>>
			The fight was long and hard, but in the end our men stopped the revolt before it could accumulate momentum.
		<</if>>
	<<elseif $battleResult == -3>>
		<<if $battleTurns <= 5>>
			The fight was quick and one sided, our men were easily crushed by the furious charge of the rebels.
		<<elseif $battleTurns <= 7>>
			The fight was hard and in the end the rebels proved too much to handle for our men.
		<<else>>
			The fight was long and hard, but despite their bravery the rebels proved too much for our men.
		<</if>>
	<<elseif $battleResult == 2>>
		The fight was long and hard, but in the end our men managed to stop the revolt, though not without difficulty.
	<<elseif $battleResult == -2>>
		The fight was long and hard. Our men in the end had to yield to the rebelling slaves, which were fortunately unable to capitalized on their victory.
	<<elseif $battleResult == -1>>
		You gave your troops the order to surrender, obediently they stand down.
	<</if>>

	/* effects */
	<<if $battleResult == 3>>
		Thanks to your victory, your @@.green;reputation@@ and @@.darkviolet;authority@@ increased.
		<<set $rep += random(800,1000)>>
		<<set $authority += random(800,1000)>>

Many of the rebelling slaves were recaptured and punished. The instigators were executed one after another in a public trial that lasted for almost three days.
		<<set $ASlaves -= random(10,30)>>
	<<elseif $battleResult == -3>>
		Due to your defeat, your @@.red;reputation@@ and @@.red;authority@@ decreased.
		<<set $rep -= random(800,1000)>>
		<<set $authority -= random(800,1000)>>

After the battle most of the rebelling slaves managed to escape, while others remained in the arcology for days looting and hunting their former masters. The arcology will bear the scars of this day for a long time.
		<<set $ACitizens -= random(50,100)>>
		<<set $ASlaves -= Math.trunc(($attackTroops - $enemyLosses) * 0.8)>>
		<<set $rebelDefeatAftermath = 5>>
	<<elseif $battleResult == -2>>
		Due to your defeat, your @@.red;reputation@@ and @@.red;authority@@ decreased.
		<<set $rep -= random(600,800)>>
		<<set $authority -= random(600,800)>>

After the battle most of the rebelling slaves managed to escape, while others remained in the arcology for days looting and hunting their former masters. The arcology will bear the scars of this day for a long time.
		<<set $ACitizens -= random(40,80)>>
		<<set $ASlaves -= Math.trunc(($attackTroops - $enemyLosses) * 0.6)>>
		<<set $rebelDefeatAftermath = 3>>
	<<elseif $battleResult == 2>>
		Thanks to your victory, your @@.green;reputation@@ and @@.darkviolet;authority@@ increased.
		<<set $rep += random(600,180)>>
		<<set $authority += random(600,800)>>

Many of the rebelling slaves were recaptured and punished. The instigators were executed one after another in a public trial that lasted for almost three days.
		<<set $ASlaves -= random(10,30)>>
	<<elseif $battleResult == -1>>
		Rather than waste the lives of your men you decided to surrender, hoping the rebels will cause less damage if you indulge them, this is however a big hit to your status. Your @@.red;reputation@@ and @@.red;authority@@ are significantly impacted.
		<<set $rep -= random(1000,1200)>>
		<<set $authority -= random(1000,1200)>>

		The surrender allows the arcology to survive @@.yellow;mostly intact@@, however reports of @@.red;mass looting and killing of citizens@@ flood your office for a few days.
		<<set $cash -= 1000>>
		<<if $week <= 30>>
			<<set $ACitizens -= random(100)>>
			<<set $ASlaves -= random(150)>>
			<<set $arcologies[0].prosperity -= random(5)>>
		<<elseif $week <= 60>>
			<<set $ACitizens -= random(120)>>
			<<set $ASlaves -= random(170)>>
			<<set $arcologies[0].prosperity -= random(10)>>
		<<elseif $week <= 90>>
			<<set $ACitizens -= random(140)>>
			<<set $ASlaves -= random(190)>>
			<<set $arcologies[0].prosperity -= random(15)>>
		<<elseif $week <= 120>>
			<<set $ACitizens -= random(160)>>
			<<set $ASlaves -= random(210)>>
			<<set $arcologies[0].prosperity -= random(20)>>
		<<else>>
			<<set $ACitizens -= random(180)>>
			<<set $ASlaves -= random(230)>>
			<<set $arcologies[0].prosperity -= random(25)>>
		<</if>>

After the battle most of the rebelling slaves managed to escape, while others remained in the arcology for days looting and hunting their former masters. The arcology will bear the scars of this day for a long time.
		<<set $ACitizens -= random(50,100)>>
		<<set $ASlaves -= Math.trunc(($attackTroops - $enemyLosses) * 0.8)>>
		<<set $rebelDefeatAftermath = 5>>
	<</if>>
<<else>>
	Today, the _day of _month _year, our arcology was inflamed by the fires of rebellion. <<print commaNum(Math.trunc($attackTroops))>> rebels from all over the structure dared rise up to dethrone their arcology owner. Our defense force, <<print commaNum($troopCount)>> strong, fought with them street by street
	<<if $enemyLosses != $attackTroops>>
		inflicting <<print commaNum(Math.trunc($enemyLosses))>> casualties, while sustaining <<if $losses > 1>> <<print commaNum(Math.trunc($losses))>> casualties <<else>> a casualty<</if>> themselves.
	<<else>>
		completely annihilating their troops, while sustaining <<if $losses > 1>> <<print commaNum(Math.trunc($losses))>> casualties <<else>> a casualty.<</if>>
	<</if>>
	<<set $ASlaves -= $enemyLosses>>
	<<if $battleResult == 3>>
		<<if $battleTurns <= 5>>
			The fight was quick and one sided, our men easily stopped the disorganized revolt in a few well aimed assaults.
		<<elseif $battleTurns <= 7>>
			The fight was hard, but in the end our men stopped the disorganized revolt with several well aimed assaults.
		<<else>>
			The fight was long and hard, but in the end our men stopped the revolt before it could accumulate momentum.
		<</if>>
	<<elseif $battleResult == -3>>
		<<if $battleTurns <= 5>>
			The fight was quick and one sided, our men were easily crushed by the furious charge of the rebels.
		<<elseif $battleTurns <= 7>>
			The fight was hard and in the end the rebels proved too much to handle for our men.
		<<else>>
			The fight was long and hard, but despite their bravery the rebels proved too much for our men.
		<</if>>
	<<elseif $battleResult == 2>>
		The fight was long and hard, but in the end our men managed to stop the revolt, though not without difficulty.
	<<elseif $battleResult == -2>>
		The fight was long and hard. Our men in the end had to yield to the rebelling slaves, which were fortunately unable to fully capitalized on their victory.
	<<elseif $battleResult == -1>>
		You gave your troops the order to surrender, obediently they stand down.
	<</if>>

	/* effects */
	<<if $battleResult == 3>>
		Thanks to your victory, your @@.green;reputation@@ and @@.darkviolet;authority@@ increased.
		<<set $rep += random(800,1000)>>
		<<set $authority += random(800,1000)>>

Many of the rebelling citizens were captured and punished, many others enslaved. The instigators were executed one after another in a public trial that lasted for almost three days.
		<<set $ACitizens -= random(10,30)>>
	<<elseif $battleResult == -3>>
		Due to your defeat, your @@.red;reputation@@ and @@.red;authority@@ decreased.
		<<set $rep -= random(800,1000)>>
		<<set $authority -= random(800,1000)>>

After the battle most of the rebelling citizens remained in the arcology for days looting and hunting their former arcology. We will bear the scars of this day for a long time.
		<<set $ACitizens -= Math.trunc(($attackTroops - $enemyLosses) * 0.8)>>
		<<set $rebelDefeatAftermath = 5>>
	<<elseif $battleResult == -2>>
		Due to your defeat, your @@.red;reputation@@ and @@.red;authority@@ decreased.
		<<set $rep -= random(600,800)>>
		<<set $authority -= random(600,800)>>

After the battle most of the rebelling citizens remained in the arcology for days looting and hunting their former arcology. We will bear the scars of this day for a long time.
		<<set $ACitizens -= random(40,80)>>
		<<set $ASlaves -= Math.trunc(($attackTroops - $enemyLosses) * 0.6)>>
		<<set $rebelDefeatAftermath = 3>>
	<<elseif $battleResult == 2>>
		Thanks to your victory, your @@.green;reputation@@ and @@.darkviolet;authority@@ increased.
		<<set $rep += random(600,180)>>
		<<set $authority += random(600,800)>>

Many of the rebelling citizens were captured and punished, many others enslaved. The instigators were executed one after another in a public trial that lasted for almost three days.
		<<set $ASlaves -= random(10,30)>>
	<<elseif $battleResult == -1>>
		Rather than waste the lives of your men you decided to surrender, hoping the rebels will cause less damage if you indulge them, this is however a big hit to your status. Your @@.red;reputation@@ and @@.red;authority@@ are significantly impacted.
		<<set $rep -= random(1000,1200)>>
		<<set $authority -= random(1000,1200)>>

		The surrender allows the arcology to survive @@.yellow;mostly intact@@, however reports of @@.red;mass looting and killing of citizens@@ flood your office for a few days.
		<<set $cash -= 1000>>
		<<if $week <= 30>>
			<<set $ACitizens -= random(100)>>
			<<set $ASlaves -= random(150)>>
			<<set $arcologies[0].prosperity -= random(5)>>
		<<elseif $week <= 60>>
			<<set $ACitizens -= random(120)>>
			<<set $ASlaves -= random(170)>>
			<<set $arcologies[0].prosperity -= random(10)>>
		<<elseif $week <= 90>>
			<<set $ACitizens -= random(140)>>
			<<set $ASlaves -= random(190)>>
			<<set $arcologies[0].prosperity -= random(15)>>
		<<elseif $week <= 120>>
			<<set $ACitizens -= random(160)>>
			<<set $ASlaves -= random(210)>>
			<<set $arcologies[0].prosperity -= random(20)>>
		<<else>>
			<<set $ACitizens -= random(180)>>
			<<set $ASlaves -= random(230)>>
			<<set $arcologies[0].prosperity -= random(25)>>
		<</if>>

After the battle most of the rebelling citizens remained in the arcology for days looting and hunting their former arcology. We will bear the scars of this day for a long time.
		<<set $ACitizens -= random(50,100)>>
		<<set $ASlaves -= Math.trunc(($attackTroops - $enemyLosses) * 0.8)>>
		<<set $rebelDefeatAftermath = 5>>
	<</if>>
<</if>>

/* engage rules */
<<if $battleResult != -1>>
	<<if $engageRule == 0>>
		Since you ordered your troops to limit their weaponry to low caliber or non lethal, the arcology reported only @@.red;minor damage@@. Most citizens and non involved slaves remained unharmed, though some casualties between the civilians were inevitable.
		A few businesses were looted and burned, but the damage was pretty limited.
		<<set $arcRepairTime += 3, $PC.engineering += .1>>
		<<if $week <= 30>>
			<<set $ACitizens -= random(40)>>
			<<set $ASlaves -= random(65)>>
			<<set $arcologies[0].prosperity -= random(2)>>
		<<elseif $week <= 60>>
			<<set $ACitizens -= random(50)>>
			<<set $ASlaves -= random(55)>>
			<<set $arcologies[0].prosperity -= random(5)>>
		<<elseif $week <= 90>>
			<<set $ACitizens -= random(60)>>
			<<set $ASlaves -= random(85)>>
			<<set $arcologies[0].prosperity -= random(7)>>
		<<elseif $week <= 120>>
			<<set $ACitizens -= random(70)>>
			<<set $ASlaves -= random(95)>>
			<<set $arcologies[0].prosperity -= random(10)>>
		<<else>>
			<<set $ACitizens -= random(80)>>
			<<set $ASlaves -= random(105)>>
			<<set $arcologies[0].prosperity -= random(12)>>
		<</if>>
	<<elseif $engageRule == 1>>
		You ordered your troops to limit their weaponry to non-heavy, non-explosive, because of this the arcology reported @@.red;moderate damage@@. Most citizens and non involved slaves remained unharmed or only lightly wounded, but many others did not make it. Unfortunately casualties between the civilians were inevitable.
		A few businesses were looted and burned, but the damage was pretty limited.
		<<set $arcRepairTime += 5, $PC.engineering += .1>>
		<<if $week <= 30>>
			<<set $ACitizens -= random(60)>>
			<<set $ASlaves -= random(85)>>
			<<set $arcologies[0].prosperity -= random(4)>>
		<<elseif $week <= 60>>
			<<set $ACitizens -= random(70)>>
			<<set $ASlaves -= random(75)>>
			<<set $arcologies[0].prosperity -= random(7)>>
		<<elseif $week <= 90>>
			<<set $ACitizens -= random(80)>>
			<<set $ASlaves -= random(105)>>
			<<set $arcologies[0].prosperity -= random(9)>>
		<<elseif $week <= 120>>
			<<set $ACitizens -= random(90)>>
			<<set $ASlaves -= random(115)>>
			<<set $arcologies[0].prosperity -= random(12)>>
		<<else>>
			<<set $ACitizens -= random(100)>>
			<<set $ASlaves -= random(125)>>
			<<set $arcologies[0].prosperity -= random(14)>>
		<</if>>
	<<elseif $engageRule == 2>>
		Since you did not apply any restriction on the weapons your forces should use, the arcology reported @@.red;heavy damage@@. Many citizens and uninvolved slaves are reported killed or missing. Casualties between the civilians were inevitable.
		Many businesses were damaged during the battle either by the fight itself, by fires which spread unchecked for hours or by looters.
		<<set $arcRepairTime += 7, $PC.engineering += .1>>
		<<if $week <= 30>>
			<<set $ACitizens -= random(100)>>
			<<set $ASlaves -= random(150)>>
			<<set $arcologies[0].prosperity -= random(5)>>
		<<elseif $week <= 60>>
			<<set $ACitizens -= random(120)>>
			<<set $ASlaves -= random(170)>>
			<<set $arcologies[0].prosperity -= random(10)>>
		<<elseif $week <= 90>>
			<<set $ACitizens -= random(140)>>
			<<set $ASlaves -= random(190)>>
			<<set $arcologies[0].prosperity -= random(15)>>
		<<elseif $week <= 120>>
			<<set $ACitizens -= random(160)>>
			<<set $ASlaves -= random(210)>>
			<<set $arcologies[0].prosperity -= random(20)>>
		<<else>>
			<<set $ACitizens -= random(180)>>
			<<set $ASlaves -= random(230)>>
			<<set $arcologies[0].prosperity -= random(25)>>
		<</if>>
	<<else>>
		Thanks to the advance riot control weaponry developed by your experts, the rebels were mostly subdued or killed with @@.yellow;little to no collateral damage to the arcology@@ and its inhabitants.
		A few businesses were looted, but the damage was very limited.
		<<set $arcRepairTime += 2, $PC.engineering += .1>>
		<<set $cash -= 1000>>
		<<if $week <= 30>>
			<<set $ACitizens -= random(20)>>
			<<set $ASlaves -= random(45)>>
			<<set $arcologies[0].prosperity -= random(2)>>
		<<elseif $week <= 60>>
			<<set $ACitizens -= random(30)>>
			<<set $ASlaves -= random(35)>>
			<<set $arcologies[0].prosperity -= random(4)>>
		<<elseif $week <= 90>>
			<<set $ACitizens -= random(40)>>
			<<set $ASlaves -= random(65)>>
			<<set $arcologies[0].prosperity -= random(6)>>
		<<elseif $week <= 120>>
			<<set $ACitizens -= random(50)>>
			<<set $ASlaves -= random(75)>>
			<<set $arcologies[0].prosperity -= random(8)>>
		<<else>>
			<<set $ACitizens -= random(60)>>
			<<set $ASlaves -= random(85)>>
			<<set $arcologies[0].prosperity -= random(10)>>
		<</if>>
	<</if>>
<</if>>
<<if $ACitizens < 100>>
	<<set $ACitizens = 100>>
<</if>>
<<if $ASlaves < 200>>
	<<set $ASlaves = 200>>
<</if>>

/* garrisons */
<<if $garrison.reactor == 0>>
	<<if random(1,100) <= (75 - ($fort.reactor * 25))>>
		Unfortunately during the fighting a group of slaves infiltrated the reactor complex and sabotaged it, causing massive power fluctuations and blackouts.
		It will take @@.red;time and money to repair the damage@@.
		<<set $garrison.reactorTime = $repairTime + random(1) - $fort.reactor, $PC.engineering += .1>>
		<<set $cash -= 2000>>
	<<else>>
		While the reactor was left defenseless without a garrison, there was no attempt at sabotage. Let's hope we'll always be this lucky.
	<</if>>
<<else>>
	The garrison assigned to the reactor protected it from the multiple sabotage attempts carried out by the rebels.
<</if>>
<<if $garrison.waterway == 0>>
	<<if random(1,100) <= (75 - ($fort.waterway * 25))>>
		Unfortunately during the fighting a group of slaves infiltrated the water management complex and sabotaged it, causing huge water leaks throughout the arcology and severely limiting the water supply.
		It will take @@.red;time and money to repair the damage@@.
		<<set $garrison.waterwayTime = $repairTime + random(1) - $fort.waterway, $PC.engineering += .1>>
		<<set $cash -= 2000>>
	<<else>>
		While the water management complex was left defenseless without a garrison, there was no attempt at sabotage. Let's hope we'll always be this lucky.
	<</if>>
<<else>>
	The garrison assigned to the water management complex protected it from the sabotage attempt of the rebels.
<</if>>
<<if $garrison.assistant == 0>>
	<<if random(1,100) <= (75 - ($fort.assistant * 25))>>
		Unfortunately during the fighting a group of slaves infiltrated the facility housing $assistantName's mainframe and sabotaged it. Without its AI the arcology will be next to impossible to manage.
		It will take @@.red;time and money to repair the damage@@.
		<<set $garrison.assistantTime = $repairTime + random(1) - $fort.assistant, $PC.engineering += .1>>
		<<set $cash -= 2000>>
	<<else>>
		While the $assistantName's mainframe was left defenseless without a garrison, there was no attempt at sabotage. Let's hope we'll always be this lucky.
	<</if>>
<<else>>
	The garrison assigned to the facility housing $assistantName's mainframe prevented any sabotage attempt.
<</if>>
<<if $garrison.penthouse == 1 && $Bodyguard != 0>>
	The garrison assigned to the penthouse together with your loyal bodyguard stopped all assaults against your penthouse with ease.
<<elseif $Bodyguard != 0>>
	<<if random(1,100) <= 75>>
		During the fighting a group of slaves assaulted the penthouse. Your bodyguard, $Bodyguard.slaveName, stood strong against the furious attack.
		<<set _woundChance = 0>>
		<<if $PC.career == "mercenary" || $PC.career == "gang">>
			<<set _woundChance -= 5>>
		<</if>>
		<<if $personalArms >= 1>>
			<<set _woundChance -= 5>>
		<</if>>
		<<if $PC.physicalAge >= 60>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.belly > 5000>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.boobsBonus >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.butt >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.preg >= 30>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.balls == 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.ballsImplant >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if random(1,100) <= _woundChance>>
			A lucky shot managed to find your way to you, leaving a painful, but thankfully not lethal, wound.
			<<set $PCWounded = 1>>
			<<set $PCWoundCooldown = 3>>
		<<else>>
			Fortunately you managed to avoid injury.
		<</if>>
		<<if $Concubine != 0>>
			<<set _woundChance = 0>>
			<<if $Concubine.combatSkill == 1>>
				<<set _woundChance -= 2>>
			<</if>>
			<<if $Concubine.amp >= -4>>
				<<set _woundChance -= 1>>
			<</if>>
			<<if $Concubine.health >= 50>>
				<<set _woundChance -= 1>>
			<</if>>
			<<if $Concubine.weight > 130>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.muscles < -30>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.eyes <= -2>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.heels == 1>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.boobs >= 1400>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.butt >= 6>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.preg >= 30>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.dick >= 8>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.balls >= 8>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.intelligence <= -3>>
				<<set _woundChance += 1>>
			<</if>>
			<<set _woundChance *= random(2,4)>>
			<<if random(1,100) <= _woundChance>>
				Your concubine was unfortunately caught in the crossfire and
				<<set $woundType = random(1,10)>>
				<<if $woundType == 1>>
					a splinter pierced her throat, severing her vocal cords.
					<<set $Concubine.voice = 0>>
				<<elseif $woundType == 2>>
					a splinter hit her face, severely damaging her eyes.
					<<set $Concubine.eyes = -2>>
				<<elseif $woundType == 3>>
					an explosion near her caused the loss of all her limbs.
					<<set $Concubine.amp = 1>>
				<<elseif $woundType >= 4>>
					a stray shot severely wounded her.
					<<if $Concubine.health >= -60>>
						<<set $Concubine.health -= 30>>
					<<else>>
						<<set $Concubine.health = -90>>
					<</if>>
				<</if>>
			<</if>>
		<</if>>
		<<set _woundChance = 0>>
		<<if $Bodyguard.combatSkill == 1>>
			<<set _woundChance -= 2>>
		<</if>>
		<<if $Bodyguard.amp >= -4>>
			<<set _woundChance -= 1>>
		<</if>>
			<<if $Bodyguard.health >= 50>>
			<<set _woundChance -= 1>>
		<</if>>
		<<if $Bodyguard.weight > 130>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.muscles < -30>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.eyes <= -2>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.heels == 1>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.boobs >= 1400>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.butt >= 6>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.preg >= 30>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.dick >= 8>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.balls >= 8>>
			<<set _woundChance += 1>>
		<</if>>
		<<if $Bodyguard.intelligence <= -3>>
			<<set _woundChance += 1>>
		<</if>>
		<<set _woundChance *= random(2,4)>>
		<<if random(1,100) <= _woundChance>>
			During one of the assaults your bodyguard was hit.
			<<set $woundType = random(1,10)>>
			<<if $woundType == 1>>
				A splinter pierced her throat, severing her vocal cords.
				<<set $Bodyguard.voice = 0>>
			<<elseif $woundType == 2>>
				A splinter hit her face, severely damaging her eyes.
				<<set $Bodyguard.eyes = -2>>
			<<elseif $woundType == 3>>
				An explosion near her caused the loss of all her limbs.
				<<set $Bodyguard.amp = 1>>
			<<elseif $woundType >= 4>>
				A stray shot severely wounded her.
				<<if $Bodyguard.health >= -60>>
					<<set $Bodyguard.health -= 30>>
				<<else>>
					<<set $Bodyguard.health = -90>>
				<</if>>
			<</if>>
		<</if>>
		The damage to the structure will be @@.red;costly to repair@@.
		<<set $cash -= 2000, $PC.engineering += .1>>
	<<else>>
		While the penthouse was left without a sizeable garrison, there was no dangerous assault against it. Let's hope we'll always be this lucky.
	<</if>>
<<elseif $garrison.penthouse == 1>>
	<<if random(1,100) <= 75>>
		During the fighting a group of slaves assaulted the penthouse. The garrison stood strong against the furious attack.
		<<set _woundChance = 0>>
		<<if $PC.career == "mercenary" || $PC.career == "gang">>
			<<set _woundChance -= 5>>
		<</if>>
		<<if $personalArms >= 1>>
			<<set _woundChance -= 5>>
		<</if>>
		<<if $PC.physicalAge >= 60>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.belly > 5000>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.boobsBonus >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.butt >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.preg >= 30>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.balls == 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.ballsImplant >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<set _woundChance *= random(1,2)>>
		<<if random(1,100) <= _woundChance>>
			A lucky shot managed to find your way to you, leaving a painful, but thankfully not lethal, wound.
			<<set $PCWounded = 1>>
			<<set $PCWoundCooldown = 3>>
		<<else>>
			Fortunately you managed to avoid injury.
		<</if>>
		<<if $Concubine != 0>>
			<<set _woundChance = 0>>
			<<if $Concubine.combatSkill == 1>>
				<<set _woundChance -= 2>>
			<</if>>
			<<if $Concubine.amp >= -4>>
				<<set _woundChance -= 1>>
			<</if>>
			<<if $Concubine.health >= 50>>
				<<set _woundChance -= 1>>
			<</if>>
			<<if $Concubine.weight > 130>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.muscles < -30>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.eyes <= -2>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.heels == 1>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.boobs >= 1400>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.butt >= 6>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.preg >= 30>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.dick >= 8>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.balls >= 8>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.intelligence <= -3>>
				<<set _woundChance += 1>>
			<</if>>
			<<set _woundChance *= random(2,4)>>
			<<if random(1,100) <= _woundChance>>
				Your concubine was unfortunately caught in the crossfire and
				<<set $woundType = random(1,10)>>
				<<if $woundType == 1>>
					a splinter pierced her throat, severing her vocal cords.
					<<set $Concubine.voice = 0>>
				<<elseif $woundType == 2>>
					a splinter hit her face, severely damaging her eyes.
					<<set $Concubine.eyes = -2>>
				<<elseif $woundType == 3>>
					an explosion near her caused the loss of all her limbs.
					<<set $Concubine.amp = 1>>
				<<elseif $woundType >= 4>>
					a stray shot severely wounded her.
					<<if $Concubine.health >= -60>>
						<<set $Concubine.health -= 30>>
					<<else>>
						<<set $Concubine.health = -90>>
					<</if>>
				<</if>>
			<</if>>
		<</if>>
		The damage to the structure will be @@.red;costly to repair@@.
		<<set $cash -= 2000, $PC.engineering += .1>>
	<<else>>
		There was no sizeable assault against the penthouse. Let's hope we'll always be this lucky.
	<</if>>
<<else>>
	<<if random(1,100) <= 75>>
		During the fighting a group of slaves assaulted the penthouse. Isolated and alone, you stood strong against the furious attack.
		<<set _woundChance = 0>>
		<<if $PC.career == "mercenary" || $PC.career == "gang">>
			<<set _woundChance -= 5>>
		<</if>>
		<<if $personalArms >= 1>>
			<<set _woundChance -= 5>>
		<</if>>
		<<if $PC.physicalAge >= 60>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.belly > 5000>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.boobsBonus >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.butt >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.preg >= 30>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.balls == 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<if $PC.ballsImplant >= 2>>
			<<set _woundChance += random(1,5)>>
		<</if>>
		<<set _woundChance *= random(1,2)>>
		<<if random(1,100) <= _woundChance>>
			A lucky shot managed to find your way to you, leaving a painful, but thankfully not lethal, wound.
			<<set $PCWounded = 1>>
			<<set $PCWoundCooldown = 3>>
		<<else>>
			Fortunately you managed to avoid injury.
		<</if>>
		<<if $Concubine != 0>>
			<<set _woundChance = 0>>
			<<if $Concubine.combatSkill == 1>>
				<<set _woundChance -= 2>>
			<</if>>
			<<if $Concubine.amp >= -4>>
				<<set _woundChance -= 1>>
			<</if>>
			<<if $Concubine.health >= 50>>
				<<set _woundChance -= 1>>
			<</if>>
			<<if $Concubine.weight > 130>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.muscles < -30>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.eyes <= -2>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.heels == 1>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.boobs >= 1400>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.butt >= 6>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.preg >= 30>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.dick >= 8>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.balls >= 8>>
				<<set _woundChance += 1>>
			<</if>>
			<<if $Concubine.intelligence <= -3>>
				<<set _woundChance += 1>>
			<</if>>
			<<set _woundChance *= random(2,4)>>
			<<if random(1,100) <= _woundChance>>
				Your concubine was unfortunately caught in the crossfire and
				<<set $woundType = random(1,10)>>
				<<if $woundType == 1>>
					a splinter pierced her throat, severing her vocal cords.
					<<set $Concubine.voice = 0>>
				<<elseif $woundType == 2>>
					a splinter hit her face, severely damaging her eyes.
					<<set $Concubine.eyes = -2>>
				<<elseif $woundType == 3>>
					an explosion near her caused the loss of all her limbs.
					<<set $Concubine.amp = 1>>
				<<elseif $woundType >= 4>>
					a stray shot severely wounded her.
					<<if $Concubine.health >= -60>>
						<<set $Concubine.health -= 30>>
					<<else>>
						<<set $Concubine.health = -90>>
					<</if>>
				<</if>>
			<</if>>
		<</if>>
	<<else>>
		There was no sizeable assault against the penthouse. Let's hope we'll always be this lucky.
	<</if>>
<</if>>

<<include "unitsRebellionReport">>

/* resets variables and flags */
<<set $attackTroops = 0>>
<<set $attackEquip = 0>>
<<set $enemyLosses = 0>>
<<set $losses = 0>>
<<set $battleTurns = 0>>
<<set $irregulars = 0>>
<<set $deployingMilitia = 0>>
<<set $deployingSlaves = 0>>
<<set $deployingMercs = 0>>
<<if $slaveRebellion == 1>>
	<<set $slaveProgress = 0>>
	<<set $citizenProgress = Math.clamp($citizenProgress - random(50,100), 0, 100)>>
<<else>>
	<<set $citizenProgress = 0>>
	<<set $slaveProgress = Math.clamp($slaveProgress - random(50,100), 0, 100)>>
<</if>>
<<set $slaveRebellion = 0>>
<<set $citizenRebellion = 0>>
<<set $tension =  Math.clamp($tension - random(50,100), 0, 100)>>


code:
:: riotControlCenter [nobr]

<<set $HackingSkillMultiplier = HSM()>>
<<set $nextButton = "Back to Arcology Management", $nextLink = "Manage Arcology", $returnTo = "Manage Arcology">>

Riot Control Center

The riot control center opens its guarded doors to you. The great chamber inside is dominated by massive screens filled with vital information and propaganda being tested.

<<if $tension <= 33>>
	Tensions in the arcology are low. Political and ideological opposition against the arcology owner is almost unheard of.
<<elseif $tension <= 66>>
	Tensions in the arcology are rising, political and ideological opposition against the arcology owner are becoming a part of the daily life of the arcology.
<<else>>
	Tensions are high. Opposition to the arcology owner is a sentiment shared by many and armed resistance is on the rise.
<</if>>

<<if $riotUpgrades.freeMedia == 0>>
	[[Provide free media access in all the arcology|riotControlCenter][$cash -= Math.trunc(5000*$upgradeMultiplierArcology), $riotUpgrades.freeMedia = 1, $riotUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology))>>. Will slowly lower tensions in the arcology, but will incur in upkeep costs.//
<<else>>
	You are providing free access to many mass media in the arcology.
	<<if $riotUpgrades.freeMedia < 5>>
		<<link "Invest more resources in the free media project">>
			<<set $riotUpgrades.freeMedia += 1>>
			<<set $cash -= ((5000 * $upgradeMultiplierArcology * ($riotUpgrades.freeMedia + 1)*$HackingSkillMultiplier))>>
			<<set $PC.hacking += .5>>
			<<set $riotUpkeep += $upgradeUpkeep>>
			<<goto "riotControlCenter">>
		<</link>>

Invest more resources into the project to increase its effectiveness.

//Costs <<print cashFormat(Math.trunc((5000 * $upgradeMultiplierArcology * ($riotUpgrades.freeMedia + 1)*$HackingSkillMultiplier)))>>. Will accelerate the tension decay, but will increase upkeep costs.//
	<<else>>
		You upgraded your free media scheme to its limits.
	<</if>>
<</if>>

<<if $slaveProgress <= 25>>
	There is very low unrest between slaves in the arcology. The chances of a rebellion igniting are extremely low.
<<elseif $slaveProgress <= 50>>
	There is some unrest between the slaves. No major movement is forming yet, but it might be time to consider preventive measures.
<<elseif $slaveProgress <= 75>>
	Unrest is getting high between the slaves of the arcology. Preventive measures are necessary if we want to prevent a violent rebellion.
<<else>>
	Unrest is extremely high between slaves. The chances of a rebellion happening in the near future are extremely high.
<</if>>

<<if $citizenProgress <= 25>>
	There is very low unrest between the citizens of the arcology. The chances of a rebellion igniting are extremely low.
<<elseif $citizenProgress <= 50>>
	There is some unrest between the citizens. No major movement is forming yet, but it might be time to consider preventive measures.
<<elseif $citizenProgress <= 75>>
	Unrest is getting high between the citizens of the arcology. Preventive measures are necessary if we want to prevent a violent rebellion.
<<else>>
	Unrest is extremely high between citizens. The chances of a rebellion happening in the near future are extremely high.
<</if>>

<<if $riotUpgrades.rapidUnit == 0>>
	[[Create rapid deployment riot units|riotControlCenter][$cash -= Math.trunc(7500*$upgradeMultiplierArcology), $riotUpgrades.rapidUnit = 1, $riotUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(7500*$upgradeMultiplierArcology))>>. Will allow spending authority or reputation to lower the progress of rebellions.//
<<else>>
	You created a rapid deployment riot unit.
	<<if $riotUpgrades.rapidUnit < 5>>
		<<link "Invest more resources in the rapid deployment unit">>
			<<set $riotUpgrades.rapidUnit += 1>>
			<<set $cash -= 5000 * $upgradeMultiplierArcology * ($riotUpgrades.rapidUnit + 1)>>
			<<set $riotUpkeep += $upgradeUpkeep>>
			<<goto "riotControlCenter">>
		<</link>>

Invest more resources into the project to increase its effectiveness.

//Costs <<print cashFormat(Math.trunc(5000 * $upgradeMultiplierArcology * ($riotUpgrades.rapidUnit + 1)))>>. Will lower action costs.//
	<<else>>

You upgraded your rapid deployment unit to its limits.
	<</if>>
	<<if $riotUpgrades.rapidUnitSpeed < 2>>
		<<link "Enhance the internal informants network">>
			<<set $riotUpgrades.rapidUnitSpeed += 1>>
			<<set $cash -= 5000 * $upgradeMultiplierArcology * ($riotUpgrades.rapidUnitSpeed + 1)>>
			<<set $riotUpkeep += $upgradeUpkeep>>
			<<goto "riotControlCenter">>
		<</link>>

Invest more resources into the effectiveness of the informants network.

//Costs <<print cashFormat(Math.trunc(5000 * $upgradeMultiplierArcology * ($riotUpgrades.rapidUnitSpeed + 1)))>>. Will reduce cooldown of the rapid deployment riot unit.//
	<<else>>

You enhanced your informants network to its limits.
	<</if>>

You can send out the squad to slow down the progress of hostile groups within the arcology:
	 <<link "spend authority">>
		<<set $riotUpgrades.rapidUnitCost = 0>>
		<<goto "riotControlCenter">>
	<</link>> |
	<<link "spend reputation">>
		<<set $riotUpgrades.rapidUnitCost = 1>>
		<<goto "riotControlCenter">>
	<</link>>

	<<if $riotUpgrades.rapidUnitCost == 0>>
		Your authority will be leveraged to suppress the rebels.
	<<else>>
		Your reputation will be leveraged to suppress the rebels.
	<</if>>

		<<if $sentUnitCooldown == 0>>

<<link "Deploy the unit against slaves rebel leaders">>
				<<if $riotUpgrades.rapidUnitCost == 0>>
					<<set $authority -= 1000 + 50 * $riotUpgrades.rapidUnit>>
				<<else>>
					<<set $reputation -= 1000 + 50 * $riotUpgrades.rapidUnit>>
				<</if>>
				<<set _change = random(15) + random(1,2) * $riotUpgrades.rapidUnit>>
				<<set $slaveProgress = Math.clamp($slaveProgress - _change,0,100)>>
				<<set $sentUnitCooldown = 3 - $riotUpgrades.rapidUnitSpeed>>
				<<replace "#result">>
					Slave rebellion progress set back by <<print _change>>%.
					The unit will be able to deployed again in $sentUnitCooldown weeks.
				<</replace>>
			<</link>>

<<link "Deploy the unit against citizens rebel leaders">>
				<<if $riotUpgrades.rapidUnitCost == 0>>
					<<set $authority -= 1000 + 50 * $riotUpgrades.rapidUnit>>
				<<else>>
					<<set $reputation -= 1000 + 50 * $riotUpgrades.rapidUnit>>
				<</if>>
				<<set _change = random(15) + random(1,2) * $riotUpgrades.rapidUnit>>
				<<set $citizenProgress = Math.clamp($citizenProgress - _change,0,100)>>
				<<set $sentUnitCooldown = 3 - $riotUpgrades.rapidUnitSpeed>>
				<<replace "#result">>
					Citizen rebellion progress set back by <<print _change>>%.
					The unit will be able to deployed again in $sentUnitCooldown weeks.
				<</replace>>
			<</link>>
		<<else>>

The unit cannot be deployed again for $sentUnitCooldown weeks.
		<</if>>

<</if>>

<<if $brainImplant < 106>>
	<<if $brainImplantProject == 0>>
		<<link "Start secretly installing brain implants in your citizens and resident slaves">>
			<<set $brainImplantProject = 1>>
			<<set $brainImplant = 0>>
			<<set $riotUpkeep += 5000>>
			<<goto "riotControlCenter">>
		<</link>>

//Will take weeks of work and will cost 5000 each week, but once finished rebellions will progress a lot slower.//
	<<elseif $brainImplantProject < 5>>
		<<link "Invest more resources in the brain implant project">>
			<<set $brainImplantProject += 1>>
			<<set $cash -= 50000 * $upgradeMultiplierArcology * $brainImplantProject*$HackingSkillMultiplier>>
			<<set $PC.hacking += 1>>
			<<set $riotUpkeep += 5000>>
			<<goto "riotControlCenter">>
		<</link>>

Invest more resources into the project to increase its speed.

//One-time cost of <<print cashFormat(Math.trunc(50000 * $upgradeMultiplierArcology * $brainImplantProject*$HackingSkillMultiplier))>> with an additional 5000 each week in maintenance. Will shorten the time required to complete the project.//
	<<else>>
		You sped up the project to its maximum.
	<</if>>
	<<if $brainImplant != -1>>

The great brain implant project is underway. Estimated time to completion: <<print Math.trunc((100 - $brainImplant) / $brainImplantProject)>>
	<</if>>
<<else>>
	The great brain implant project is completed, rebellions against you will be extremely difficult to organize.
<</if>>

<<if $advancedRiotEquip == 0>>
	<<link "Develop advanced anti-riot equipment">>
		<<set $advancedRiotEquip = 1>>
		<<set $cash -= 30000>>
		<<goto "riotControlCenter">>
	<</link>>

//Costs <<print cashFormat(30000)>>. Will allow the selection of advanced riot equipment in case of a rebellion, which will let your troops fight at full effectiveness while doing reduced collateral damage.//
<<else>>
	You developed advanced riot equipment, which allows your troops to fight within the confines of your arcology without the fear of doing major collateral damage.
<</if>>

<<if $fort.reactor == 0>>
	<<link "Reinforce the reactor complex">>
		<<set $fort.reactor = 1>>
		<<set $cash -= 10000 * $upgradeMultiplierArcology>>
		<<goto "riotControlCenter">>
	<</link>>

//Costs <<print cashFormat(10000 * $upgradeMultiplierArcology)>>. Will add protection to the reactor building, making it less likely to be damaged and speeding up repairs if our defensive efforts should fail.//
<<else>>
	You have installed additional protection layers and redundant systems in the reactor complex.
<</if>>

<<if $fort.waterway == 0>>
	<<link "Reinforce the waterways">>
		<<set $fort.waterway = 1>>
		<<set $cash -= 10000 * $upgradeMultiplierArcology>>
		<<goto "riotControlCenter">>
	<</link>>

//Costs <<print cashFormat(10000 * $upgradeMultiplierArcology)>>. Will add protection to the waterways, making it less likely to be damaged and speeding up repairs if our defensive efforts should fail.//
<<else>>
	You have installed additional protection layers and redundant systems in the waterways.
<</if>>

<<if $fort.assistant == 0>>
	<<link "Reinforce the assistant CPU core">>
		<<set $fort.assistant = 1>>
		<<set $cash -= 10000 * $upgradeMultiplierArcology>>
		<<goto "riotControlCenter">>
	<</link>>

//Costs <<print cashFormat(10000 * $upgradeMultiplierArcology)>>. Will add protection to the assistant CPU core, making it less likely to be damaged and speeding up repairs if our defensive efforts should fail.//
<<else>>
	You have installed additional protection layers and redundant systems in the assistant CPU core.
<</if>>


code:
:: secBarracks [nobr]

<<set $nextButton = "Back to Arcology Management", $nextLink = "Manage Arcology", $returnTo = "Manage Arcology">>

The Barracks

__Upgrades__

While this a sore sight for many citizens of $arcologies[0].name, the barracks stand proud before you.
<<if $secBarracksUpgrades.size == 0>>
	The building is relatively small and able to house a limited number of units.
<<elseif $secBarracksUpgrades.size == 1>>
	The building has been expanded and can now house more units comfortably.
<<elseif $secBarracksUpgrades.size == 2>>
	The building has been further expanded and can now house a high number of units.
<<elseif $secBarracksUpgrades.size == 3>>
	The building has been greatly expanded and can now house a sizable military.
<<elseif $secBarracksUpgrades.size == 4>>
	The building has been greatly expanded and can now house a small army.
<<else>>
	The building has been greatly expanded and can now house an army worthy of an old world nation.
<</if>>
<<if $secBarracksUpgrades.luxury == 0>>
	The barracks are a spartan building, with little to make the day to day lives of your soldiers pleasant.
<<elseif $secBarracksUpgrades.luxury == 1>>
	The barracks have been made more comfortable by installing high tech furniture.
<<elseif $secBarracksUpgrades.luxury == 2>>
	The barracks have been made more comfortable by installing high tech furniture and advanced kitchen facilities.
<<elseif $secBarracksUpgrades.luxury == 3>>
	The barracks have been made more comfortable by installing high tech furniture and advanced kitchen facilities. It also provides free access to any digital media.
<<else>>
	The barracks have been made more comfortable by installing high tech furniture and advanced kitchen facilities. It also provides free access to any digital media. A small limited access brothel has been added to the structure.
<</if>>
<<if $secBarracksUpgrades.training == 0>>
	The building lacks the space and the equipment to train your units.
<<elseif $secBarracksUpgrades.training == 1>>
	A training facility has been set up, allowing your units to better their skills with time.
<<else>>
	The training facility has been filled with specialized equipment and skilled trainers.
<</if>>
<<if $secBarracksUpgrades.loyaltyMod == 0>>
	The barracks lack an indoctrination facility.
<<elseif $secBarracksUpgrades.loyaltyMod == 1>>
	The barracks have been fitted with an indoctrination facility.
<<else>>
	The barracks have been fitted with an advanced indoctrination facility.
<</if>>

<<if $secBarracksUpgrades.size < 5>>
	<<link "Increase the size of the barracks">>
		<<set $cash -= 5000 * ($secBarracksUpgrades.size + 1)>>
		<<set $secBarracksUpgrades.size += 1>>
		<<set $maxUnits += 2>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(5000 * ($secBarracksUpgrades.size + 1))>> and will increase the maximum number of units by 2.//
<<else>>
	You've expanded the barracks to their maximum.
<</if>>

<<if $secBarracksUpgrades.luxury == 0>>
	<<link "Increase the quality of life of your soldiers by installing high tech furniture and appliances.">>
		<<set $secBarracksUpgrades.luxury += 1>>
		<<set $cash -= 5000>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(5000)>> and will provide a 5% bonus to morale.//
<<elseif $secBarracksUpgrades.luxury == 1>>
	<<link "Further increase the quality of life of your soldiers by installing advanced kitchen equipment and hiring skilled chefs.">>
		<<set $secBarracksUpgrades.luxury += 1>>
		<<set $cash -= 10000>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(10000)>> and will provide a 5% bonus to morale, for a total of +10%.//
<<elseif $secBarracksUpgrades.luxury == 2>>
	<<link "Further increase the quality of life of your soldiers by providing high speed, free access to digital media">>
		<<set $secBarracksUpgrades.luxury += 1>>
		<<set $cash -= 10000>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(10000)>> and will provide a 5% bonus to morale, for a total of +15%.//
<<elseif $secBarracksUpgrades.luxury == 3>>
	<<link "Further increase the quality of life of your soldiers by adding and staffing an exclusive brothel to the structure">>
		<<set $secBarracksUpgrades.luxury += 1>>
		<<set $cash -= 15000>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(15000)>> and will provide a 5% bonus to morale, for a total of +20%.//
<<else>>
	You've made life in your barracks as good as it can get.
<</if>>

<<if $secBarracksUpgrades.training == 0>>
	<<link "Add a training facility to the barracks">>
		<<set $secBarracksUpgrades.training += 1>>
		<<set $cash -= 10000>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(10000)>> and will allow units to accumulate some experience each week.//
<<elseif $secBarracksUpgrades.training == 1>>
	<<link "Improve the training facility with modern equipment and skilled personnel">>
		<<set $secBarracksUpgrades.training += 1>>
		<<set $cash -= 20000>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(20000)>> and will allow units to accumulate experience each week.//
<<else>>
	You have improved the training facility to the limit.
<</if>>

<<if $secBarracksUpgrades.loyaltyMod == 0>>
	<<link "Add an indoctrination facility to the barracks">>
		<<set $secBarracksUpgrades.loyaltyMod += 1>>
		<<set $cash -= 10000>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(10000)>> and will slowly raise loyalty of all units//
<<elseif $secBarracksUpgrades.loyaltyMod == 1>>
	<<link "Improve the indoctrination facility with advanced equipment and skilled personnel">>
		<<set $secBarracksUpgrades.loyaltyMod += 1>>
		<<set $cash -= 20000>>
		<<set $secBarracksUpkeep += $upgradeUpkeep>>
		<<goto "secBarracks">>
	<</link>>

//Costs <<print cashFormat(20000)>> and will raise loyalty of all units faster.//
<<else>>
	You have improved the indoctrination facility to the limit.
<</if>>

__Units__

Your maximum number of units is <<print $maxUnits>>, currently you have <<print $activeUnits>>. <<if $secBarracksUpgrades.luxury > 0>>The barracks provides <<print $secBarracksUpgrades.luxury * 5>>% bonus morale when battle occurs.<</if>><<if $secBarracksUpgrades.training > 0>> The training facility will increase the effectiveness of your units with time.<</if>>
<<if $arcologies[0].FSRomanRevivalist != "unset" || $arcologies[0].FSChineseRevivalist != "unset" || $arcologies[0].FSArabianRevivalist != "unset" || $arcologies[0].FSEdoRevivalist != "unset" || $arcologies[0].FSEgyptianRevivalist != "unset" || $arcologies[0].FSAztecRevivalist != "unset">>
<</if>>

<<replenishAllUnits>>

__Security Drones__
/* drones */
<<if $secBots.active == 1>>

	<<secBotsDescription>>

	<<link "Review Equipment and upgrades">>
		<<set $targetUnit = "secBots">>
		<<goto "seeUnit">>
	<</link>>
	<<if $secBots.troops < $secBots.maxTroops>>
	|
		<<link "Replenish the unit">>
			<<set $cash -= ($secBots.maxTroops - $secBots.troops) * $secBotsCost>>
			<<set $secBots.troops = $secBots.maxTroops>>
			<<goto "secBarracks">>
		<</link>>
	<</if>>
<<else>>
	You have lost too many security drones to be able to field them again.
	<<link "Reform the unit">>
		<<set $cash -= $secBots.maxTroops * $secBotsCost>>
		<<set $secBots.troops = $secBots.maxTroops>>
		<<set $secBots.active = 1>>
		<<goto "secBarracks">>
	<</link>>
<</if>>

__Slaves__

/* slaves */
You are free to organize your menial slaves into fighting units. Currently you have <<print commaNum($helots)>> slaves available, while <<print commaNum($slavesEmployedManpower)>> are already employed as soldiers. During all your battles you lost a total of <<print commaNum($slavesTotalCasualties)>>.
<<silently>><<MenialPopCap>><</silently>>
<<set _menialPrice = menialSlaveCost()>>
<<if $cash > _menialPrice>>
<<if $PopCap > $helots+$fuckdolls+$menialBioreactors>>

	[[Buy|secBarracks][$helots+=1,$menialDemandFactor+=1,$cash-=_menialPrice]]
	<<if $cash > (_menialPrice+200)*10>>
		[[(x10)|secBarracks][$helots+=10,$menialDemandFactor+=10,$cash-=(_menialPrice+200)*10]]
	<</if>>
	<<if $cash > (_menialPrice+200)*100>>
		[[(x100)|secBarracks][$helots+=100,$menialDemandFactor+=100,$cash-=(_menialPrice+200)*100]]
	<</if>>
	<<if $cash > (_menialPrice+200)*2>>
		[[(max)|secBarracks][$helots+=Math.trunc($cash/(_menialPrice+200)),$menialDemandFactor+=Math.trunc($cash/(_menialPrice+200)),$cash-=Math.trunc($cash/(_menialPrice+200))*(_menialPrice+200)]]
	<</if>>
	//Bulk purchases will cost <<print cashFormat(200)>> over market price.//
<</if>>
<</if>>

<<set _sL = $slaveUnits.length>>
<<if $helots > 0 && $activeUnits < $maxUnits>>

	<<link "Form a new unit">>
		<<if $createdSlavesUnits == 0>>
			<<set _name = (1+$createdSlavesUnits) + "st slave platoon">>
		<<elseif $createdSlavesUnits == 1>>
			<<set _name = (1+$createdSlavesUnits) + "nd slave platoon">>
		<<elseif $createdSlavesUnits == 2>>
			<<set _name = (1+$createdSlavesUnits) + "rd slave platoon">>
		<<else>>
			<<set _name = (1+$createdSlavesUnits) + "th slave platoon">>
		<</if>>
		<<if $helots >= $maxTroops>>
			<<set _newUnit = {
			ID: 0,
			platoonName: _name,
			active: 1,
			isDeployed: 0,
			troops: $maxTroops,
			maxTroops: $maxTroops,
			equip: 0,
			training: 0,
			loyalty: random(40,60),
			cyber: 0,
			medics: 0,
			SF: 0,
			commissars: 0,
			battlesFought: 0}>>
			<<generateUnitID _newUnit>>
			<<set $slaveUnits.push(_newUnit)>>
			<<set $helots -= 30>>
			<<set $slavesEmployedManpower += 30>>
			<<set $createdSlavesUnits++>>
		<<else>>
			<<set _newUnit = {
			ID: 0,
			platoonName: _name,
			active: 1,
			isDeployed: 0,
			troops: $helots,
			maxTroops: $maxTroops,
			equip: 0,
			training: 0,
			loyalty: random(40,60),
			cyber: 0,
			medics: 0,
			SF: 0,
			commissars: 0,
			battlesFought: 0}>>
			<<generateUnitID _newUnit>>
			<<set $slaveUnits.push(_newUnit)>>
			<<set $slavesEmployedManpower += _newUnit.troops>>
			<<set $helots = 0>>
			<<set $createdSlavesUnits++>>
		<</if>>
		<<set $activeUnits++>>
		<<goto "secBarracks">>
	<</link>>
<<elseif $helots > 0>>
	You have reached the maximum number of units. You'll have to disband one or enlarge the barracks before forming a new unit.
<<elseif $activeUnits < $maxUnits>>
	You don't have any free menial slave with which to form a new unit.
<</if>>
<<for _i = 0; _i < _sL; _i++>>
	<<capture _i>>
	<<if $slaveUnits[_i].active == 1>>

		<<slaveUnitsDescription $slaveUnits[_i]>>

		<<link "Disband the unit">>
			<<set $helots += $slaveUnits[_i].troops>>
			<<set $slavesEmployedManpower -= $slaveUnits[_i].troops>>
			<<set $slaveUnits.deleteAt(_i)>>
			<<set $activeUnits-->>
			<<goto "secBarracks">>
		<</link>>
		|
		<<link "Review Equipment and upgrades">>
			<<set $targetUnit = "slaveUnits">>
			<<set $targetIndex = _i>>
			<<goto "seeUnit">>
		<</link>>
		|
		<<if $slaveUnits[_i].troops < $slaveUnits[_i].maxTroops && $helots > 0>>
			<<link "Replenish unit">>
				<<if $helots >= $slaveUnits[_i].maxTroops - $slaveUnits[_i].troops>>
					<<set $helots -= $slaveUnits[_i].maxTroops - $slaveUnits[_i].troops>>
					<<set $slavesEmployedManpower += $slaveUnits[_i].maxTroops - $slaveUnits[_i].troops>>
					<<set _expLoss = ($slaveUnits[_i].maxTroops - $slaveUnits[_i].troops) / $slaveUnits[_i].troops>>
					<<set $slaveUnits[_i].training -= $slaveUnits[_i].training * _expLoss>>
					<<set $slaveUnits[_i].troops = $slaveUnits[_i].maxTroops>>
				<<else>>
					<<set $slavesEmployedManpower += $helots>>
					<<set _expLoss = $helots / $slaveUnits[_i].troops>>
					<<set $slaveUnits[_i].training -= $slaveUnits[_i].training * _expLoss>>
					<<set $slaveUnits[_i].troops += $helots>>
					<<set $helots = 0>>
				<</if>>
				<<goto "secBarracks">>
			<</link>>
		<</if>>

	<<else>>

		$slaveUnits[_i].platoonName lost too many operatives to be considered active.

		<<link "Disband the unit">>
			<<set _elimUnit = $slaveUnits[_i]>>
			<<set _newSlaveUnits = []>>
			<<for _y = 0; _y < _sL; _y++>>
				<<if $slaveUnits[_y] != _elimUnit>>
					<<set _newSlaveUnits.push($slaveUnits[_y])>>
				<</if>>
			<</for>>
			<<set $slaveUnits = _newSlaveUnits>>
			<<set $activeUnits-->>
			<<goto "secBarracks">>
		<</link>>
		|
		<<if $helots > 0>>
			<<link "Reform the unit">>
				<<if $helots >= $slaveUnits[_i].maxTroops>>
					<<set $slavesEmployedManpower += $slaveUnits[_i].maxTroops>>
					<<set $helots -= $slaveUnits[_i].maxTroops>>
					<<set $slaveUnits[_i].troops = $slaveUnits[_i].maxTroops>>
					<<set $slaveUnits[_i].training = 0>>
				<<else>>
					<<set $slavesEmployedManpower += $helots>>
					<<set $slaveUnits[_i].troops += $helots>>
					<<set $helots = 0>>
					<<set $slaveUnits[_i].training = 0>>
				<</if>>
				<<set $slaveUnits[_i].active = 1>>
				<<goto "secBarracks">>
			<</link>>
		<</if>>
	<</if>>
	<</capture>>
<</for>>

<<if $militiaFounded == 1>>

__Militia__

/* militia */
	You founded the $arcologies[0].name free militia. You are now able to organize your citizens in fighting units.
	<<if $militiaRecruitment == 0>>
		The militia is composed entirely of volunteers, your manpower is approximately 1.5% of the citizens population of your arcology.
	<<elseif $militiaRecruitment == 1>>
		With the establishment of conscription, your available manpower has increased to now approximately 3% of the arcology's citizens population.
	<<elseif $militiaRecruitment == 2>>
		By establishing obligatory military service to obtain citizenship you have enlarged your manpower pool to be approximately 5% of the arcology's citizens population.
	<</if>>
	Your current total manpower is <<print commaNum($militiaTotalManpower)>>, of which <<print commaNum($militiaEmployedManpower)>> is in active duty. You lost in total <<print commaNum($militiaTotalCasualties)>> citizens, leaving you with <<print commaNum($militiaFreeManpower)>> available citizens.

	<<set _mL = $militiaUnits.length>>
	<<if $militiaFreeManpower > 0 && $activeUnits < $maxUnits>>

		<<link "Form a new unit">>
			<<if $createdMilitiaUnits == 0>>
				<<set _name = (1+$createdMilitiaUnits) + "st citizens' platoon">>
			<<elseif $createdMilitiaUnits == 1>>
				<<set _name = (1+$createdMilitiaUnits) + "nd citizens' platoon">>
			<<elseif $createdMilitiaUnits == 2>>
				<<set _name = (1+$createdMilitiaUnits) + "rd citizens' platoon">>
			<<else>>
				<<set _name = (1+$createdMilitiaUnits) + "th citizens' platoon">>
			<</if>>
			<<if $militiaFreeManpower >= $maxTroops>>
				<<set _newUnit = {
				ID: 0,
				platoonName: _name,
				active: 1,
				isDeployed: 0,
				troops: $maxTroops,
				maxTroops: $maxTroops,
				equip: 0,
				training: 0,
				loyalty: random(40,60),
				cyber: 0,
				medics: 0,
				SF: 0,
				commissars: 0,
				battlesFought: 0}>>
				<<generateUnitID _newUnit>>
				<<set $militiaUnits.push(_newUnit)>>
				<<set $militiaFreeManpower -= 30>>
				<<set $militiaEmployedManpower += 30>>
				<<set $createdMilitiaUnits++>>
			<<else>>
				<<set _newUnit = {
				ID: 0,
				platoonName: _name,
				active: 1,
				isDeployed: 0,
				troops: $militiaFreeManpower,
				maxTroops: $maxTroops,
				equip: 0,
				training: 0,
				loyalty: random(40,60),
				cyber: 0,
				medics: 0,
				SF: 0,
				commissars: 0,
				battlesFought: 0}>>
				<<generateUnitID _newUnit>>
				<<set $militiaUnits.push(_newUnit)>>
				<<set $militiaEmployedManpower += _newUnit.troops>>
				<<set $militiaFreeManpower = 0>>
				<<set $createdMilitiaUnits++>>
			<</if>>
			<<set $activeUnits++>>
			<<goto "secBarracks">>
		<</link>>
	<<elseif $militiaFreeManpower > 0>>
		You have reached the maximum number of units. You'll have to disband one or enlarge the barracks before forming a new unit.
	<<elseif $activeUnits < $maxUnits>>
		You don't have any free recruits with which to form a new unit.
	<</if>>
	<<for _i = 0; _i < _mL; _i++>>
		<<capture _i>>
		<<if $militiaUnits[_i].active == 1>>

			<<militiaUnitsDescription $militiaUnits[_i]>>

			<<link "Disband the unit">>
				<<set $militiaFreeManpower += $militiaUnits[_i].troops>>
				<<set $militiaEmployedManpower -= $militiaUnits[_i].troops>>
				<<set $militiaUnits.deleteAt(_i)>>
				<<set $activeUnits-->>
				<<goto "secBarracks">>
			<</link>>
			|
			<<link "Review Equipment and upgrades">>
				<<set $targetUnit = "militiaUnits">>
				<<set $targetIndex = _i>>
				<<goto "seeUnit">>
			<</link>>
			|
			<<if $militiaUnits[_i].troops < $militiaUnits[_i].maxTroops && $militiaFreeManpower > 0>>
				<<link "Replenish unit">>
					<<if $militiaFreeManpower >= $militiaUnits[_i].maxTroops - $militiaUnits[_i].troops>>
						<<set $militiaFreeManpower -= $militiaUnits[_i].maxTroops - $militiaUnits[_i].troops>>
						<<set $militiaEmployedManpower += $militiaUnits[_i].maxTroops - $militiaUnits[_i].troops>>
						<<set _expLoss = ($militiaUnits[_i].maxTroops - $militiaUnits[_i].troops) / $militiaUnits[_i].troops>>
						<<set $militiaUnits[_i].training -= $militiaUnits[_i].training * _expLoss>>
						<<set $militiaUnits[_i].troops = $militiaUnits[_i].maxTroops>>
					<<else>>
						<<set $militiaEmployedManpower += $militiaFreeManpower>>
						<<set _expLoss = $militiaFreeManpower / $militiaUnits[_i].troops>>
						<<set $militiaUnits[_i].training -= $militiaUnits[_i].training * _expLoss>>
						<<set $militiaUnits[_i].troops += $militiaFreeManpower>>
						<<set $militiaFreeManpower = 0>>
					<</if>>
					<<goto "secBarracks">>
				<</link>>
			<</if>>
		<<else>>

			$militiaUnits[_i].platoonName lost too many operatives to be considered active.

			<<link "Disband the unit">>
				<<set $militiaFreeManpower += $militiaUnits[_i].troops>>
				<<set $militiaEmployedManpower -= $militiaUnits[_i].troops>>
				<<set _elimUnit = $militiaUnits[_i]>>
				<<set _newMilitiaUnits = []>>
				<<for _y = 0; _y < _sL; _y++>>
					<<if $militiaUnits[_y] != _elimUnit>>
						<<set _newMilitiaUnits.push($militiaUnits[_y])>>
					<</if>>
				<</for>>
				<<set $militiaUnits = _newMilitiaUnits>>
				<<set $activeUnits-->>
				<<goto "secBarracks">>
			<</link>>
			|
			<<if $militiaFreeManpower > 0>>
				<<link "Reform the unit">>
					<<if $militiaFreeManpower >= $militiaUnits[_i].maxTroops>>
						<<set $militiaEmployedManpower += $militiaUnits[_i].maxTroops>>
						<<set $militiaFreeManpower -= $militiaUnits[_i].maxTroops>>
						<<set $militiaUnits[_i].troops = $militiaUnits[_i].maxTroops>>
						<<set $militiaUnits[_i].training = 0>>
					<<else>>
						<<set $militiaEmployedManpower += $militiaFreeManpower>>
						<<set $militiaUnits[_i].troops += $militiaFreeManpower>>
						<<set $militiaFreeManpower = 0>>
						<<set $militiaUnits[_i].training = 0>>
					<</if>>
					<<set $militiaUnits[_i].active = 1>>
					<<goto "secBarracks">>
				<</link>>
			<</if>>
		<</if>>
		<</capture>>
	<</for>>

<<else>>

	You have not yet founded the militia, you will not be able to form citizens units.
<</if>>

<<if $mercenaries >= 1>>

__Mercenaries__

/* mercenaries */
	With the installation of a mercenary company in the arcology, many other are attracted to your free city, hoping to land a contract with you.
	You are able to organize them in units to use in the defense of the arcology. Excluding the defense force you set up, there are <<print commaNum($mercTotalManpower)>> mercenaries in your arcology, of which <<print commaNum($mercEmployedManpower)>> actively employed and <<print $mercFreeManpower>> not yet under contract. In total <<print commaNum($mercTotalCasualties)>> mercenaries have died defending your arcology.

	<<set _meL = $mercUnits.length>>
	<<if $mercFreeManpower > 0 && $activeUnits < $maxUnits>>

		<<link "Form a new unit">>
			<<if $createdMercUnits == 0>>
				<<set _name = (1+$createdMercUnits) + "st mercenary platoon">>
			<<elseif $createdMercUnits == 1>>
				<<set _name = (1+$createdMercUnits) + "nd mercenary platoon">>
			<<elseif $createdMercUnits == 2>>
				<<set _name = (1+$createdMercUnits) + "rd mercenary platoon">>
			<<else>>
				<<set _name = (1+$createdMercUnits) + "th mercenary platoon">>
			<</if>>
			<<if $mercFreeManpower >= $maxTroops>>
				<<set _newUnit = {
				ID: 0,
				platoonName: _name,
				active: 1,
				isDeployed: 0,
				troops: $maxTroops,
				maxTroops: $maxTroops,
				equip: 0,
				training: 0,
				loyalty: random(40,60),
				cyber: 0,
				medics: 0,
				SF: 0,
				commissars: 0,
				battlesFought: 0}>>
				<<generateUnitID _newUnit>>
				<<set $mercUnits.push(_newUnit)>>
				<<set $mercFreeManpower -= 30>>
				<<set $mercEmployedManpower += 30>>
				<<set $createdMercUnits++>>
			<<else>>
				<<set _newUnit = {
				ID: 0,
				platoonName: _name,
				active: 1,
				isDeployed: 0,
				troops: $mercFreeManpower,
				maxTroops: $maxTroops,
				equip: 0,
				training: 0,
				loyalty: random(40,60),
				cyber: 0,
				medics: 0,
				SF: 0,
				commissars: 0,
				battlesFought: 0}>>
				<<generateUnitID _newUnit>>
				<<set $mercUnits.push(_newUnit)>>
				<<set $mercEmployedManpower += _newUnit.troops>>
				<<set $mercFreeManpower = 0>>
				<<set $createdMercUnits++>>
			<</if>>
			<<set $activeUnits++>>
			<<goto "secBarracks">>
		<</link>>
	<<elseif $mercFreeManpower > 0>>
		You have reached the maximum number of units. You'll have to disband one or enlarge the barracks before forming a new unit.
	<<elseif $activeUnits < $maxUnits>>
		You don't have any free mercenaries with which to form a new unit.
	<</if>>
	<<for _i = 0; _i < _meL; _i++>>
		<<capture _i>>
		<<if $mercUnits[_i].active == 1>>

			<<mercUnitsDescription $mercUnits[_i]>>

			<<link "Disband the unit">>
				<<set $mercFreeManpower += $mercUnits[_i].troops>>
				<<set $mercEmployedManpower -= $mercUnits[_i].troops>>
				<<set $mercUnits.deleteAt(_i)>>
				<<set $activeUnits-->>
				<<goto "secBarracks">>
			<</link>>
			|
			<<link "Review Equipment and upgrades">>
				<<set $targetUnit = "mercUnits">>
				<<set $targetIndex = _i>>
				<<goto "seeUnit">>
			<</link>>
			|
			<<if $mercUnits[_i].troops < $mercUnits[_i].maxTroops && $mercFreeManpower > 0>>
				<<link "Replenish unit">>
					<<if $mercFreeManpower >= $mercUnits[_i].maxTroops - $mercUnits[_i].troops>>
						<<set $mercFreeManpower -= $mercUnits[_i].maxTroops - $mercUnits[_i].troops>>
						<<set $mercEmployedManpower += $mercUnits[_i].maxTroops - $mercUnits[_i].troops>>
						<<set _expLoss = ($mercUnits[_i].maxTroops - $mercUnits[_i].troops) / $mercUnits[_i].troops>>
						<<set $mercUnits[_i].training -= $mercUnits[_i].training * _expLoss>>
						<<set $mercUnits[_i].troops = $mercUnits[_i].maxTroops>>
					<<else>>
						<<set $mercEmployedManpower += $mercFreeManpower>>
						<<set _expLoss = $mercFreeManpower / $mercUnits[_i].troops>>
						<<set $mercUnits[_i].training -= $mercUnits[_i].training * _expLoss>>
						<<set $mercUnits[_i].troops += $mercFreeManpower>>
						<<set $mercFreeManpower = 0>>
					<</if>>
					<<goto "secBarracks">>
				<</link>>
			<</if>>

		<<else>>

			$mercUnits[_i].platoonName lost too many operatives to be considered active.

			<<link "Disband the unit">>
				<<set _elimUnit = $mercUnits[_i]>>
				<<set _newMercUnits = []>>
				<<for _y = 0; _y < _sL; _y++>>
					<<if $mercUnits[_y] != _elimUnit>>
						<<set _newMercUnits.push($mercUnits[_y])>>
					<</if>>
				<</for>>
				<<set $mercUnits = _newMercUnits>>
				<<set $activeUnits-->>
				<<goto "secBarracks">>
			<</link>>
			|
			<<if $mercFreeManpower > 0>>
				<<link "Reform the unit">>
					<<if $mercFreeManpower >= $mercUnits[_i].maxTroops>>
						<<set $mercEmployedManpower += $mercUnits[_i].maxTroops>>
						<<set $mercFreeManpower -= $mercUnits[_i].maxTroops>>
						<<set $mercUnits[_i].troops = $mercUnits[_i].maxTroops>>
						<<set $mercUnits[_i].training = 0>>
					<<else>>
						<<set $mercEmployedManpower += $mercFreeManpower>>
						<<set $mercUnits[_i].troops += $mercFreeManpower>>
						<<set $mercFreeManpower = 0>>
						<<set $mercUnits[_i].training = 0>>
					<</if>>
					<<set $mercUnits[_i].active = 1>>
					<<goto "secBarracks">>
				<</link>>
			<</if>>
		<</if>>
		<</capture>>
	<</for>>
<<else>>

	Mercenaries are not allowed inside the arcology. You will not be able to recruit mercenary units.
<</if>>


code:
:: secExpOptions [nobr]

<<set $showEncyclopedia = 1, $encyclopedia = "Security Expansion", $nextButton = "Back to Options", $nextLink = "Options">>

__Battles__:
<<if $terrain != "oceanic">>

<<if $battlesEnabled == 0>>
		Battles are @@.red;DISABLED@@.
		<<link "Enable battles">>
			<<set $battlesEnabled = 1>>
			<<goto "secExpOptions">>
		<</link>>
	<<else>>
		Battles are @@.cyan;ENABLED@@.
	<<link "Disable battles">>
			<<set $battlesEnabled = 0>>
			<<goto "secExpOptions">>
		<</link>>
	<</if>>

    //Enable/disable battles.//
	<<if $battlesEnabled == 1>>

		<<if $majorBattlesEnabled == 0>>
			Major battles are @@.red;DISABLED@@.
			<<link "Enable major battles">>
				<<set $majorBattlesEnabled = 1>>
				<<set $battlesEnabled = 1>>
				<<goto "secExpOptions">>
			<</link>>
		<<else>>
			Major battles are @@.cyan;ENABLED@@.
		<<link "Disable major battles">>
				<<set $majorBattlesEnabled = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //Enable/disable late game large scale battles.//

		<<if $majorBattleGameOver == 0>>
			Major battles can cause gameover is @@.red;FALSE@@.
			<<link "Activate game loss in case of major battle defeat">>
				<<set $majorBattleGameOver = 1>>
				<<goto "secExpOptions">>
			<</link>>
		<<else>>
			Major battles can cause gameover is @@.cyan;TRUE@@.
		<<link "Deactivate game loss in case of major battle defeat">>
				<<set $majorBattleGameOver = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //By default a total defeat in a major battle will cause a gameover.//

		<<if $forceBattle == 0>>
			Battle guaranteed this week is @@.red;FALSE@@.
			<<link "Force engagement every week">>
				<<set $forceBattle = 1>>
				<<goto "secExpOptions">>
			<</link>>

		<<else>>
			Battle guaranteed this week is @@.cyan;TRUE@@.
		<<link "Do not force engagement every week">>
				<<set $forceBattle = 0>>
				<<set $forceMajorBattle = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //Will force battles to happen every week.//

		<<if $forceMajorBattle == 0>>
			Major battle guaranteed this week is @@.red;FALSE@@.
			<<link "Force major engagement every week">>
				<<set $forceMajorBattle = 1>>
				<<set $forceBattle = 1>>
				<<goto "secExpOptions">>
			<</link>>
		<<else>>
			Major battle guaranteed this week is @@.cyan;TRUE@@.
			<<link "Do not force major engagement every week">>
				<<set $forceMajorBattle = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //Will force major battles to happen every week. //
	<</if>>
<<else>>

Oceanic arcologies are not by default subject to external attacks. You can however allow them to happen anyway. If you choose to do so please keep in mind that descriptions and mechanics are not intended for naval combat but land combat.

	<<if $battlesEnabled == 0>>
		Battles are @@.red;DISABLED@@.
		<<link "Enable battles">>
			<<set $battlesEnabled = 1>>
			<<goto "secExpOptions">>
		<</link>>
	<<else>>
		Battles are @@.cyan;ENABLED@@.
	<<link "Disable battles">>
			<<set $battlesEnabled = 0>>
			<<goto "secExpOptions">>
		<</link>>
	<</if>>

    //Enable/disable battles.//
	<<if $battlesEnabled == 1>>

		<<if $majorBattlesEnabled == 0>>
			Major battles are @@.red;DISABLED@@.
			<<link "Enable major battles">>
				<<set $majorBattlesEnabled = 1>>
				<<set $battlesEnabled = 1>>
				<<goto "secExpOptions">>
			<</link>>
		<<else>>
			Major battles are @@.cyan;ENABLED@@.
		<<link "Disable major battles">>
				<<set $majorBattlesEnabled = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //Enable/disable late game large scale battles.//

		<<if $majorBattleGameOver == 0>>
			Major battles can cause gameover is @@.red;FALSE@@.
			<<link "Activate game loss in case of major battle defeat">>
				<<set $majorBattleGameOver = 1>>
				<<goto "secExpOptions">>
			<</link>>
		<<else>>
			Major battles can cause gameover is @@.cyan;TRUE@@.
		<<link "Deactivate game loss in case of major battle defeat">>
				<<set $majorBattleGameOver = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //By default a total defeat in a major battle will cause a gameover.//

		<<if $forceBattle == 0>>
			Battle guaranteed this week is @@.red;FALSE@@.
			<<link "Force engagement every week">>
				<<set $forceBattle = 1>>
				<<goto "secExpOptions">>
			<</link>>

		<<else>>
			Battle guaranteed this week is @@.cyan;TRUE@@.
		<<link "Do not force engagement every week">>
				<<set $forceBattle = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //Will force battles to happen every week.//

		<<if $forceMajorBattle == 0>>
			Major battle guaranteed this week is @@.red;FALSE@@.
			<<link "Force major engagement every week">>
				<<set $forceMajorBattle = 1>>
				<<set $forceBattle = 1>>
				<<goto "secExpOptions">>
			<</link>>
		<<else>>
			Major battle guaranteed this week is @@.cyan;TRUE@@.
			<<link "Do not force major engagement every week">>
				<<set $forceMajorBattle = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //Will force major battles to happen every week. //
	<</if>>
<</if>>

__Rebellions__:

	<<if $rebellionsEnabled == 0>>
		Rebellions are @@.red;DISABLED@@.
		<<link "Enable rebellions">>
			<<set $rebellionsEnabled = 1>>
			<<goto "secExpOptions">>
		<</link>>
	<<else>>
		Rebellions are @@.cyan;ENABLED@@.
	<<link "Disable rebellions">>
			<<set $rebellionsEnabled = 0>>
			<<goto "secExpOptions">>
		<</link>>
	<</if>>

    //Enable/disable rebellions.//

	<<if $rebellionsEnabled == 1>>
		<<if $rebellionGameOver == 0>>
			Rebellions can cause gameover is @@.red;FALSE@@.
			<<link "Activate game loss in case of rebellions succeeding">>
				<<set $rebellionGameOver = 1>>
				<<goto "secExpOptions">>
			<</link>>
		<<elseif $rebellionGameOver == 1>>
			Rebellions can cause gameover is @@.cyan;TRUE@@.
			<<link "Deactivate game loss in case of rebellions succeeding">>
				<<set $rebellionGameOver = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //Determines whether a total defeat in a rebellion will cause a gameover.//

		<<if $forceRebellion == 0>>
			Rebellions guaranteed this week is @@.red;FALSE@@.
			<<link "Force engagement every week">>
				<<set $forceRebellion = 1>>
				<<goto "secExpOptions">>
			<</link>>
		<<else>>
			Rebellions guaranteed this week is @@.cyan;TRUE@@.
		<<link "Do not force engagement every week">>
				<<set $forceRebellion = 0>>
				<<goto "secExpOptions">>
			<</link>>
		<</if>>

    //Will force rebellions to happen every week. Rebellions will take precedence over battles.//
	<</if>>

<<if $showBattleStatistics == 0 &&($battlesEnabled == 1 || $rebellionsEnabled == 1)>>

	Detailed battle statistics are @@.red;HIDDEN@@.
	<<link "Enable detailed battle statistics">>
		<<set $showBattleStatistics = 1>>
		<<goto "secExpOptions">>
	<</link>>

    //Will show detailed statistics and battle turns.//

<<elseif ($battlesEnabled == 1 || $rebellionsEnabled == 1)>>

	Detailed battle statistics are @@.cyan;SHOWN@@.
	<<link "Disable detailed battle statistics">>
		<<set $showBattleStatistics = 0>>
		<<goto "secExpOptions">>
	<</link>>

    //Will show detailed statistics and battle turns.//
<</if>>

<<if $allowPrestigeFromBattles == 0 && $battlesEnabled == 1>>

	Battles can give prestige to slaves is @@.red;DISABLED@@.
	<<link "enable prestige from battles for slaves">>
		<<set $allowPrestigeFromBattles = 1>>
		<<goto "secExpOptions">>
	<</link>>

    //If enabled, slaves will gain a rank of prestige for every 10 victories scored under their command.//

<<elseif $battlesEnabled == 1>>

	Battles can give prestige to slaves is @@.cyan;ENABLED@@.
	<<link "Disable prestige from battles for slaves">>
		<<set $allowPrestigeFromBattles = 0>>
		<<goto "secExpOptions">>
	<</link>>

    //If enabled, slaves will gain a rank of prestige for every 10 victories scored under their command.//
<</if>>

__Battles/Rebellions Difficulty__:

Difficulty is set to:
<<if $difficulty == 0.5>>
	@@.green;Very easy@@
<<elseif $difficulty == 0.75>>
	@@.limegreen;Easy@@
<<elseif $difficulty == 1>>
	@@.yellow;Normal@@
<<elseif $difficulty == 1.25>>
	@@.red;Hard@@
<<else>>
	@@.darkred;Very hard@@
<</if>>

<<link "Very easy">>
	<<set $difficulty = 0.5>>
	<<replace "#difficulty">>
		@@.green;Very easy@@
	<</replace>>
<</link>> | <<link "Easy">>
	<<set $difficulty = 0.75>>
	<<replace "#difficulty">>
		@@.limegreen;Easy@@
	<</replace>>
<</link>> | <<link "Normal">>
	<<set $difficulty = 1>>
	<<replace "#difficulty">>
		@@.yellow;Normal@@
	<</replace>>
<</link>> | <<link "Hard">>
	<<set $difficulty = 1.25>>
	<<replace "#difficulty">>
		@@.red;Hard@@
	<</replace>>
<</link>> | <<link "Very hard">>
	<<set $difficulty = 1.5>>
	<<replace "#difficulty">>
		@@.darkred;Very hard@@
	<</replace>>
<</link>>

__Battles frequency__:

Battle frequency is set to:
<<if $battleFrequency == 0.5>>
	@@.green;Very infrequent@@
<<elseif $battleFrequency == 0.75>>
	@@.limegreen;Infrequent@@
<<elseif $battleFrequency == 1>>
	@@.yellow;Normal@@
<<elseif $battleFrequency == 1.25>>
	@@.red;Frequent@@
<<else>>
	@@.darkred;Very frequent@@
<</if>>

<<link "Very infrequent">>
	<<set $battleFrequency = 0.5>>
	<<replace "#battleFrequency">>
		@@.green;Very infrequent@@
	<</replace>>
<</link>> | <<link "Infrequent">>
	<<set $battleFrequency = 0.75>>
	<<replace "#battleFrequency">>
		@@.limegreen;Infrequent@@
	<</replace>>
<</link>> | <<link "Normal">>
	<<set $battleFrequency = 1>>
	<<replace "#battleFrequency">>
		@@.yellow;Normal@@
	<</replace>>
<</link>> | <<link "Frequent">>
	<<set $battleFrequency = 1.25>>
	<<replace "#battleFrequency">>
		@@.red;Frequent@@
	<</replace>>
<</link>> | <<link "Very frequent">>
	<<set $battleFrequency = 1.5>>
	<<replace "#battleFrequency">>
		@@.darkred;Very frequent@@
	<</replace>>
<</link>>

__Major battle multiplier__:

Major battle multiplier is set to:
<<if $majorBattleMult == 0.5>>
	@@.green;Very low@@
<<elseif $majorBattleMult == 0.75>>
	@@.limegreen;Low@@
<<elseif $majorBattleMult == 1>>
	@@.yellow;Normal@@
<<elseif $majorBattleMult == 1.25>>
	@@.red;high@@
<<else>>
	@@.darkred;Very high@@
<</if>>

<<link "Very low">>
	<<set $majorBattleMult = 0.5>>
	<<replace "#majorBattleMult">>
		@@.green;Very low@@
	<</replace>>
<</link>> | <<link "Low">>
	<<set $majorBattleMult = 0.75>>
	<<replace "#majorBattleMult">>
		@@.limegreen;Low@@
	<</replace>>
<</link>> | <<link "Normal">>
	<<set $majorBattleMult = 1>>
	<<replace "#majorBattleMult">>
		@@.yellow;Normal@@
	<</replace>>
<</link>> | <<link "High">>
	<<set $majorBattleMult = 1.25>>
	<<replace "#majorBattleMult">>
		@@.red;High@@
	<</replace>>
<</link>> | <<link "Very high">>
	<<set $majorBattleMult = 1.5>>
	<<replace "#majorBattleMult">>
		@@.darkred;Very high@@
	<</replace>>
<</link>>

__Rebellions buildup speed__:

Rebellion speed is set to:
<<if $rebellionSpeed == 0.5>>
	@@.green;Very slow@@
<<elseif $rebellionSpeed == 0.75>>
	@@.limegreen;Slow@@
<<elseif $rebellionSpeed == 1>>
	@@.yellow;Normal@@
<<elseif $rebellionSpeed == 1.25>>
	@@.red;Fast@@
<<else>>
	@@.darkred;Very fast@@
<</if>>

<<link "Very slow">>
	<<set $rebellionSpeed = 0.5>>
	<<replace "#rebellionSpeed">>
		@@.green;Very slow@@
	<</replace>>
<</link>> | <<link "Slow">>
	<<set $rebellionSpeed = 0.75>>
	<<replace "#rebellionSpeed">>
		@@.limegreen;Slow@@
	<</replace>>
<</link>> | <<link "Normal">>
	<<set $rebellionSpeed = 1>>
	<<replace "#rebellionSpeed">>
		@@.yellow;Normal@@
	<</replace>>
<</link>> | <<link "Fast">>
	<<set $rebellionSpeed = 1.25>>
	<<replace "#rebellionSpeed">>
		@@.red;Fast@@
	<</replace>>
<</link>> | <<link "Very fast">>
	<<set $rebellionSpeed = 1.5>>
	<<replace "#rebellionSpeed">>
		@@.darkred;Very fast@@
	<</replace>>
<</link>>

__Debug/cheats:__
<<silently>><<MenialPopCap>><</silently>>

<<link "Set loyalty high">>
	<<for _i = 0; _i < $militiaUnits.length; _i++>>
		<<set $militiaUnits[_i].loyalty = random(80,100)>>
	<</for>>

	<<for _i = 0; _i < $slaveUnits.length; _i++>>
		<<set $slaveUnits[_i].loyalty = random(80,100)>>
	<</for>>

	<<for _i = 0; _i < $mercUnits.length; _i++>>
		<<set $mercUnits[_i].loyalty = random(80,100)>>
	<</for>>
	<<goto "secExpOptions">>
<</link>> | <<link "Set loyalty average">>
	<<for _i = 0; _i < $militiaUnits.length; _i++>>
		<<set $militiaUnits[_i].loyalty = random(40,60)>>
	<</for>>

	<<for _i = 0; _i < $slaveUnits.length; _i++>>
		<<set $slaveUnits[_i].loyalty = random(40,60)>>
	<</for>>

	<<for _i = 0; _i < $mercUnits.length; _i++>>
		<<set $mercUnits[_i].loyalty = random(40,60)>>
	<</for>>
	<<goto "secExpOptions">>
<</link>> | <<link "Set loyalty low">>
	<<for _i = 0; _i < $militiaUnits.length; _i++>>
		<<set $militiaUnits[_i].loyalty = random(20)>>
	<</for>>

	<<for _i = 0; _i < $slaveUnits.length; _i++>>
		<<set $slaveUnits[_i].loyalty = random(20)>>
	<</for>>

	<<for _i = 0; _i < $mercUnits.length; _i++>>
		<<set $mercUnits[_i].loyalty = random(20)>>
	<</for>>
	<<goto "secExpOptions">>
<</link>> | <<link "Randomize loyalty">>
	<<for _i = 0; _i < $militiaUnits.length; _i++>>
		<<set $militiaUnits[_i].loyalty = random(100)>>
	<</for>>

	<<for _i = 0; _i < $slaveUnits.length; _i++>>
		<<set $slaveUnits[_i].loyalty = random(100)>>
	<</for>>

	<<for _i = 0; _i < $mercUnits.length; _i++>>
		<<set $mercUnits[_i].loyalty = random(100)>>
	<</for>>
	<<goto "secExpOptions">>
<</link>>

<<link "Give Authority">>
	<<set $authority = Math.clamp($authority + 1000, 0, 20000)>>
	<<goto "secExpOptions">>
<</link>> | <<link "Remove Authority">>
	<<set $authority = Math.clamp($authority - 1000, 0, 20000)>>
	<<goto "secExpOptions">>
<</link>>

<<link "Raise security">>
	<<set $security = Math.clamp($security + 5, 0, 100)>>
	<<goto "secExpOptions">>
<</link>> | <<link "Lower security">>
	<<set $security = Math.clamp($security - 5, 0, 100)>>
	<<goto "secExpOptions">>
<</link>>

<<link "Raise crime">>
	<<set $crime = Math.clamp($crime + 5, 0, 100)>>
	<<goto "secExpOptions">>
<</link>> | <<link "Lower crime">>
	<<set $crime = Math.clamp($crime - 5, 0, 100)>>
	<<goto "secExpOptions">>
<</link>>

<<link "Give menial slaves">>
	<<set $helots = Math.clamp($helots + 30, 0, $PopCap)>>
	<<goto "secExpOptions">>
<</link>> | <<link "Remove menial slaves">>
	<<set $helots = Math.clamp($helots - 30, 0, $PopCap)>>
	<<goto "secExpOptions">>
<</link>>

<<link "Give militia manpower">>
	<<set $militiaFreeManpower += 30>>
	<<recalcManpower>>
	<<goto "secExpOptions">>
<</link>> | <<link "Remove militia manpower">>
	<<set $militiaFreeManpower = Math.clamp($militiaFreeManpower - 30, 0, $militiaFreeManpower)>>
	<<recalcManpower>>
	<<goto "secExpOptions">>
<</link>>

<<link "Give mercs manpower">>
	<<set $mercFreeManpower += 30>>
	<<recalcManpower>>
	<<goto "secExpOptions">>
<</link>> | <<link "Remove mercs manpower">>
	<<set $mercFreeManpower = Math.clamp($mercFreeManpower - 30, 0, $mercFreeManpower)>>
	<<recalcManpower>>
	<<goto "secExpOptions">>
<</link>>

<<link "Add citizens">>
	<<set $ACitizens = Math.clamp($ACitizens + 200, 0, $ACitizenLimit)>>
	<<goto "secExpOptions">>
<</link>> | <<link "Remove citizens">>
	<<set $ACitizens = Math.clamp($ACitizens - 200, 0, $ACitizenLimit)>>
	<<goto "secExpOptions">>
<</link>>

<<link "Add slaves">>
	<<set $ASlaves = Math.clamp($ASlaves + 200, 0, $ASlaveLimit)>>
	<<goto "secExpOptions">>
<</link>> | <<link "Remove slaves">>
	<<set $ASlaves = Math.clamp($ASlaves - 200, 0, $ASlaveLimit)>>
	<<goto "secExpOptions">>
<</link>>

<<link "Raise prosperity">>
	<<set $arcologies[0].prosperity = Math.clamp($arcologies[0].prosperity + 10, 0, 1000)>>
	<<goto "secExpOptions">>
<</link>> | <<link "Lower prosperity">>
	<<set $arcologies[0].prosperity = Math.clamp($arcologies[0].prosperity - 10, 0, 1000)>>
	<<goto "secExpOptions">>
<</link>>