code:
:: authorityReport [nobr]

<<if $useTabs == 0>>__Authority__<</if>>

Your authority is
<<if $SecExp.core.authority > 19500>>
	nearly absolute. The arcology is yours to command as it pleases you.
<<elseif $SecExp.core.authority > 15000>>
	extremely high. There's little you cannot do within the walls of your arcology.
<<elseif $SecExp.core.authority > 10000>>
	high. You command respect and fear in equal measure.
<<elseif $SecExp.core.authority > 5000>>
	moderate. You command some respect from your citizens.
<<else>>
	low. You command no respect or fear from your citizens.
<</if>>

<<set _authGrowth = 0>>

<<if $PC.career == "wealth">>
	As part of the idle rich, you were used to having obedience coming naturally to you. Now you find it harder to maintain authority over the arcology.
	<<set _authGrowth -= (10 * random(5,15))>>
<<elseif $PC.career == "slaver">>
	Your past as a slaver helps you assert your authority over the arcology.
	<<set _authGrowth += (10 * random(5,15))>>
<<elseif $PC.career == "escort">>
	Given your past career as an escort, you find it hard to assert your authority over the arcology and its inhabitants.
	<<set _authGrowth -= (10 * random(5,15))>>
<<elseif $PC.career == "servant">>
	Given your past career as a servant, you find it hard to assert your authority over the arcology and its inhabitants.
	<<set _authGrowth -= (10 * random(5,15))>>
<<elseif $PC.career == "BlackHat">>
	Given your past career as a (rather questionable) incursion specialist, you find it hard to assert your authority over the arcology and its inhabitants, despite what you may know about them.
	<<set _authGrowth -= (10 * random(5,15))>>
<<elseif $PC.career == "gang">>
	Given your past life as a gang leader, you find it easier to assert your authority over the arcology and its inhabitants.
	<<set _authGrowth += (10 * random(5,15))>>
<</if>>

<<if $rep >= 19500>>
	Your legend is so well known that your mere presence commands respect and obedience, increasing your authority.
	<<set _authGrowth += (10 * random(10,20))>>
<<elseif $rep >= 15000>>
	Your reputation is so high that your mere presence commands respect, increasing your authority.
	<<set _authGrowth += (10 * random(5,15))>>
<<elseif $rep >= 10000>>
	Your reputation is high enough that your presence commands some respect, increasing your authority.
	<<set _authGrowth += (10 * random(2,8))>>
<</if>>

<<if $SecExp.core.security >= 90>>
	Your arcology is incredibly secure and your citizens know quite well who to thank, greatly increasing your authority.
	<<set _authGrowth += (10 * random(10,20))>>
<<elseif $SecExp.core.security >= 70>>
	Your arcology is really secure and your citizens know quite well who to thank, increasing your authority.
	<<set _authGrowth += (10 * random(5,15))>>
<<elseif $SecExp.core.security >= 50>>
	Your arcology is quite secure and your citizens know who to thank, increasing your authority.
	<<set _authGrowth += (10 * random(2,8))>>
<</if>>

<<if $SecExp.core.crimeLow >= 90>>
	The all powerful criminal organizations controlling the arcology have a very easy time undermining your authority.
	<<set _authGrowth -= (10 * random(10,20))>>
<<elseif $SecExp.core.crimeLow >= 70>>
	Crime is king in the arcology, powerful criminals have a very easy time undermining your authority.
	<<set _authGrowth -= (10 * random(5,15))>>
<<elseif $SecExp.core.crimeLow >= 50>>
	Criminal organizations have a strong foothold in the arcology, their activities undermine your authority.
	<<set _authGrowth -= (10 * random(2,8))>>
<</if>>

<<if $averageDevotion >= 50 && $averageTrust >= 50>>
	The high devotion and trust of your slaves speak eloquently of your leadership capabilities, helping your authority grow.
	<<set _authGrowth += (5 * (($averageDevotion + $averageTrust) / 10))>>
<<elseif $averageDevotion >= 50>>
	The high devotion of your slaves speaks eloquently of your leadership capabilities, helping your authority grow.
	<<set _authGrowth += (5 * ($averageDevotion / 10))>>
<<elseif $averageTrust >= 50>>
	The high trust of your slaves speaks eloquently of your leadership capabilities, helping your authority grow.
	<<set _authGrowth += (5 * ($averageTrust / 10))>>
<</if>>

<<if $arcologies[0].ownership >= 90>>
	You own so much of the arcology that your authority quickly increases.
	<<set _authGrowth += (5 * Math.trunc($arcologies[0].ownership / 10))>>
<<elseif $arcologies[0].ownership >= 70>>
	You own a big part of the arcology, causing your authority to increase.
	<<set _authGrowth += (5 * Math.trunc($arcologies[0].ownership / 10))>>
<<elseif $arcologies[0].ownership >= 50>>
	You own the majority of the arcology, causing your authority to slowly increase.
	<<set _authGrowth += (5 * Math.trunc($arcologies[0].ownership / 10))>>
<<else>>
	Your low ownership of the arcology causes your authority to decrease.
	<<set _authGrowth -= (5 * Math.trunc($arcologies[0].ownership / 10))>>
<</if>>

<<if App.SecExp.battle.activeUnits() >= 9>>
	Your military is massive; commanding so many troops greatly increases your authority.
<<elseif App.SecExp.battle.activeUnits() >= 7>>
	Your military is huge; commanding such a number of soldiers increases your authority.
<<elseif App.SecExp.battle.activeUnits() >= 4>>
	Your military is at a decent size; commanding a small army increases your authority.
<</if>>
<<if App.SecExp.battle.activeUnits() >= 4>>
	<<set _authGrowth += (12 * App.SecExp.battle.activeUnits())>>
<</if>>

<<set _size = App.SF.upgrades.total()>>
<<if $SF.Toggle && $SF.Active >= 1 && _size > 10>>
	Having a powerful special force increases your authority.
	<<set _authGrowth += (_size/10)>>
<</if>>

<<if $arcologies[0].FSChattelReligionist >= 90>>
	Religious organizations have a tight grip on the minds of your residents and their dogma greatly helps your authority grow.
	<<set _authGrowth += $arcologies[0].FSChattelReligionist>>
<<elseif $arcologies[0].FSChattelReligionist >= 50>>
	Religious organizations have a tight grip on the minds of your residents and their dogma helps your authority grow.
	<<set _authGrowth += $arcologies[0].FSChattelReligionist>>
<</if>>

<<set _elite = $arcologies[0].FSNeoImperialistLaw2 == 1 ? 'Barons' : 'Societal Elite'>>
<<if $arcologies[0].FSRestart >= 90>>
	The arcology's society is extremely stratified. The reliance on the _elite by the lower classes greatly increases your reputation.
	<<set _authGrowth += $arcologies[0].FSRestart>>
<<elseif $arcologies[0].FSRestart >= 50>>
	The arcology's society is very stratified. The reliance on the _elite by the lower classes increases your reputation.
	<<set _authGrowth += $arcologies[0].FSRestart>>
<</if>>

<<if $arcologies[0].FSPaternalist >= 90>>
	Your extremely paternalistic society has the unfortunate side effects of spreading dangerous ideals in the arcology, greatly damaging your authority.
	<<set _authGrowth -= Math.clamp($arcologies[0].FSPaternalist, 0, 100)>>
<<elseif $arcologies[0].FSPaternalist >= 50>>
	Your paternalistic society has the unfortunate side effects of spreading dangerous ideals in the arcology, damaging your authority.
	<<set _authGrowth -= Math.clamp($arcologies[0].FSPaternalist, 0, 100)>>
<</if>>

<<if $arcologies[0].FSNull >= 90>>
	Extreme cultural openness allows dangerous ideas to spread in your arcology, greatly damaging your reputation.
	<<set _authGrowth -= $arcologies[0].FSNull>>
<<elseif $arcologies[0].FSNull >= 50>>
	Mild cultural openness allows dangerous ideas to spread in your arcology, damaging your reputation.
	<<set _authGrowth -= $arcologies[0].FSNull>>
<</if>>

<<if $SecExp.buildings.propHub>>
	<<if $SecExp.buildings.propHub.upgrades.miniTruth >= 1>>
		Your authenticity department works tirelessly to impose your authority in all of the arcology.
		<<set _authGrowth += (15 * $SecExp.buildings.propHub.upgrades.miniTruth)>>
	<</if>>
	<<if $SecExp.buildings.propHub.upgrades.secretService >= 1>>
		Your secret services constantly keep under surveillance any potential threat, intervening when necessary. Rumors of the secretive security service and mysterious disappearances make your authority increase.
		<<set _authGrowth += (15 * $SecExp.buildings.propHub.upgrades.secretService)>>
	<</if>>
<</if>>

<<if App.SecExp.upkeep.edictsAuth() > 0>>
	Some of your authority is spent maintaining your edicts.
	<<set _authGrowth -= App.SecExp.upkeep.edictsAuth()>>
<</if>>

This week
<<if _authGrowth > 0>>
	@@.green;authority has increased.@@
<<elseif _authGrowth == 0>>
	@@.yellow;authority did not change.@@
<<else>>
	@@.red;authority has decreased.@@
<</if>>

<<set $SecExp.core.authority += _authGrowth>>
<<set $SecExp.core.authority = Math.trunc(Math.clamp($SecExp.core.authority, 0, 20000))>>

<<if $SecExp.settings.rebellion.enabled == 1>>

	<<include "rebellionGenerator">> /* rebellions */
<</if>>

repo_name: Welptard/fc

license: mit


code:
:: propagandaHub [nobr jump-to-safe jump-from-safe]

<<if $career == "capitalist" || $career == "celebrity" || $career == "wealth">>
	<<set _HistoryDiscount = .5>>
<<else>>
	<<set _HistoryDiscount = 1>>
<</if>>

