:: securityReport [nobr]

/* init */
<<set _immigration = $ACitizens - $oldACitizens>>
<<set _secGrowth = 0>>
<<set _secRest = 0>>
<<set _restGrowth = 0>>
<<set _newSec = 0>>
<<set _crimeGrowth = 0>>
<<set _crimeCap = 0>>
<<set _newCrime = 0>>
<<set _recruits = 0>>
<<set _newMercs = 0>>

<<if $useTabs == 0>>__Security__<</if>>
<br>

<strong>Security</strong>:
<<if $secHelots > 0>>
	<<print $secHelots>> slaves work to improve the security of your arcology
	<<if $mercenaries >= 1 && $arcologyUpgrade.drones == 1>>
		, while your mercenaries and security drones tirelessly patrol the streets to keep them safe.
	<<elseif $arcologyUpgrade.drones == 1>>
		, while your security drones tirelessly patrol the arcology to keep it safe.
	<<else>>
		, while your loyal subordinates try to keep the arcology safe to the best of their abilites.
	<</if>>
<<else>>
	<<if $mercenaries >= 1 && $arcologyUpgrade.drones == 1>>
		Your mercenaries and security drones tirelessly patrol the streets to keep them safe.
	<<elseif $arcologyUpgrade.drones == 1>>
		Your security drones tirelessly patrol the arcology to keep it safe.
	<<else>>
		Your loyal subordinates try to keep the arcology safe to the best of their abilites.
	<</if>>
<</if>>

/* security modifiers */
<<if $PC.career == "mercenary">>
	Your past life as a mercenary makes it easier to manage the security of the arcology.
	<<set _secGrowth += 1>>
<</if>>
<<if $smilingManFate == 0>>
	The ex-criminal known to the world as The Smiling Man puts her impressive skills to work, dramatically increasing the efficacy of your security measures.
	<<set _secGrowth += 2>>
<</if>>
<<if $ACitizens + $ASlaves <= 2000>>
	The small number of residents makes their job easier.<<set _secGrowth += 2>>
<<elseif $ACitizens + $ASlaves <= 4000>>
	The fairly low number of residents makes their job a little easier.<<set _secGrowth += 1>>
<<elseif $ACitizens + $ASlaves <= 6000>>
	The fairly high number of residents makes their job a little harder.<<set _secGrowth -= -0.5>>
<<elseif $ACitizens + $ASlaves <= 8000>>
	The high number of residents makes their job harder.<<set _secGrowth -= 1>>
<<else>>
	The extremely high number of residents makes their job a lot harder.<<set _secGrowth -= 2>>
<</if>>
<<if _immigration < 10>>
	The limited number of immigrants that reached the arcology this week does not have any serious impact on the efficacy of current security measures.<<set _secGrowth += 0.5>>
<<elseif _immigration < 30>>
	The number of immigrants that reached the arcology this week is high enough to complicate security protocols.<<set _secGrowth -= 0.2>>
<<elseif _immigration < 60>>
	The high number of immigrants that reached the arcology this week complicates security protocols.<<set _secGrowth -= 0.5>>
<<elseif _immigration < 80>>
	The high number of immigrants that reached the arcology this week severely complicates security protocols.<<set _secGrowth -= 1>>
<<else>>
	The extremely high number of immigrants that reached the arcology this week severely complicates security protocols.<<set _secGrowth -= 2>>
<</if>>
<<if $crime < 20>>
	Crime is a distant problem in the arcology, which makes improving security easier.<<set _secGrowth += 1>>
<<elseif $crime < 40>>
	Crime is a minor problem in the arcology, not serious enough to disrupt security efforts.
<<elseif $crime < 60>>
	Crime is an issue in the arcology, which makes improving security harder.<<set _secGrowth -= 0.5>>
<<elseif $crime < 80>>
	Crime is an overbearing problem in the arcology, which makes improving security a lot harder.<<set _secGrowth -= 1>>
<<else>>
	Crime is sovereign in the arcology, which makes improving security extremely difficult.<<set _secGrowth -= 2>>
<</if>>
<<if $authority < 5000>>
	The low authority you hold on the arcology hampers the efforts of your security department.<<set _secGrowth -= 1>>
<<elseif $authority < 7500>>
	The limited authority you hold on the arcology hampers the efforts of your security department.<<set _secGrowth -= 0.5>>
<<elseif $authority < 10000>>
	The authority you hold on the arcology does not significantly impact the efforts of your security department.
<<elseif $authority < 15000>>
	The high authority you hold on the arcology facilitates the security department's work.<<set _secGrowth += 0.5>>