<<set $nextButton = "Back">>
<<set $nextLink = "Main">>

Propaganda Hub

The propaganda hub is a surprisingly inconspicuous building, dimly lit from the outside. You are well aware however of its role and its importance. You confidently enter its unassuming doorway and calmly review the work being done here.

<<if $RecruiterID != 0>>
	<<setLocalPronouns _S.Recruiter>>

	<<if $SecExp.buildings.propHub.recruiterOffice == 0>>
		<<link "Give <<= SlaveFullName(_S.Recruiter)>> an office.""propagandaHub">>
			<<set $SecExp.buildings.propHub.recruiterOffice = 1>>
		<</link>>
	<<else>>
		<<link "Remove <<= SlaveFullName(_S.Recruiter)>> from $his office.""propagandaHub">>
			<<set $SecExp.buildings.propHub.recruiterOffice = 0>>
		<</link>>
	<</if>>

//Providing them with an office will help boost your chosen campaign. This also stacks with the campaign boost edict.//
<</if>>
/* classic propaganda */

<<if $SecExp.buildings.propHub.upgrades.campaign == 0>>
	<<link "Set up a propaganda campaign" "propagandaHub">>
		<<set $SecExp.buildings.propHub.upgrades.campaign += 1>>
		<<run cashX(forceNeg(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount)), "capEx")>>
		<<set $SecExp.buildings.propHub.focus = "social engineering">>
	<</link>>

Set up a propaganda campaign to align your citizens with your goals.

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will provide the focused resource each week, but will cost reputation in upkeep.//
<<else>>
	You have set up a team of trained slaves and expert propagandists, ready to spread the message of your choosing to the population.

Focus on:
	<<if $SecExp.buildings.propHub.focus == "social engineering">>
		social engineering
	<<else>>
		<<link "social engineering" "propagandaHub">>
			<<set $SecExp.buildings.propHub.focus = "social engineering">>
		<</link>>
	<</if>>
	|
	<<if $SecExp.buildings.propHub.focus == "immigration">>
	immigration
	<<else>>
		<<link "immigration" "propagandaHub">>
			<<set $SecExp.buildings.propHub.focus = "immigration">>
		<</link>>
	<</if>>
	|
	<<if $SecExp.buildings.propHub.focus == "enslavement">>
		 enslavement
	<<else>>
		<<link "enslavement" "propagandaHub">>
			<<set $SecExp.buildings.propHub.focus = "enslavement">>
		<</link>>
	<</if>>
	<<if $SecExp.edicts.defense.militia >= 1>>
		|
		<<if $SecExp.buildings.propHub.focus == "recruitment">>
			recruitment
		<<else>>
			<<link "recruitment" "propagandaHub">>
				<<set $SecExp.buildings.propHub.focus = "recruitment">>
			<</link>>
		<</if>>
	<</if>>

	You are concentrating your propaganda efforts towards
	<<if $SecExp.buildings.propHub.focus == "social engineering">>
		increasing the acceptance of your chosen future societies.
	<<elseif $SecExp.buildings.propHub.focus == "immigration">>
		convincing more people to immigrate to your arcology.
	<<elseif $SecExp.buildings.propHub.focus == "enslavement">>
		convincing more people to voluntarily enslave themselves.
	<<elseif $SecExp.buildings.propHub.focus == "recruitment">>
		convincing more citizens to enter the militia.
	<</if>>

	<<if $SecExp.buildings.propHub.upgrades.campaign < 5>>
		<<set _costC = Math.trunc(5000 * $upgradeMultiplierArcology * ($SecExp.buildings.propHub.upgrades.campaign + 1) * _HistoryDiscount*$HackingSkillMultiplier)>>
		<<link "Invest more resources in the propaganda machine" "propagandaHub">>
			<<run cashX(-_costC, "capEx")>>
			<<set $SecExp.buildings.propHub.upgrades.campaign += 1>>
			<<= IncreasePCSkills('hacking', 0.5)>>
		<</link>>

Invest more resources into the project to increase its effectiveness.

//Costs <<print cashFormat(_costC)>>. Will provide more of the focused resource each week but increase reputation upkeep.//
	<<else>>
		You upgraded your propaganda machine to its limits.
	<</if>>
<</if>>

/* ministry of truth */
<<if $SecExp.buildings.propHub.upgrades.miniTruth == 0>>
	<<link "Set up the authenticity department" "propagandaHub">>
		<<set $SecExp.buildings.propHub.upgrades.miniTruth += 1>>
		<<run cashX(forceNeg(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount)), "capEx")>>
	<</link>>

Set up a department tasked with guaranteeing the authenticity of all information available in the arcology. Of course if reality is against what is best for the arcology, then it should be redacted as well.

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology * _HistoryDiscount))>>. Will provide authority and unlock special upgrades, but will increase upkeep.//
<<else>>
	<<if $SecExp.buildings.propHub.upgrades.miniTruth < 5>>
		<<set _costM = Math.trunc(5000*$upgradeMultiplierArcology * ($SecExp.buildings.propHub.upgrades.miniTruth + 1) * _HistoryDiscount)>>
		<<link "Enlarge the authenticity department" "propagandaHub">>
			<<run cashX(-_costM, "capEx")>>
			<<set $SecExp.buildings.propHub.upgrades.miniTruth += 1>>
		<</link>>

Invest more resources into the project to increase its effectiveness.

//Costs <<print cashFormat(_costM)>>. Will provide more authority each week, but increases upkeep.//
	<<else>>
		You have upgraded the authenticity department to its maximum.
	<</if>>

	<<if $SecExp.buildings.propHub.upgrades.fakeNews == 0>>
		<<link "Install a news generator" "propagandaHub">>
			<<set $SecExp.buildings.propHub.upgrades.fakeNews = 1>>
			<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount)), "capEx")>>
		<</link>>

Install an automatic news generator, able to fabricate thousands of plausible sounding news every day.

//Costs <<print cashFormat(Math.trunc(10000 * $upgradeMultiplierArcology * _HistoryDiscount))>>. The authenticity dept. now provides a small amount of reputation as well as authority, but increases upkeep.//
	<<else>>
		You have installed an automatic news generator. [[Remove news generator|propagandaHub][$SecExp.buildings.propHub.upgrades.fakeNews = 0]]
	<</if>>

	<<if $SecExp.buildings.propHub.upgrades.controlLeaks == 0>>
		<<link "Institute controlled leaks protocols" "propagandaHub">>
			<<set $SecExp.buildings.propHub.upgrades.controlLeaks = 1>>
			<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier)), "capEx")>>
			<<= IncreasePCSkills('hacking', 1)>>
		<</link>>

Institute a system able to release erroneous, but plausible, information about your business, leading your competitors to prepared financial traps.

//Costs <<print cashFormat(Math.trunc(10000 * $upgradeMultiplierArcology * _HistoryDiscount*$HackingSkillMultiplier))>>. The authenticity dept. now slightly increases prosperity each week as well as authority, but increases upkeep.//
	<<else>>
		You have instituted controlled leaks protocols, able to create fabricated leaks of sensible information. [[Shut down leak protocols|propagandaHub][$SecExp.buildings.propHub.upgrades.controlLeaks = 0]]
	<</if>>
<</if>>

/* secret police */
<<if $SecExp.buildings.propHub.upgrades.secretService == 0>>
	<<link "Set up personal secret service" "propagandaHub">>
		<<set $SecExp.buildings.propHub.upgrades.secretService += 1>>
		<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount)), "capEx")>>
	<</link>>

Set up a department tasked with the protection of your person, as well as operations requiring a delicate approach.

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology * _HistoryDiscount))>>. Will provide authority and unlock special upgrades, but will increase upkeep.//
<<else>>
	<<if $SecExp.buildings.propHub.upgrades.secretService < 5 && $rep >= ($SecExp.buildings.propHub.upgrades.secretService * 1000) + 5000>>
		<<set _costSS = Math.trunc(5000*$upgradeMultiplierArcology * ($SecExp.buildings.propHub.upgrades.secretService + 1) * _HistoryDiscount)>>
		<<link "Expand the secret service" "propagandaHub">>
			<<run cashX(-_costSS, "capEx")>>
			<<set $SecExp.buildings.propHub.upgrades.secretService += 1>>
		<</link>>

Invest more resources into the project to increase its effectiveness.

//Costs <<print cashFormat(_costSS)>>. Will provide more authority each week, but increases upkeep.//
	<<elseif $SecExp.buildings.propHub.upgrades.secretService < 5>>
		You lack the reputation to further expand operations.
	<<else>>
		You have upgraded the secret service to its maximum.
	<</if>>

	<<if $SecExp.buildings.propHub.upgrades.blackOps == 0>>
		<<link "Create a black ops team" "propagandaHub">>
			<<set $SecExp.buildings.propHub.upgrades.blackOps = 1>>
			<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount)), "capEx")>>
		<</link>>

Create a black ops team, ready to carry out corporate sabotage and sensitive operations to further your goals.

//Costs <<print cashFormat(Math.trunc(10000 * $upgradeMultiplierArcology * _HistoryDiscount))>>. The secret services now provides security as well as authority, but increases upkeep.//
	<<else>>
		You have created a black ops team.
	<</if>>

	<<if $SecExp.buildings.propHub.upgrades.marketInfiltration == 0>>
		<<link "Infiltrate" "propagandaHub">>
			<<set $SecExp.buildings.propHub.upgrades.marketInfiltration = 1>>
			<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount)), "capEx")>>
		<</link>>
		the black market in order to manipulate it.

//Costs <<print cashFormat(Math.trunc(10000 * $upgradeMultiplierArcology * _HistoryDiscount))>>. The secret services now provides cash as well as authority each week, but will increase crime growth.//
	<<else>>
		You have infiltrated the black market and are now in partial control of it. [[Withdraw from the black market|propagandaHub][$SecExp.buildings.propHub.upgrades.marketInfiltration = 0]]
	<</if>>