<<else>>
	The absolute authority you hold on the arcology makes the security department's work a lot easier.<<set _secGrowth += 1>>
<</if>>
<<if $activeUnits >= 6>>
	Your military is the size of a small army. Security is easier to maintain with such forces at your disposal. <<set _secGrowth += 0.5>>
<</if>>
<<if $lastAttackWeeks < 3 && $hasFoughtOnce == 1>>
	The recent attack has a negative effect on the security of the arcology.<<set _secGrowth -= 1>>
<<elseif $lastAttackWeeks < 5 && $hasFoughtOnce == 1>>
	While some time has passed, the last attack still has a negative effect on the security of the arcology.<<set _secGrowth -= 0.5>>
<<elseif $hasFoughtOnce == 1>>
	The arcology has not been attacked in a while, which has a positive effect on security.<<set _secGrowth += 0.5>>
<</if>>
<<if $blackOps == 1>>
	Your black ops team proves to be a formidable tool against anyone threatening the security of your arcology.
	<<set _secGrowth += 0.5 * random(1,2)>>
<</if>>

<<if $garrison.assistantTime > 0>>
	With the central CPU core of the assistant down, managing security is a much harder task. Inevitably some little but important details will slip past your agents.
	It will still take <<if $garrison.assistantTime> 1>>$garrison.assistantTime weeks<<else>>a week<</if>> to finish repair works.
	<<set _secGrowth-->>
	<<set _crimeGrowth++>>
	<<set $garrison.assistantTime-->>
<</if>>
	
<<if $SFSupportLevel >= 3>>
	The two squads of $securityForceName assigned to the Security HQ provide an essential help to the security department.
<</if>>
<<if $SFSupportLevel >= 2>>
	The training officers of $securityForceName assigned to the Security HQ improve its effectiveness.
<</if>>
<<if $SFSupportLevel >= 1>>
	Providing your Security Department with equipment from $securityForceName slightly boosts the security of your arology.
<</if>>

/* resting point */
<<set _secRest = $secRestPoint * ($secHelots / $reqHelots)>>
<<if _secRest < 0>>
	<<set _secRest = 20>>
<</if>>
<<if _secRest < $secRestPoint && $secHQ == 1>>
	The limited staff assigned to the HQ hampered the improvements to security achieved this week.
<<elseif _secRest < $secRestPoint>>
	The limited infrastructure available slowly erodes away the security level of the arcology.  
<</if>>
<<if $security > (_secRest + 5)>>
	The security level of the arcology is over its effective resting point, limiting the achievable growth this week.
	<<set _secGrowth *= 0.5>>
<<elseif $security < (_secRest - 5)>>
	The security level of the arcology is under its effective resting point, speeding up its growth.
	<<set _secGrowth *= 1.5>>
<<elseif $security ==  _secRest>>
	The security level of the arcology is at its effective resting point, this severely limits the influence of external factors on the change achievable this week.
	<<set _secGrowth *= 0.3>>
<<else>>
	The security level of the arcology is near its effective resting point, this severely limits the influence of external factors on the change achievable this week.
	<<set _secGrowth *= 0.3>>
<</if>>
<<set _restGrowth = (_secRest - $security) * 0.2>>
<<set _newSec = Math.trunc($security + _secGrowth + _restGrowth)>>
<<if _newSec < $security>>
	This week @@.red;security decreased@@.
<<elseif _newSec == $security>>
	This week @@.yellow;security did not change@@.
<<else>>
	This week @@.green;security improved@@.
<</if>>
<<set $security = Math.clamp(_newSec, 0, 100)>>

<br>
<br>

<strong>Crime</strong>:
/* crime modifiers */
<<if $week < 30>>
	Due to the deterioration of the old world countries, organized crime focuses more and more on the prosperous free cities, yours included. This has a small impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 0.5>>
<<elseif $week < 60>>
	Due to the deterioration of the old world countries, organized crime focuses more and more on the prosperous free cities, yours included. This has a noticeable impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 1>>
<<elseif $week < 90>>
	Due to the deterioration of the old world countries, organized crime focuses more and more on the prosperous free cities, yours included. This has a moderate impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 1.5>>
<<elseif $week < 120>>
	Due to the deterioration of the old world countries, organized crime focuses more and more on the prosperous free cities, yours included. This has a big impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 2>>
<<else>>
	Due to the deterioration of the old world countries, organized crime focuses more and more on the prosperous free cities, yours included. This has a huge impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 2.5>>