<</if>>


code:
:: riotControlCenter [nobr jump-to-safe jump-from-safe]

<<set $nextButton = "Back", $nextLink = "Main">>
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 $SecExp.rebellions.tension <= 33>>
	Tensions in the arcology are low. Political and ideological opposition against the arcology owner is almost unheard of.
<<elseif $SecExp.rebellions.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 $SecExp.buildings.riotCenter.upgrades.freeMedia == 0>>
	[[Provide free media access in all the arcology|riotControlCenter][cashX(forceNeg(Math.trunc(5000*$upgradeMultiplierArcology)), "capEx"), $SecExp.buildings.riotCenter.upgrades.freeMedia = 1]]

//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 $SecExp.buildings.riotCenter.upgrades.freeMedia < 5>>
		<<set _costFM = Math.trunc(5000 * $upgradeMultiplierArcology * ($SecExp.buildings.riotCenter.upgrades.freeMedia + 1)*$HackingSkillMultiplier)>>

<<link "Invest more resources in the free media project" "riotControlCenter">>
			<<run cashX(-_costFM, "capEx")>>
			<<set $SecExp.buildings.riotCenter.upgrades.freeMedia++>>
			<<= IncreasePCSkills('hacking', 0.5)>>
		<</link>>

Invest more resources into the project to increase its effectiveness.

//Costs <<print cashFormat(_costFM)>>. Will accelerate the tension decay, but will increase upkeep costs.//
	<<else>>
		You upgraded your free media scheme to its limits.
	<</if>>
<</if>>

<<if $SecExp.rebellions.slaveProgress <= 25>>
	There is very low unrest between slaves in the arcology. The chances of a rebellion igniting are extremely low.
<<elseif $SecExp.rebellions.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 $SecExp.rebellions.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 $SecExp.rebellions.citizenProgress <= 25>>
	There is very low unrest between the citizens of the arcology. The chances of a rebellion igniting are extremely low.
<<elseif $SecExp.rebellions.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 $SecExp.rebellions.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 $SecExp.buildings.riotCenter.upgrades.rapidUnit == 0>>
	[[Create rapid deployment riot units|riotControlCenter][cashX(forceNeg(Math.trunc(7500*$upgradeMultiplierArcology)), "capEx"), $SecExp.buildings.riotCenter.upgrades.rapidUnit = 1]]

//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 $SecExp.buildings.riotCenter.upgrades.rapidUnit < 5>>
		<<set _costRU = Math.trunc(5000 * $upgradeMultiplierArcology * ($SecExp.buildings.riotCenter.upgrades.rapidUnit + 1))>>

<<link "Invest more resources in the rapid deployment unit" "riotControlCenter">>
			<<run cashX(-_costRU, "capEx")>>
			<<set $SecExp.buildings.riotCenter.upgrades.rapidUnit++>>
		<</link>>

Invest more resources into the project to increase its effectiveness.

//Costs <<print cashFormat(_costRU)>>. Will lower action costs.//
	<<else>>

You upgraded your rapid deployment unit to its limits.
	<</if>>
	<<if $SecExp.buildings.riotCenter.upgrades.rapidUnitSpeed < 2>>
		<<set _costRUS = Math.trunc(5000 * $upgradeMultiplierArcology * ($SecExp.buildings.riotCenter.upgrades.rapidUnitSpeed + 1))>>

<<link "Enhance the internal informants network" "riotControlCenter">>
			<<run cashX(-_costRUS, "capEx")>>
			<<set $SecExp.buildings.riotCenter.upgrades.rapidUnitSpeed++>>
		<</link>>

Invest more resources into the effectiveness of the informants network.

//Costs <<print cashFormat(_costRUS)>>. Will reduce cooldown of the rapid deployment riot unit.//
	<<else>>

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

	<<if $SecExp.buildings.riotCenter.sentUnitCooldown == 0>>

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

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

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

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

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

<</if>>

<<if $SecExp.buildings.riotCenter.brainImplant < 106>>
	<<if $SecExp.buildings.riotCenter.brainImplantProject == 0>>
		<<link "Start secretly installing brain implants in your citizens and resident slaves" "riotControlCenter">>
			<<set $SecExp.buildings.riotCenter.brainImplantProject = 1>>
			<<set $SecExp.buildings.riotCenter.brainImplant = 0>>
		<</link>>

//Will take weeks of work and will cost <<print cashFormat(5000)>> each week, but once finished rebellions will progress a lot slower.//
	<<elseif $SecExp.buildings.riotCenter.brainImplantProject < 5>>
		<<set _costBIP = Math.trunc(50000 * $upgradeMultiplierArcology * $SecExp.buildings.riotCenter.brainImplantProject*$HackingSkillMultiplier)>>
		<<link "Invest more resources in the brain implant project" "riotControlCenter">>
			<<run cashX(-_costBIP, "capEx")>>
			<<set $SecExp.buildings.riotCenter.brainImplantProject++>>
			<<= IncreasePCSkills('hacking', 1)>>
		<</link>>

Invest more resources into the project to increase its speed.

//One-time cost of <<print cashFormat(_costBIP)>> with an additional <<print cashFormat(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 $SecExp.buildings.riotCenter.brainImplant != -1>>

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

<<if $SecExp.buildings.riotCenter.advancedRiotEquip == 0>>
	<<link "Develop advanced anti-riot equipment" "riotControlCenter">>
		<<set $SecExp.buildings.riotCenter.advancedRiotEquip = 1>>
		<<run cashX(forceNeg(30000 * $upgradeMultiplierTrade), "capEx")>>
	<</link>>

//Costs <<print cashFormat(30000 * $upgradeMultiplierTrade)>>. 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 $SecExp.buildings.riotCenter.fort.reactor == 0>>
	<<link "Reinforce the reactor complex" "riotControlCenter">>
		<<set $SecExp.buildings.riotCenter.fort.reactor = 1>>
		<<run cashX(forceNeg(10000 * $upgradeMultiplierArcology), "capEx")>>
	<</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 $SecExp.buildings.riotCenter.fort.waterway == 0>>
	<<link "Reinforce the waterways" "riotControlCenter">>
		<<set $SecExp.buildings.riotCenter.fort.waterway = 1>>
		<<run cashX(forceNeg(10000 * $upgradeMultiplierArcology), "capEx")>>
	<</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 $SecExp.buildings.riotCenter.fort.assistant == 0>>
	<<link "Reinforce the assistant CPU core" "riotControlCenter">>
		<<set $SecExp.buildings.riotCenter.fort.assistant = 1>>
		<<run cashX(forceNeg(10000 * $upgradeMultiplierArcology), "capEx")>>
	<</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>>

<<if $SF.Toggle && $SF.Active >= 1>>

	<<if $SecExp.edicts.SFSupportLevel >= 4 && $SF.Squad.Armoury >= 8 && !$SecExp.rebellions.sfArmor>>
		<<set _costSFA = Math.ceil(500000*App.SF.env()*(1.15+($SF.Squad.Armoury/10)))>>
		 <<link "Give the riot unit access to the combat armor suits of $SF.Lower.""riotControlCenter">>
			<<set $SecExp.rebellions.sfArmor = 1>>
			<<run cashX(-_costSFA, "capEx")>>
		<</link>>
		//Costs <<print cashFormat(_costSFA)>>
	<<else>>
		You have given the riot unit access to the combat armor suits of $SF.Lower.
	<</if>>
<</if>>


code:
:: secBarracks [nobr jump-to-safe jump-from-safe]

<<set $nextButton = "Back", $nextLink = "Main">>

The Barracks

__Upgrades__

While this a sore sight for many citizens of $arcologies[0].name, the barracks stand proud before you.
<<if $SecExp.buildings.barracks.size == 0>>
	The building is relatively small and able to house a limited number of units.
<<elseif $SecExp.buildings.barracks.size == 1>>
	The building has been expanded and can now house more units comfortably.
<<elseif $SecExp.buildings.barracks.size == 2>>
	The building has been further expanded and can now house a high number of units.
<<elseif $SecExp.buildings.barracks.size == 3>>
	The building has been greatly expanded and can now house a sizable military.
<<elseif $SecExp.buildings.barracks.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 $SecExp.buildings.barracks.luxury == 0>>
	The barracks are a spartan building, with little to make the day to day lives of your soldiers pleasant.
<<elseif $SecExp.buildings.barracks.luxury == 1>>
	The barracks have been made more comfortable by installing high tech furniture.
<<elseif $SecExp.buildings.barracks.luxury == 2>>
	The barracks have been made more comfortable by installing high tech furniture and advanced kitchen facilities.
<<elseif $SecExp.buildings.barracks.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 $SecExp.buildings.barracks.training == 0>>
	The building lacks the space and the equipment to train your units.
<<elseif $SecExp.buildings.barracks.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 $SecExp.buildings.barracks.loyaltyMod == 0>>
	The barracks lack an indoctrination facility.
<<elseif $SecExp.buildings.barracks.loyaltyMod == 1>>
	The barracks have been fitted with an indoctrination facility.
<<else>>
	The barracks have been fitted with an advanced indoctrination facility.
<</if>>

<<if $SecExp.buildings.barracks.size < 5>>
	<<link "Increase the size of the barracks" "secBarracks">>
		<<run cashX(forceNeg(Math.trunc((5000 * ($SecExp.buildings.barracks.size + 1))*$upgradeMultiplierArcology)), "capEx")>>
		<<set $SecExp.buildings.barracks.size += 1>>
	<</link>>

//Costs <<print cashFormat((5000 * ($SecExp.buildings.barracks.size + 1))*$upgradeMultiplierArcology)>> and will increase the maximum number of units by 2.//
<<else>>
	<<if $SF.Toggle && $SF.Active >= 1>>
		<<set _capSF = capFirstChar($SF.Lower || "the special force")>>
		<<set _reasons = [], _cost = Math.ceil((750000*(1.15+(App.SF.upgrades.total()/1000))*(1.15+($SF.Squad.Firebase/10)))*App.SF.env())>>

 _capSF might be able to provide assistance.
		<<if $SF.Squad.Firebase > 5 && $SecExp.edicts.SFSupportLevel >= 4 && App.SecExp.battle.maxUnits() === 18 && App.SecExp.battle.deploySpeed() <= 10>>

_capSF [[will provide the security force their own section in the Firebase.|secBarracks][$SecExp.sectionInFirebase = 1, cashX(-_cost, "specialForcesCap")]]
			@@.red;<<print cashFormat(_cost)>>@@
		<</if>>
		<<if $SF.Squad.Firebase < 5>>
			<<set _reasons.push('Firebase would likely require additional expansion(s)')>>
		<</if>>
		<<if $SecExp.edicts.SFSupportLevel < 4>>
			<<set _reasons.push('support contract needs more clauses')>>
		<</if>>
		<<set _reasons.join(',')>>
		<<if _reasons.length > 0>>
The Colonel says that the; _reasons.<</if>>
	<<else>>
		You've expanded the barracks to their maximum.
	<</if>>
<</if>>

<<if $SecExp.buildings.barracks.luxury == 0>>
	<<link "Increase the quality of life of your soldiers by installing high tech furniture and appliances." "secBarracks">>
		<<set $SecExp.buildings.barracks.luxury += 1>>
		<<run cashX(forceNeg(Math.trunc(5000*$upgradeMultiplierTrade)), "capEx")>>
	<</link>>

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierTrade))>> and will provide a 5% bonus to morale.//
<<elseif $SecExp.buildings.barracks.luxury == 1>>
	<<link "Further increase the quality of life of your soldiers by installing advanced kitchen equipment and hiring skilled chefs." "secBarracks">>
		<<set $SecExp.buildings.barracks.luxury += 1>>
		<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierTrade)), "capEx")>>
	<</link>>

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierTrade))>> and will provide a 5% bonus to morale, for a total of +10%.//
<<elseif $SecExp.buildings.barracks.luxury == 2>>
	<<link "Further increase the quality of life of your soldiers by providing high speed, free access to digital media" "secBarracks">>
		<<set $SecExp.buildings.barracks.luxury += 1>>
		<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierTrade)), "capEx")>>
	<</link>>

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierTrade))>> and will provide a 5% bonus to morale, for a total of +15%.//
<<elseif $SecExp.buildings.barracks.luxury == 3>>
	<<link "Further increase the quality of life of your soldiers by adding and staffing an exclusive brothel to the structure" "secBarracks">>
		<<set $SecExp.buildings.barracks.luxury += 1>>
		<<run cashX(forceNeg(Math.trunc(15000*$upgradeMultiplierArcology)), "capEx")>>
	<</link>>

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology))>> 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 $SecExp.buildings.barracks.training == 0>>
	<<link "Add a training facility to the barracks" "secBarracks">>
		<<set $SecExp.buildings.barracks.training += 1>>
		<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology)), "capEx")>>
	<</link>>

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology))>> and will allow units to accumulate some experience each week.//
<<elseif $SecExp.buildings.barracks.training == 1>>
	<<link "Improve the training facility with modern equipment and skilled personnel" "secBarracks">>
		<<set $SecExp.buildings.barracks.training += 1>>
		<<run cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierTrade)), "capEx")>>
	<</link>>

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

<<if $SecExp.buildings.barracks.loyaltyMod == 0>>
	<<link "Add an indoctrination facility to the barracks" "secBarracks">>
		<<set $SecExp.buildings.barracks.loyaltyMod += 1>>
		<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology)), "capEx")>>
	<</link>>

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology))>> and will slowly raise loyalty of all units//
<<elseif $SecExp.buildings.barracks.loyaltyMod == 1>>
	<<link "Improve the indoctrination facility with advanced equipment and skilled personnel" "secBarracks">>
		<<set $SecExp.buildings.barracks.loyaltyMod += 1>>
		<<run cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierTrade)), "capEx")>>
	<</link>>

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

__Units__

Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> (<<print num($secBots.maxTroops+(50*App.SecExp.battle.maxUnits()))>> troops), <<print App.SecExp.battle.activeUnits()>> (<<print num($secBots.troops+App.SecExp.Manpower.employedOverall)>> troops) are active and <<print (2 * App.SecExp.battle.deploySpeed())>> units can be deployed. <<if $SecExp.buildings.barracks.luxury > 0>>The barracks provides <<print $SecExp.buildings.barracks.luxury * 5>>% bonus morale when battle occurs.<</if>> <<if $SecExp.buildings.barracks.training > 0>>The training facility will increase the effectiveness of your units with time.<</if>>

<<set _options = new App.UI.OptionsGroup()>>
<<run _options.addOption("Unit descriptions are", "unitDescriptions", $SecExp.settings)
.addValue("Abbreviated", 1).on().addValue("Summarized", 0).off()>>
<<includeDOM _options.render()>>
<<if App.SecExp.battle.activeUnits() >= App.SecExp.battle.maxUnits()>>

You have reached the maximum number of units. You'll have to disband one or enlarge the barracks before forming a new unit.
<</if>>
<<replenishAllUnits>>

<<if $arcologyUpgrade.drones === 0>>
	You have not yet installed a drone security system in your arcology, you will not be able to form a unit of drones.
<</if>>
<<if $SecExp.edicts.defense.militia === 0>>

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

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

	<<if $arcologyUpgrade.drones == 1>>
		<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Bots')" id="tab Bots">Security Drones</button>
	<</if>>
	<<if $SecExp.edicts.defense.militia >= 1>>
		<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Militia')" id="tab Militia">Militia: ($militiaUnits.length)</button>
	<</if>>
	<<if $mercenaries >= 1>>
		<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Mercs')" id="tab Mercs">Mercenaries: ($mercUnits.length)</button>
	<</if>>
	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Slaves')" id="tab Slaves">Slaves: ($slaveUnits.length)</button>

<<run App.UI.tabBar.handlePreSelectedTab($tabChoice.secBarracks)>>

		<<set _secBotsCost = 500, _secBotsUpgradeCost = 250>>
		<<= App.SecExp.getUnit("Bots").describe()>>

		<<if $secBots.active == 1>>
			<<if $secBots.maxTroops > $secBots.troops>>
				<<link "Replenish the unit" "secBarracks">>
					<<run cashX(forceNeg(($secBots.maxTroops - $secBots.troops) * _secBotsCost), "securityExpansion")>>
					<<set $secBots.troops = $secBots.maxTroops>>
				<</link>>
			<</if>>
			<<if $secBots.maxTroops < 80>>

				<<link "Improve the digital control matrix" "secBarracks">>
					<<set $secBots.maxTroops += 10>>
					<<run cashX(-5000, "securityExpansion")>>
				<</link>>
				Invest in the development of more refined controls for your drones to increase the maximum number of drones in the unit.

//Costs <<print cashFormat(5000)>> per upgrade and each will increase the max by 10//
			<<elseif $SF.Toggle && $SF.Active >= 1 && $secBots.maxTroops < 100 && $SecExp.edicts.SFSupportLevel >= 1>>

				<<link "Refine the drone network with $SF.Lower assistance" "secBarracks">>
				<<set $secBots.maxTroops += 10>>
					<<run cashX(forceNeg(5000 + 10 * _secBotsUpgradeCost * $secBots.equip), "securityExpansion")>>
				<</link>>
				Utilize the technological developments made by $SF.Lower to further improve the control matrix of the security drones.

//Costs <<print cashFormat(5000 + 10 * _secBotsUpgradeCost * $secBots.equip)>> and will increase the max by 10//
			<<elseif $SF.Toggle && $SF.Active >= 1 && $SecExp.edicts.SFSupportLevel === 0>>
				There's little left to improve in the matrix. However support from $SF.Lower might give some more room from improvement, if an assistance contract is signed.
			<<else>>
				There's little left to improve in the matrix. Your control systems are at top capacity and won't be able to handle a bigger drone unit.
			<</if>>
			<<if $secBots.equip < 3>>

				<<link "Improve drone weaponry and armor" "secBarracks">>
					<<set $secBots.equip += 1>>
					<<run cashX(forceNeg((_secBotsUpgradeCost * $secBots.maxTroops) + 1000), "securityExpansion")>>
				<</link>>
				Invest in better equipment for your drones to increase their battle effectiveness.

//Costs <<print cashFormat((_secBotsUpgradeCost * $secBots.maxTroops) + 1000)>> and will increase attack and defense value of the unit by 15% for every upgrade.//
			<<else>>

Your drones are equipped with top tier weaponry and armor.
			<</if>>
			<<if $SecExp.settings.showStats == 1>>

<<= App.SecExp.getUnit("Bots").printStats()>>
			<</if>>
		<<else>>
			<<link "Rebuild the unit" "secBarracks">>
				<<run cashX(forceNeg(($secBots.maxTroops - $secBots.troops) * _secBotsCost), "securityExpansion")>>
				<<set $secBots.troops = $secBots.maxTroops>>
				<<set $secBots.active = 1>>
			<</link>>
		<</if>>

		You are free to organize your menial slaves into fighting units. Currently you have <<print num($menials)>> slaves available, while <<print num(App.SecExp.Manpower.employedSlave)>> are already employed as soldiers. During all your battles you lost a total of <<print num($slavesTotalCasualties)>>.