<</if>>
<<if $arcologies[0].prosperity < 50>>
	The low prosperity of the arcology facilitates criminal recruitment and organization.<<set _crimeGrowth += 2>>
<<elseif $arcologies[0].prosperity < 80>>
	The fairly low prosperity of the arcology facilitates criminal recruitment and organization.<<set _crimeGrowth += 1>>
<<elseif $arcologies[0].prosperity < 120>>
	The prosperity of the arcology is not high or low enough to have significant effects on criminal recruitment and organization.
<<elseif $arcologies[0].prosperity < 160>>
	The prosperity of the arcology is high enough to provide its citizens a decent life, hampering criminal recruitment and organization.<<set _crimeGrowth -= 0.5>>
<<elseif $arcologies[0].prosperity < 180>>
	The prosperity of the arcology is high enough to provide its citizens a decent life, significantly hampering criminal recruitment and organization.<<set _crimeGrowth -= 1>>
<<else>>
	The prosperity of the arcology is high enough to provide its citizens a very good life, significantly hampering criminal recruitment and organization.<<set _crimeGrowth -= 2>>
<</if>>
<<if $ASlaves < 1000>>
	The low number of slaves in the arcology does not hinder the activity of law enforcement, limiting crime growth.<<set _crimeGrowth -= 1>>
<<elseif $ASlaves < 2000>>
	The fairly low number of slaves in the arcology does not hinder significantly the activity of law enforcement, limiting crime growth.<<set _crimeGrowth -= 0.5>>
<<elseif $ASlaves < 3000>>
	The number of slaves in the arcology is becoming an impediment for law enforcement, facilitating crime growth.<<set _crimeGrowth += 1>>
<<else>>
	The number of slaves in the arcology is becoming a a big issue for law enforcement, facilitating crime growth.<<set _crimeGrowth += 1.5>>
<</if>>
<<if $security <= 20>>
	The security measures in place are severely limited, allowing crime to grow uncontested.
<<elseif $security <= 50>>
	The security measures in place are of limited effect and use, giving only mixed results in their fight against crime.<<set _crimeGrowth -= 1>>
<<elseif $security <= 75>>
	The security measures in place are well developed and effective, making a serious dent in the profitability of criminal activity in your arcology.<<set _crimeGrowth -= 2.5>>
<<else>>
	The security measures in place are extremely well developed and very effective, posing a serious threat even to the most powerful criminal organizations in existence.<<set _crimeGrowth -= 5>>
<</if>>
<<if $authority < 5000>>
	Your low authority allows crime to grow undisturbed.<<set _crimeGrowth += 1>>
<<elseif $authority < 7500>>
	Your relatively low authority facilitates criminal activities.<<set _crimeGrowth += 0.5>>
<<elseif $authority < 10000>>
	Your authority is not high enough to discourage criminal activity.
<<elseif $authority < 15000>>
	Your high authority is an effective tool against crime.<<set _crimeGrowth -= 1>>
<<else>>
	Your absolute authority is an extremely effective tool against crime.<<set _crimeGrowth -= 2>>
<</if>>
<<if $cash >= 100000>>
	Your great wealth acts as a beacon for the greediest criminals, calling them to your arcology as moths to a flame.<<set _crimeGrowth += 0.5>>
<</if>>	
<<if $marketInfiltration == 1>>
	<<set _crimeGrowth += 0.5 * random(1,2)>>
<</if>>

/* crime cap */
<<set _crimeCap = Math.trunc(Math.clamp($crimeCap + $crimeCap * ($secHelots / $reqHelots),0,100))>>
<<if _crimeCap < $crimeCap && $secHQ == 1>>
	The limited staff assigned to the HQ allows more space for criminals to act.
<</if>>
<<set _newCrime = Math.trunc($crime + _crimeGrowth)>>
<<if _newCrime > _crimeCap>>
	<<set _newCrime = _crimeCap>>
<</if>>
<<if _newCrime > $crime>>
	This week @@.red;crime increased@@.
<<elseif _newCrime == $crime>>
	This week @@.yellow;crime did not change@@.
<<else>>
	This week @@.green;crime decreased@@.
<</if>>
<<set $crime = Math.clamp(_newCrime,0,100)>>

<br>
<br>