Default unit name: <<textbox "$SecExp.defaultNames.slaves" $SecExp.defaultNames.slaves "secBarracks">> |
		<<if $menials > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>>
			<<link "Form a new unit" "secBarracks">>
				<<set $slaveUnits.push(App.SecExp.generateUnit("slaves"))>>
			<</link>> |
		<</if>>
		<<includeDOM App.SecExp.bulkUpgradeUnit($slaveUnits)>>

		<<set _popCap = menialPopCap()>>
		<<set _menialPrice = menialSlaveCost()>>
		<<set _bulkMax = _popCap.value-$menials-$fuckdolls-$menialBioreactors>>
		<<if $cash > _menialPrice>>
			<<if _bulkMax > 0>>

				[[Buy|secBarracks][$menials+=1,$menialSupplyFactor-=1,cashX(forceNeg(_menialPrice), "menialTransfer")]]
				<<if $cash > (menialSlaveCost(10))*10>>
					[[(x10)|secBarracks][$menials+=10,$menialSupplyFactor-=10,cashX(forceNeg((menialSlaveCost(10))*10), "menialTransfer")]]
				<</if>>
				<<if $cash > (menialSlaveCost(100))*100>>
					[[(x100)|secBarracks][$menials+=100,$menialSupplyFactor-=100,cashX(forceNeg((menialSlaveCost(100))*100), "menialTransfer")]]
				<</if>>
				<<if $cash > (_menialPrice+1)*2>>
					<<set _menialBulkPremium = Math.trunc(1 + Math.clamp($cash/_menialPrice,0,_bulkMax)/400)>>
					[[(max)|secBarracks][$menials+=Math.trunc(Math.clamp($cash/(_menialPrice+_menialBulkPremium),0,_bulkMax)),$menialSupplyFactor-=Math.trunc(Math.clamp($cash/(_menialPrice+_menialBulkPremium),0,_bulkMax)),cashX(forceNeg(Math.trunc(Math.clamp($cash/(_menialPrice+_menialBulkPremium),0,_bulkMax)*(_menialPrice+_menialBulkPremium))), "menialTransfer")]]
				<</if>>
				//Bulk transactions may require offering a premium.//
			<</if>>
		<</if>>

		<<set _sL = $slaveUnits.length>>
		<<for _i = 0; _i < _sL; _i++>>
			<<capture _i>>
			<<= App.SecExp.getUnit("Slaves", _i).describe()>>

			Rename unit <<textbox "$slaveUnits[_i].platoonName" $slaveUnits[_i].platoonName "secBarracks">>
			 | <<link "Disband the unit" "secBarracks">>
				<<set $menials += $slaveUnits[_i].troops>>
				<<set $slaveUnits.deleteAt(_i)>>
			<</link>>
			<<if $slaveUnits[_i].active == 1>>
				<<if $slaveUnits[_i].troops < $slaveUnits[_i].maxTroops && $menials > 0>>
					|
					<<link "Replenish unit" "secBarracks">>
						<<if $menials >= $slaveUnits[_i].maxTroops - $slaveUnits[_i].troops>>
							<<set $menials -= $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 _expLoss = $menials / $slaveUnits[_i].troops>>
							<<set $slaveUnits[_i].training -= $slaveUnits[_i].training * _expLoss>>
							<<set $slaveUnits[_i].troops += $menials>>
							<<set $menials = 0>>
						<</if>>
					<</link>>
				<</if>>
			<<else>>
				<<if $menials > 0>>
					|
					<<link "Reform the unit" "secBarracks">>
						<<if $menials >= $slaveUnits[_i].maxTroops>>
							<<set $menials -= $slaveUnits[_i].maxTroops>>
							<<set $slaveUnits[_i].troops = $slaveUnits[_i].maxTroops>>
							<<set $slaveUnits[_i].training = 0>>
						<<else>>
							<<set $slaveUnits[_i].troops += $menials>>
							<<set $menials = 0>>
							<<set $slaveUnits[_i].training = 0>>
						<</if>>
						<<set $slaveUnits[_i].active = 1>>
					<</link>>
				<</if>>
			<</if>>
			| <<includeDOM App.SecExp.bulkUpgradeUnit($slaveUnits[_i])>>
			<<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("Slaves", _i).printStats()>> <</if>>
			<<includeDOM App.SecExp.humanUnitUpgradeList($slaveUnits[_i])>>
			<</capture>>
		<</for>>

		You founded the $arcologies[0].name free militia. You are now able to organize your citizens into fighting units.
		<<if $SecExp.edicts.defense.militia === 2>>
			The militia is composed entirely of volunteers, your manpower is <<= num(App.SecExp.militiaCap()*100)>>% of the citizens population of your arcology.
		<<elseif $SecExp.edicts.defense.militia === 3>>
			With the establishment of conscription, your available manpower has increased to now <<= num(App.SecExp.militiaCap()*100)>>% of the arcology's citizens population.
		<<elseif $SecExp.edicts.defense.militia === 4>>
			By establishing obligatory military service to obtain citizenship you have enlarged your manpower pool to be <<= num(App.SecExp.militiaCap()*100)>>% of the arcology's citizens population.
		<<elseif $SecExp.edicts.defense.militia === 5>>
			With the adoption of a militarized society, your available manpower has swelled to be <<= num(App.SecExp.militiaCap()*100)>>% of the arcology's citizens population.
		<</if>>
		Your current total manpower is <<print num(App.SecExp.Manpower.totalMilitia)>>, of which <<print num(App.SecExp.Manpower.employedMilitia)>> is in active duty. You lost in total <<print num($militiaTotalCasualties)>> citizens, leaving you with <<print num($militiaFreeManpower)>> available citizens.

Default unit name: <<textbox "$SecExp.defaultNames.militia" $SecExp.defaultNames.militia "secBarracks">> |
		<<if $militiaFreeManpower > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>>
			<<link "Form a new unit" "secBarracks">>
				<<set $militiaUnits.push(App.SecExp.generateUnit("militia"))>>
			<</link>> |
		<</if>>
		<<includeDOM App.SecExp.bulkUpgradeUnit($militiaUnits)>>

		<<set _mL = $militiaUnits.length>>
		<<for _i = 0; _i < _mL; _i++>>
			<<capture _i>>
			<<= App.SecExp.getUnit("Militia", _i).describe()>>

			Rename unit <<textbox "$militiaUnits[_i].platoonName" $militiaUnits[_i].platoonName "secBarracks">>
			 | <<link "Disband the unit" "secBarracks">>
				<<set $militiaFreeManpower += $militiaUnits[_i].troops>>
				<<set $militiaUnits.deleteAt(_i)>>
			<</link>>
			<<if $militiaUnits[_i].active == 1>>
				<<if $militiaUnits[_i].troops < $militiaUnits[_i].maxTroops && $militiaFreeManpower > 0>>
					|
					<<link "Replenish unit" "secBarracks">>
						<<if $militiaFreeManpower >= $militiaUnits[_i].maxTroops - $militiaUnits[_i].troops>>
							<<set $militiaFreeManpower -= $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 _expLoss = $militiaFreeManpower / $militiaUnits[_i].troops>>
							<<set $militiaUnits[_i].training -= $militiaUnits[_i].training * _expLoss>>
							<<set $militiaUnits[_i].troops += $militiaFreeManpower>>
							<<set $militiaFreeManpower = 0>>
						<</if>>
					<</link>>
				<</if>>
			<<else>>
				<<if $militiaFreeManpower > 0>>
					|
					<<link "Reform the unit" "secBarracks">>
						<<if $militiaFreeManpower >= $militiaUnits[_i].maxTroops>>
							<<set $militiaFreeManpower -= $militiaUnits[_i].maxTroops>>
							<<set $militiaUnits[_i].troops = $militiaUnits[_i].maxTroops>>
							<<set $militiaUnits[_i].training = 0>>
						<<else>>
							<<set $militiaUnits[_i].troops += $militiaFreeManpower>>
							<<set $militiaFreeManpower = 0>>
							<<set $militiaUnits[_i].training = 0>>
						<</if>>
						<<set $militiaUnits[_i].active = 1>>
					<</link>>
				<</if>>
			<</if>>
			| <<includeDOM App.SecExp.bulkUpgradeUnit($militiaUnits[_i])>>
			<<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("Militia", _i).printStats()>> <</if>>
			<<includeDOM App.SecExp.humanUnitUpgradeList($militiaUnits[_i])>>
			<</capture>>
		<</for>>

		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 num(App.SecExp.Manpower.totalMerc)>> mercenaries in your arcology, of which <<print num(App.SecExp.Manpower.employedMerc)>> actively employed and <<print num($mercFreeManpower)>> not yet under contract. In total <<print num($mercTotalCasualties)>> mercenaries have died defending your arcology.

Default unit name: <<textbox "$SecExp.defaultNames.mercs" $SecExp.defaultNames.mercs "secBarracks">> |
		<<if $mercFreeManpower > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>>
			<<link "Form a new unit" "secBarracks">>
				<<set $mercUnits.push(App.SecExp.generateUnit("mercs"))>>
			<</link>> |
		<</if>>
		<<includeDOM App.SecExp.bulkUpgradeUnit($mercUnits)>>

		<<set _meL = $mercUnits.length>>
		<<for _i = 0; _i < _meL; _i++>>
			<<capture _i>>
			<<= App.SecExp.getUnit("Mercs", _i).describe()>>

			Rename unit <<textbox "$mercUnits[_i].platoonName" $mercUnits[_i].platoonName "secBarracks">>
			 | <<link "Disband the unit" "secBarracks">>
				<<set $mercFreeManpower += $mercUnits[_i].troops>>
				<<set $mercUnits.deleteAt(_i)>>
			<</link>>
			<<if $mercUnits[_i].active == 1>>
				<<if $mercUnits[_i].troops < $mercUnits[_i].maxTroops && $mercFreeManpower > 0>>
					|
					<<link "Replenish unit" "secBarracks">>
						<<if $mercFreeManpower >= $mercUnits[_i].maxTroops - $mercUnits[_i].troops>>
							<<set $mercFreeManpower -= $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 _expLoss = $mercFreeManpower / $mercUnits[_i].troops>>
							<<set $mercUnits[_i].training -= $mercUnits[_i].training * _expLoss>>
							<<set $mercUnits[_i].troops += $mercFreeManpower>>
							<<set $mercFreeManpower = 0>>
						<</if>>
					<</link>>
				<</if>>
			<<else>>
				<<if $mercFreeManpower > 0>>
					|
					<<link "Reform the unit" "secBarracks">>
						<<if $mercFreeManpower >= $mercUnits[_i].maxTroops>>
							<<set $mercFreeManpower -= $mercUnits[_i].maxTroops>>
							<<set $mercUnits[_i].troops = $mercUnits[_i].maxTroops>>
							<<set $mercUnits[_i].training = 0>>
						<<else>>
							<<set $mercUnits[_i].troops += $mercFreeManpower>>
							<<set $mercFreeManpower = 0>>
							<<set $mercUnits[_i].training = 0>>
						<</if>>
						<<set $mercUnits[_i].active = 1>>
					<</link>>
				<</if>>
			<</if>>
			| <<includeDOM App.SecExp.bulkUpgradeUnit($mercUnits[_i])>>
			<<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("Mercs", _i).printStats()>> <</if>>
			<<includeDOM App.SecExp.humanUnitUpgradeList($mercUnits[_i])>>
			<</capture>>
		<</for>>


code:
:: securityHQ [nobr jump-to-safe jump-from-safe]

<<set $nextButton = "Back", $nextLink = "Main", _HistoryDiscount = 1>>
<<if $career == "mercenary" || $career == "gang" || $career == "slaver">>
	<<set _HistoryDiscount = 0.5>>
<</if>>

Security Headquarters

The security headquarters stand in front of you. Innumerable screens flood with light the great central room. <<if $SecExp.buildings.secHub.menials > 0>>Some slaves see you enter and interrupt their work to greet you.<</if>> From here you can build a safe and prosperous arcology.
<<if $SecExp.core.authority < 10000 || $SecExp.core.authority < 12000>>

You lack the authority to access more advanced upgrades.
<</if>>

You have  <<print num($SecExp.buildings.secHub.menials)>>  slaves working in the HQ. <<= App.SecExp.Check.reqMenials()>> are required and you have  <<print num($menials)>>  free menial slaves.
<<if $SecExp.buildings.secHub.menials < App.SecExp.Check.reqMenials()>>

You do not have enough slaves here. You will not receive the full benefit of the installed upgrades.
<<else>>

You have enough slaves to man all security systems.
<</if>>
<<set _popCap = menialPopCap()>>
<<set _menialPrice = menialSlaveCost()>>
<<set _bulkMax = _popCap.value-$menials-$fuckdolls-$menialBioreactors>>
<<if $cash > _menialPrice>>
	<<if _bulkMax > 0 || $menials+$fuckdolls+$menialBioreactors == 0>>

[[Buy|securityHQ][$menials++,$menialSupplyFactor -= 1, cashX(-_menialPrice, "menialTransfer")]]
		<<if $cash > (menialSlaveCost(10))*10>>
			[[(x10)|securityHQ][$menials += 10,$menialSupplyFactor -= 10, cashX(-(menialSlaveCost(10)*10), "menialTransfer")]]
		<</if>>
		<<if $cash > (menialSlaveCost(100))*100>>
			[[(x100)|securityHQ][$menials += 100,$menialSupplyFactor -= 100, cashX(-(menialSlaveCost(100)*100), "menialTransfer")]]
		<</if>>
		<<if $cash > (_menialPrice+1)*2>>
			<<set _menialBulkPremium = Math.trunc(1 + Math.clamp($cash/_menialPrice,0,_bulkMax)/400)>>
			<<set _maxMenials = Math.clamp($cash/(_menialPrice+_menialBulkPremium),0,_bulkMax)>>
			<<set _finalMaxCost = Math.trunc(_maxMenials*(_menialPrice+_menialBulkPremium))>>
			[[(max)|securityHQ][$menials += Math.trunc(_maxMenials), $menialSupplyFactor -= Math.trunc(_maxMenials), cashX(-_finalMaxCost, "menialTransfer")]]
		<</if>>
		//Bulk transactions may require offering a premium. The remaining slaves will be more efficient in dealing with crime.//
	<</if>>
<</if>>

<<set _optionsList = [1, 5, 10, 100, 500, 1000]>>
<<if $menials > 0>>

Transfer in:
	<<for _i = 0; _i < _optionsList.length; _i++>>
	<<capture _optionsList[_i]>>
		<<if $menials >= _optionsList[_i]>>
			<<if _optionsList[_i] > 1>> | <</if>>
			<<link _optionsList[_i]>>
				<<set $menials -= _optionsList[_i]>>
				<<set $SecExp.buildings.secHub.menials += _optionsList[_i]>>
				<<replace "#secHel">><<print $SecExp.buildings.secHub.menials>><</replace>>
				<<replace "#hel">><<print $menials>><</replace>>
				<<if $menials < _optionsList[_i] || $SecExp.buildings.secHub.menials >= App.SecExp.Check.reqMenials() || $SecExp.buildings.secHub.menials == _i>>
					<<goto "securityHQ">>
				<</if>>
			<</link>>
		<</if>>
	<</capture>>
	<</for>>
<</if>>
<<if $SecExp.buildings.secHub.menials > 0>>

Transfer out
	<<for _i = 0; _i < _optionsList.length; _i++>>
	<<capture _optionsList[_i]>>
		<<if $SecExp.buildings.secHub.menials >= _optionsList[_i]>>
			<<if _optionsList[_i] > 1>> | <</if>>
			<<link _optionsList[_i]>>
				<<set $menials += _optionsList[_i]>>
				<<set $SecExp.buildings.secHub.menials -= _optionsList[_i]>>
				<<replace "#secHel">><<print $SecExp.buildings.secHub.menials>><</replace>>
				<<replace "#hel">><<print $menials>><</replace>>
				<<if $SecExp.buildings.secHub.menials < _optionsList[_i] || $SecExp.buildings.secHub.menials < App.SecExp.Check.reqMenials()>>
					<<goto "securityHQ">>
				<</if>>
			<</link>>
		<</if>>
	<</capture>>
	<</for>>
<</if>>

<<if $SecExp.buildings.secHub.menials != App.SecExp.Check.reqMenials()>>

<<link "Match the requirement" "securityHQ">>
		<<if $menials >= App.SecExp.Check.reqMenials() - $SecExp.buildings.secHub.menials>>
			<<set $menials -= App.SecExp.Check.reqMenials() - $SecExp.buildings.secHub.menials>>
			<<set $SecExp.buildings.secHub.menials = App.SecExp.Check.reqMenials()>>
		<<elseif App.SecExp.Check.reqMenials() < $SecExp.buildings.secHub.menials>>
			<<set $menials += $SecExp.buildings.secHub.menials - App.SecExp.Check.reqMenials()>>
			<<set $SecExp.buildings.secHub.menials = App.SecExp.Check.reqMenials()>>
		<<else>>
			<<set $SecExp.buildings.secHub.menials += $menials>>
			<<set $menials = 0>>
		<</if>>
	<</link>>
<</if>>

Your security level (@@.deepskyblue;$SecExp.core.security@@) /* security level and upgrades */
<<if $SecExp.core.security <= 20>>
	is dangerously low.
<<elseif $SecExp.core.security <= 40>>
	is low.
<<elseif $SecExp.core.security <= 60>>
	is decent.
<<elseif $SecExp.core.security <= 80>>
	is good.
<<else>>
	is great.
<</if>>
Considering the current upgrades the resting level for security is <<print App.SecExp.Check.reqMenials()>>, while the effective maximum level is <<print Math.trunc(App.SecExp.Check.reqMenials() * (Math.clamp($SecExp.buildings.secHub.menials,0,App.SecExp.Check.reqMenials()) / App.SecExp.Check.reqMenials()))>>.

Your crime level (@@.orangered;$SecExp.core.crimeLow@@) /* crime level and upgrades */
<<if $SecExp.core.crimeLow <= 20>>
	is very low.
<<elseif $SecExp.core.crimeLow <= 40>>
	is low.
<<elseif $SecExp.core.crimeLow <= 60>>
	is average.
<<elseif $SecExp.core.crimeLow <= 80>>
	is high.
<<else>>
	is extremely high.
<</if>>
Considering the current upgrades the maximum level of crime is <<print App.SecExp.Check.crimeCap()>>, while the effective maximum level is <<print Math.trunc(Math.clamp(App.SecExp.Check.crimeCap() + (App.SecExp.Check.crimeCap() - App.SecExp.Check.crimeCap() * ($SecExp.buildings.secHub.menials / App.SecExp.Check.reqMenials())),0,100))>>.

<<if App.SecExp.battle.recon() == 0>>

Your reconnaissance capabilities are very limited. Very little information will be available if the arcology is attacked.
<<elseif App.SecExp.battle.recon() == 1>>

You have limited reconnaissance capabilities. You'll have limited intel available in case of an attack.
<<elseif App.SecExp.battle.recon() == 2>>

You have good reconnaissance capabilities. Good, reliable intel will be available if the arcology is attacked.
<<else>>

You have great reconnaissance capabilities. You'll have very accurate information on the enemy if the arcology is attacked.
<</if>>

<<if App.SecExp.battle.deploySpeed() == 1>>

You have low readiness. You won't be able to mobilize many troops in time in case of an attack.
<<elseif App.SecExp.battle.deploySpeed() == 2>>

You have decent readiness. You will be able to muster up sufficient forces to handle an average attack.
<<elseif App.SecExp.battle.deploySpeed() == 3>>

You have good readiness. You will be able to mobilize a lot of troops in case of an attack.
<<else>>

You have great readiness. You can mobilize a small army in very little time.
<</if>>

<<if $SecExp.core.authority > 12000>>