<<if $militiaFounded == 1 || $activeUnits >= 1>>
	/* militia */
	<strong>Military</strong>: 
	<<if $recruitVolunteers == 1>>
		Your militia accepts only volunteering citizens, ready to defend their arcology.
		<<set _recruits = random(1,2)>>
		<<if $rep >= 10000>>
			Many citizens volunteer just to fight for someone of your renown.
			<<set _recruits += 1>>
		<</if>>
		<<if $authority >= 10000>>
			Many citizens feel it is their duty to fight for you, boosting volunteer enrollment.
			<<set _recruits += 1>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax phisical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruits += 1>>
		<</if>>
		<<if $militiaTotalManpower - $militiaTotalCasualties + _recruits <= 0.02 * $ACitizens>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<else>>
			There are not many more citizens willing to join the arcology armed forces. You'll need to enact higher recruitment edicts if you need more manpower.
		<</if>>
	<<elseif $conscription == 1>>
		Adult citizens are required to join the militia for a period of time.
		<<set _recruits = random(3,5)>>
		<<if $militaryExemption == 1>>
			Some citizens prefer to contribute to the arcology's defense through financial support rather than military service, making you @@.yellowgreen;a small sum@@.
			<<set _recruits -= random(1,2)>>
			<<set $cash += 250>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax phisical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruits += 1>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruits -= random(0,1)>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endager themselves and their children.
			<<set _recruits -= 1>>
		<</if>>
		<<if $militiaTotalManpower - $militiaTotalCasualties + _recruits <= 0.05 * $ACitizens>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<else>>
			There are not many more citizens able to join the arcology armed forces. You'll need to enact higher recruitment edicts if you need more manpower.
		<</if>>
	<<elseif $militaryService == 1>>
		Adult citizens are required to register and serve in the militia whenever necessary.
		<<set _recruits = random(5,7)>>
		<<if $militaryExemption == 1>>
			Some citizens prefer to contribute to the arcology's defense through financial support rather than military service, making you @@.yellowgreen;a small sum@@.
			<<set _recruits -= random(1,2)>>
			<<set $cash += 250>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax phisical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruits += 1>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruits -= random(0,1)>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endager themselves and their children.
			<<set _recruits -= 1>>
		<</if>>
		<<if $militiaTotalManpower - $militiaTotalCasualties + _recruits <= 0.10 * $ACitizens>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<else>>
			There are not many more citizens able to join the arcology armed forces. You'll need to enact higher recruitment edicts if you need more manpower.
		<</if>>
	<<elseif $militarizedSociety == 1>>
		Every citizen is required to train and participate in the military activities of the arcology.
		<<set _recruits = random(7,9)>>
		<<if $militaryExemption == 1>>
			Some citizens prefer to contribute to the arcology's defense through financial support rather than military service, making you @@.yellowgreen;a small sum@@.
			<<set _recruits -= random(1,2)>>
			<<set $cash += 250>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax phisical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruits += 1>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruits -= random(0,1)>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endager themselves and their children.
			<<set _recruits -= 1>>
		<</if>>
		<<if $militiaTotalManpower - $militiaTotalCasualties + _recruits <= 0.20 * $ACitizens>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<else>>
			There are not many more citizens able to join the arcology armed forces. You'll need to enact higher recruitment edicts if you need more manpower.
		<</if>>
	<</if>>
	
	/* mercs */
	<<if $mercenaries >= 1>>
		<<set _newMercs = random(0,3)>>
		<<if $rep < 6000>>
			Your low reputation turns some mercenaries away, hoping to find contracts that would bring them more renown.<<set _newMercs -= 1>>
		<<elseif $rep < 12000>>
			Your reputation is not high enough to attract many mercenaries to your free city.
		<<else>>
			Your reputation attracts many guns for hire who would be proud to have such distinct character on their resume.<<set _newMercs += 1>>
		<</if>>
		<<if $arcologies[0].prosperity < 50>>
			The low prosperity of the arcology discourages new guns for hire from coming to your arcology.<<set _newMercs -= 1>>
		<<elseif $arcologies[0].prosperity < 80>>
			The fairly low prosperity of the arcology discourages new guns for hire from coming to your arcology.<<set _newMercs += 1>>
		<<elseif $arcologies[0].prosperity < 120>>
			The prosperity of the arcology attracts a few mercenaries, hopeful to find lucrative contracts within its walls.<<set _newMercs += random(1,2)>>
		<<elseif $arcologies[0].prosperity < 160>>
			The fairly high prosperity of the arcology attracts some mercenaries, hopeful to find lucrative contracts within its walls.<<set _newMercs += random(2,3)>>
		<<elseif $arcologies[0].prosperity < 180>>
			The high prosperity of the arcology is attracts some mercenaries, hopeful to find lucrative contracts within its walls.<<set _newMercs += random(2,4)>>
		<<else>>
			The very high prosperity of the arcology attracts a lot of mercenaries, hopeful to find lucrative contracts within its walls.<<set _newMercs += random(3,5)>>
		<</if>>
		<<if $crime > 60>>
			The powerful crime organizatiosn that nested themselves in the arcology have an unending need for cheap guns for hire, many mercenaries flock to your free city in search of employment.<<set _newMercs += random(1,2)>>
		<</if>>
		<<if _newMercs > 0>>
			<<set $mercTotalManpower += _recruits>>
			<<set $mercFreeManpower += _recruits>>
			This week <<print _newMercs>> citizens joined the militia.
		<<else>>
			This week no new mercenaries reached the arcology.
		<</if>>
	<</if>>
	
	/* training */
	<<if $secBarracksUpgrades.training >= 1>>
		<<if $secBarracksUpgrades.training == 1>>
			<<set _sL = $slaveUnits.length>>
			<<for _i = 0; _i < _sL; _i++>>
				<<if $slaveUnits[_i].training < 100>>
					<br>$slaveUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, slowing increasing their experience level.
					<<set $slaveUnits[_i].training += random(2,4)>>
				<</if>>
			<</for>>
			<<set _mL = $militiaUnits.length>>
			<<for _i = 0; _i < _mL; _i++>>
				<<if $militiaUnits[_i].training < 100>>
					<br>$militiaUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, slowing increasing their experience level.
					<<set $militiaUnits[_i].training += random(2,4)>>
				<</if>>
			<</for>>
			<<set _meL = $mercUnits.length>>
			<<for _i = 0; _i < _meL; _i++>>
				<<if $mercUnits[_i].training < 100>>
					<br>$mercUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, slowing increasing their experience level.
					<<set $mercUnits[_i].training += random(2,4)>>
				<</if>>
			<</for>>
		<<elseif $secBarracksUpgrades.training == 2>>
			<<set _sL = $slaveUnits.length>>
			<<for _i = 0; _i < _sL; _i++>>
				<<if $slaveUnits[_i].training < 100>>
					<br>$slaveUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, increasing their experience level.
					<<set $slaveUnits[_i].training += random(3,5)>>
				<</if>>
			<</for>>
			<<set _mL = $militiaUnits.length>>
			<<for _i = 0; _i < _mL; _i++>>
				<<if $militiaUnits[_i].training < 100>>
					<br>$militiaUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, increasing their experience level.
					<<set $militiaUnits[_i].training += random(3,5)>>
				<</if>>
			<</for>>
			<<set _meL = $mercUnits.length>>
			<<for _i = 0; _i < _meL; _i++>>
				<<if $mercUnits[_i].training < 100>>
					<br>$mercUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, increasing their experience level.
					<<set $mercUnits[_i].training += random(4,6)>>
				<</if>>
			<</for>>
		<<elseif $secBarracksUpgrades.training == 3>>
			<<set _sL = $slaveUnits.length>>
			<<for _i = 0; _i < _sL; _i++>>
				<<if $slaveUnits[_i].training < 100>>
					<br>$slaveUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, quickly increasing their experience level.
					<<set $slaveUnits[_i].training += random(4,6)>>
				<</if>>
			<</for>>
			<<set _mL = $militiaUnits.length>>
			<<for _i = 0; _i < _mL; _i++>>
				<<if $militiaUnits[_i].training < 100>>
					<br>$militiaUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, quickly increasing their experience level.
					<<set $militiaUnits[_i].training += random(4,6)>>
				<</if>>
			<</for>>
			<<set _meL = $mercUnits.length>>
			<<for _i = 0; _i < _meL; _i++>>
				<<if $mercUnits[_i].training < 100>>
					<br>$mercUnits[_i].platoonName is able to make use of the training facilities to better prepare its soldiers, quickly increasing their experience level.
					<<set $mercUnits[_i].training += random(4,6)>>
				<</if>>
			<</for>>
		<</if>>
	<</if>>
<</if>>

<br>
<br>
<<if $brainImplantProject > 0 && $brainImplant == 106>>
	<<set $brainImplant += $brainImplantProject>>
	<<if 100 - $brainImplant <= 0>>
		The project has been completed!
		<<set $brainImplant = 101>>
	<<else>>
		The great brain implant project is proceeding steadily. This week we made
		<<if $brainImplantProject <= 2>>
			some small
		<<elseif $brainImplantProject <= 4>>
			some
		<<else>>
			good
		<</if>>
		progress
	<</if>>
<</if>>