__Cold Data Storage Facility__:
	<<if App.SecExp.Check.reqMenials() <= 10>>

Personnel cannot be further reduced.
	<<elseif $SecExp.buildings.secHub.coldstorage > 6>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of three years.
	<<elseif $SecExp.buildings.secHub.coldstorage == 6 && $SecExp.core.authority >= 19500 && App.SecExp.Check.reqMenials() > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of two years.

[[Expand the cold storage facility to increase data retention to three years|securityHQ][cashX(-Math.trunc(2400000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.coldstorage++, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(2400000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will lower the amount of required slaves by a further 10, but will increase upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<elseif $SecExp.buildings.secHub.coldstorage == 5 && $SecExp.core.authority >= 19500 && App.SecExp.Check.reqMenials() > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of one year.

[[Expand the cold storage facility to increase data retention to two years|securityHQ][cashX(-Math.trunc(1200000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.coldstorage++, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(1200000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will lower the amount of required slaves by a further 10, but will increase upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<elseif $SecExp.buildings.secHub.coldstorage == 4 && $SecExp.core.authority >= 19500 && App.SecExp.Check.reqMenials() > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of nine months.

[[Expand the cold storage facility to increase data retention to one year|securityHQ][cashX(-Math.trunc(900000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.coldstorage++, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(900000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will lower the amount of required slaves by a further 10, but will increase upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<elseif $SecExp.buildings.secHub.coldstorage == 3 && $SecExp.core.authority > 18000 && App.SecExp.Check.reqMenials() > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of six months.

[[Expand the cold storage facility to increase data retention to nine months|securityHQ][cashX(-Math.trunc(600000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.coldstorage++, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(600000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will lower the amount of required slaves by a further 10, but will increase upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<elseif $SecExp.buildings.secHub.coldstorage == 2 && $SecExp.core.authority > 16000 && App.SecExp.Check.reqMenials() > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of three months.

[[Expand the cold storage facility to increase data retention to six months|securityHQ][cashX(-Math.trunc(300000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.coldstorage++, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(300000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will lower the amount of required slaves by a further 10, but will increase upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<elseif $SecExp.buildings.secHub.coldstorage == 1 && $SecExp.core.authority > 14000 && App.SecExp.Check.reqMenials() > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of one month.

[[Expand the cold storage facility to increase data retention to three months|securityHQ][cashX(-Math.trunc(100000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.coldstorage++, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(100000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will lower the amount of required slaves by a further 10, but will increase upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<elseif $SecExp.buildings.secHub.coldstorage == 0 && $SecExp.core.authority > 12000 && App.SecExp.Check.reqMenials() > 10>>
		[[Install a cold storage facility|securityHQ][cashX(-Math.trunc(50000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.coldstorage++, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(50000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will lower the amount of required slaves by 10, but will increase upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<</if>>
<</if>>

 <<run App.UI.tabBar.handlePreSelectedTab($tabChoice.securityHQ)>>

	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'SecurityCrime')" id="tab SecurityCrime">Security and crime</button>
	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'ReconReadiness')" id="tab ReconReadiness">Reconnaissance and readiness</button>

		Security

		<<if $SecExp.buildings.secHub.upgrades.security.nanoCams == 0>>
			[[Install a nano-camera system |securityHQ][cashX(-Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.security.nanoCams = 1]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will raise rest point of security by 10 points, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
		<<else>>
			You have installed all across the arcology closed circuit nano-cameras to keep the arcology under your watchful eye.
		<</if>>

		<<if $SecExp.buildings.secHub.upgrades.security.cyberBots == 0>>

[[Buy cybersecurity algorithms|securityHQ][cashX(-Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.security.cyberBots = 1]]

//Costs <<print cashFormat(Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will raise rest point of security by 10 points, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
		<<else>>

You have bought advanced cybersecurity algorithms that will defend your arcology against hack attempts or cyber frauds.
		<</if>>

		<<if $SecExp.core.authority > 10000>>
			<<if $SecExp.buildings.secHub.upgrades.security.eyeScan == 0>>

[[Install invisible eye scanners|securityHQ][cashX(-Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.security.eyeScan = 1]]

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will raise rest point of security by 15 points, but will require 10 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
			<<else>>

You have installed numerous hidden eye scanners that accurately register the movements of everyone inside the arcology.
			<</if>>
			<<if $SecExp.buildings.secHub.upgrades.security.cryptoAnalyzer == 0>>

[[Buy and install crypto analyzers|securityHQ][cashX(-Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.security.cryptoAnalyzer = 1]]

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will raise rest point of security by 15 points, but will require 10 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
			<<else>>

You have bought and employed sophisticated crypto analyzing software to accurately track and archive every financial movement or transaction made inside the walls of your arcology.
			<</if>>
		<</if>>

Crime

		<<if $SecExp.buildings.secHub.upgrades.crime.advForensic == 0>>
			[[Install advanced forensic equipment|securityHQ][cashX(-Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.crime.advForensic = 1, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will bring down the crime level cap by 10 points, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
		<<else>>
			You have installed advanced forensic equipment, able to extract every bit of precious information from any clue.
		<</if>>

		<<if $SecExp.buildings.secHub.upgrades.crime.autoArchive == 0>>

[[Install auto-curating archiver|securityHQ][cashX(-Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.crime.autoArchive = 1, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will bring down the crime level cap by 10 points, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
		<<else>>

You have installed auto-curating archiver software, which will update in real time your data archives with any new relevant information on criminals residing in your arcology.
		<</if>>

		<<if $SecExp.core.authority > 10000>>
			<<if $SecExp.buildings.secHub.upgrades.crime.autoTrial == 0>>

[[Install automated trials software|securityHQ][cashX(-Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.crime.autoTrial = 1, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will bring down the crime level cap by 15 points, but will require 10 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
			<<else>>

You have installed advanced legal algorithms that allows the handling of legal matters much quicker and much more accurately.
			<</if>>
			<<if $SecExp.buildings.secHub.upgrades.crime.worldProfiler == 0>>

[[Install worldwide profilers|securityHQ][cashX(-Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.crime.worldProfiler = 1, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will bring down the crime level cap by 15 points, but will require 10 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
			<<else>>

You have installed advanced profiler software, which will constantly scour every known data archive on the globe (legally or not) to gather as much information as possible on dangerous criminals.
			<</if>>
		<</if>>

	Reconnaissance

	<<if $SecExp.buildings.secHub.upgrades.intel.sensors == 0>>
		[[Install perimeter sensors|securityHQ][cashX(-Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.intel.sensors = 1, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will increase recon capabilities, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<else>>
		You have installed perimeter seismic sensors able to detect movement with high accuracy.
	<</if>>

	<<if $SecExp.buildings.secHub.upgrades.intel.signalIntercept == 0>>

[[Create signal interception hub|securityHQ][cashX(-Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.intel.signalIntercept = 1, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will increase recon capabilities, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<else>>

You have installed advanced signal interception equipment.
	<</if>>

	<<if $SecExp.core.authority > 10000>>
		<<if $SecExp.buildings.secHub.upgrades.intel.radar == 0>>

[[Install advanced radar equipment|securityHQ][cashX(-Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier), "capEx"), $SecExp.buildings.secHub.upgrades.intel.radar = 1, $PC.skill.hacking += 1]]

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount*$HackingSkillMultiplier))>>. Will increase recon capabilities, but will require 10 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
		<<else>>

You have installed sophisticated radar equipment.
		<</if>>
	<</if>>

Readiness

	<<if $SecExp.buildings.secHub.upgrades.readiness.pathways == 0>>
		[[Build specialized pathways in the arcology|securityHQ][cashX(-Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount), "capEx"), $SecExp.buildings.secHub.upgrades.readiness.pathways = 1]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 1, but will increase upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<else>>
		You have built specialized pathways inside the arcology to quickly move troops around the structure.
	<</if>>

	<<if $SecExp.buildings.secHub.upgrades.readiness.rapidVehicles == 0>>

[[Buy rapid armored transport vehicles|securityHQ][cashX(-Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount), "capEx"), $SecExp.buildings.secHub.upgrades.readiness.rapidVehicles = 1]]

//Costs <<print cashFormat(Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
	<<else>>

You have bought rapid armored transport vehicles able to bring your troops to battle much quicker than before.
	<</if>>

	<<if $SecExp.core.authority > 10000>>
		<<if $SecExp.buildings.secHub.upgrades.readiness.rapidPlatforms == 0>>

[[Build rapid deployment platforms|securityHQ][cashX(-Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount), "capEx"), $SecExp.buildings.secHub.upgrades.readiness.rapidPlatforms = 1]]

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
		<<else>>

You have built rapid deployment platforms able to equip and deploy units within very limited time windows.
		<</if>>
		<<if $SecExp.buildings.secHub.upgrades.readiness.earlyWarn == 0>>

[[Institute early warning systems|securityHQ][cashX(-Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount), "capEx"), $SecExp.buildings.secHub.upgrades.readiness.earlyWarn = 1]]

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 10 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.//
		<<else>>

You have created early warning systems that constantly analyze in real time data to determine the likeness of an attack.
		<</if>>
	<</if>>


code:
:: transportHub [nobr]

<<set $nextButton = "Back", $nextLink = "Main">>

The Transport Hub

You quickly reach the transport hub, where a constant stream of vehicles, people and goods greets you. Part of the structure is dedicated to air travel and the other is mainly occupied by the <<if $terrain != "oceanic" && $terrain != "marine">>rail station<<else>>docks<</if>>.

<<if $SecExp.edicts.limitImmigration == 1 || $policies.immigrationRep == -1>>
	Due to your strict policies concerning immigration, very few new citizens arrive in the transport hub.
<<elseif $SecExp.edicts.openBorders == 1 || $policies.immigrationCash == 1>>
	Due to your liberal policies concerning immigration, the transport hub is filled with a flow of new citizens.
<</if>>

<<if $SecExp.buildings.transportHub.airport == 1>>
	The arcology's airport is  relatively small and poorly equipped. It can handle some traffic, but nothing noteworthy.
<<elseif $SecExp.buildings.transportHub.airport == 2>>
	The arcology's airport is  relatively small, but well equipped. It can handle some traffic, but nothing too serious.
<<elseif $SecExp.buildings.transportHub.airport == 3>>
	The arcology's airport is  good sized and well equipped. It can handle a good amount of traffic.
<<elseif $SecExp.buildings.transportHub.airport == 4>>
	The arcology's airport is  good sized and very well equipped. It can handle a lot of traffic.
<<else>>
	The arcology's airport is  huge and very well equipped. It can handle an impressive amount of traffic.
<</if>>

<<if $terrain != "oceanic" && $terrain != "marine">>
	<<if $SecExp.buildings.transportHub.surfaceTransport == 1>>
		The railway network is old and limited. It can handle some traffic, but not sustain commercial activity.
	<<elseif $SecExp.buildings.transportHub.surfaceTransport == 2>>
		The railway network is modern and efficient, but limited in reach. It can handle some traffic, but not sustain commercial activity of any significant size.
	<<elseif $SecExp.buildings.transportHub.surfaceTransport == 3>>
		The railway network is modern, efficient and expansive. It can handle a significant amount of traffic.
	<<else>>
		The railway network is high tech and very far reaching. It can handle an enormous amount of traffic.
	<</if>>
<<else>>
	<<if $SecExp.buildings.transportHub.surfaceTransport == 1>>
		The docks are old and small. They can handle some traffic, but not sustain commercial activity.
	<<elseif $SecExp.buildings.transportHub.surfaceTransport == 2>>
		The docks are modern and efficient, but limited in size. They can handle some traffic, but not sustain commercial activity of significant size.
	<<elseif $SecExp.buildings.transportHub.surfaceTransport == 3>>
		The docks are modern, efficient and expansive. They can handle a significant amount of traffic.
	<<else>>
		The docks are huge in size and high tech. They can handle an enormous amount of traffic.
	<</if>>
<</if>>

<<if $SecExp.buildings.transportHub.security == 1>>
	The security of the hub is limited to a few cameras and the occasional guard.
<<elseif $SecExp.buildings.transportHub.security == 2>>
	The security of the hub is guaranteed by a powerful camera surveillance system.
<<elseif $SecExp.buildings.transportHub.security == 3>>
	The security of the hub is guaranteed by a powerful camera surveillance system and a rapid response team constantly patrolling the structure.
<<else>>
	The security of the hub is guaranteed by a powerful camera surveillance system, a rapid response team constantly patrolling the building and additional security drones making the rounds around the exterior.
<</if>>

<<if $SecExp.core.trade <= 20>>

Trade is @@.red;almost non-existent.@@ Outside the supplies for the arcology's domestic consumption little else crosses the territory of the free city.
<<elseif $SecExp.core.trade <= 40>>

Trade is @@.orange;low.@@ There's some but limited commercial activity crossing the territory of the free city.
<<elseif $SecExp.core.trade <= 60>>

Trade is at @@.yellow;positive levels.@@ There's a good amount commercial activity outside the supplies for the arcology's domestic consumption.
<<elseif $SecExp.core.trade <= 80>>

Trade is at @@.limegreen;high levels.@@ There's a lot of commercial activity outside the supplies for the arcology's domestic consumption.
<<else>>

Trade is at @@.green;extremely high levels.@@ There's a constant stream of commercial activity crossing the arcology.
<</if>>

<<if $SecExp.buildings.transportHub.airport == 1>>

 <<link "Modernize the airport" "transportHub">>
		<<run cashX(forceNeg(Math.trunc(5000*$upgradeMultiplierArcology)), "capEx")>>
		<<set $SecExp.buildings.transportHub.airport++>>
	<</link>> //Will cost <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology))>> and will increase trade, but will affect security//
<<elseif $SecExp.buildings.transportHub.airport == 2>>

 <<link "Enlarge the airport" "transportHub">>
		<<run cashX(forceNeg(Math.trunc(15000*$upgradeMultiplierArcology)), "capEx")>>
		<<set $SecExp.buildings.transportHub.airport++>>
	<</link>> //Will cost <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology))>> and will increase trade, but will affect security//
<<elseif $SecExp.buildings.transportHub.airport == 3>>

 <<link "Further modernize the airport" "transportHub">>
		<<run cashX(forceNeg(Math.trunc(45000*$upgradeMultiplierArcology)), "capEx")>>
		<<set $SecExp.buildings.transportHub.airport++>>
	<</link>> //Will cost <<print cashFormat(Math.trunc(45000*$upgradeMultiplierArcology))>> and will increase trade, but will affect security//
<<elseif $SecExp.buildings.transportHub.airport == 4>>

 <<link "Further enlarge the airport" "transportHub">>
		<<run cashX(forceNeg(Math.trunc(85000*$upgradeMultiplierArcology)), "capEx")>>
		<<set $SecExp.buildings.transportHub.airport++>>
	<</link>> //Will cost <<print cashFormat(Math.trunc(85000*$upgradeMultiplierArcology))>> and will increase trade, but will affect security//
<<else>>

The airport is fully upgraded.
<</if>>

<<if $terrain != "oceanic" && $terrain != "marine">> /* trainyard/dockyard */
	<<if $SecExp.buildings.transportHub.surfaceTransport == 1>>

 <<link "Modernize the railway" "transportHub">>
			<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology)), "capEx")>>
			<<set $SecExp.buildings.transportHub.surfaceTransport++>>
		<</link>> //Will cost <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology))>>, will increase trade and slightly lower arcology's upkeep, but will affect security//
	<<elseif $SecExp.buildings.transportHub.surfaceTransport == 2>>

 <<link "Enlarge the railway" "transportHub">>
			<<run cashX(forceNeg(Math.trunc(25000*$upgradeMultiplierArcology)), "capEx")>>
			<<set $SecExp.buildings.transportHub.surfaceTransport++>>
		<</link>> //Will cost <<print cashFormat(Math.trunc(25000*$upgradeMultiplierArcology))>>, will increase trade and slightly lower arcology's upkeep, but will affect security//
	<<elseif $SecExp.buildings.transportHub.surfaceTransport == 3>>

 <<link "Further modernize and enlarge the railway" "transportHub">>
			<<run cashX(forceNeg(Math.trunc(65000*$upgradeMultiplierArcology)), "capEx")>>
			<<set $SecExp.buildings.transportHub.surfaceTransport++>>
		<</link>> //Will cost <<print cashFormat(Math.trunc(65000*$upgradeMultiplierArcology))>>, will increase trade and slightly lower arcology's upkeep, but will affect security//
	<<else>>

The railway is fully upgraded.
	<</if>>
<<else>>
	<<if $SecExp.buildings.transportHub.surfaceTransport == 1>>

 <<link "Modernize the docks" "transportHub">>
			<<run cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology)), "capEx")>>
			<<set $SecExp.buildings.transportHub.surfaceTransport++>>
		<</link>> //Will cost <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology))>>, will increase trade and slightly lower arcology's upkeep, but will affect security//
	<<elseif $SecExp.buildings.transportHub.surfaceTransport == 2>>

 <<link "Enlarge the docks" "transportHub">>
			<<run cashX(forceNeg(Math.trunc(25000*$upgradeMultiplierArcology)), "capEx")>>
			<<set $SecExp.buildings.transportHub.surfaceTransport++>>
		<</link>> //Will cost <<print cashFormat(Math.trunc(25000*$upgradeMultiplierArcology))>>, will increase trade and slightly lower arcology's upkeep, but will affect security//
	<<elseif $SecExp.buildings.transportHub.surfaceTransport == 3>>

 <<link "Further modernize and enlarge the docks" "transportHub">>
			<<run cashX(forceNeg(Math.trunc(65000*$upgradeMultiplierArcology)), "capEx")>>
			<<set $SecExp.buildings.transportHub.surfaceTransport++>>
		<</link>> //Will cost <<print cashFormat(Math.trunc(65000*$upgradeMultiplierArcology))>>, will increase trade and slightly lower arcology's upkeep, but will affect security//
	<<else>>

The docks are fully upgraded.
	<</if>>
<</if>>

<<if $SecExp.buildings.transportHub.security == 1>> /* security */

 <<link "Expand and modernize the surveillance system" "transportHub">>
		<<run cashX(forceNeg(Math.trunc(15000*$upgradeMultiplierArcology)), "capEx")>>
		<<set $SecExp.buildings.transportHub.security++>>
	<</link>> //Will cost <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology))>> and lower the transport hub security modifiers//
<<elseif $SecExp.buildings.transportHub.security == 2>>

 <<link "Establish a rapid response team" "transportHub">>
		<<run cashX(forceNeg(Math.trunc(35000*$upgradeMultiplierArcology)), "capEx")>>
		<<set $SecExp.buildings.transportHub.security++>>
	<</link>> //Will cost <<print cashFormat(Math.trunc(35000*$upgradeMultiplierArcology))>> and further lower the transport hub security modifiers//
<<elseif $SecExp.buildings.transportHub.security == 3>>

 <<link "Add additional security drones to the structure" "transportHub">>
		<<run cashX(forceNeg(Math.trunc(55000*$upgradeMultiplierArcology)), "capEx")>>
		<<set $SecExp.buildings.transportHub.security++>>
	<</link>> //Will cost <<print cashFormat(Math.trunc(55000*$upgradeMultiplierArcology))>> and further lower the transport hub security modifiers//
<<else>>

The hub security is fully upgraded
<</if>>

[[Return this sector to standard markets|Main][delete $SecExp.buildings.transportHub, cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology)), "capEx"), App.Arcology.cellUpgrade($building, App.Arcology.Cell.Market, "Transport Hub", "Markets")]] //Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology))>>//