:: Costs [nobr]

<<set $costs = ($brothel*$facilityCost)+($arcade*$facilityCost*0.5)+($club*$facilityCost)+($dairy*$facilityCost)+($incubator*$facilityCost*10)>>

<<set $costs += (0.2*$brothelUpgradeDrugs*$brothel*$facilityCost)+(0.2*$arcadeUpgradeInjectors*$arcade*$facilityCost)+(0.2*$arcadeUpgradeCollectors*$arcade*$facilityCost)+(0.2*$clubUpgradePDAs*$club*$facilityCost)+(0.2*$dairyFeedersUpgrade*$dairy*$facilityCost)+(0.1*$dairyPregUpgrade*$dairy*$facilityCost)+(0.2*$dairyStimulatorsUpgrade*$facilityCost)+(0.2*$servantsQuartersUpgradeMonitoring*$servantsQuarters*$facilityCost)+(0.2*$incubatorUpgradeWeight*$incubator*$facilityCost)+(0.2*$incubatorUpgradeMuscles*$incubator*$facilityCost)+(0.2*$incubatorUpgradeReproduction*$incubator*$facilityCost)+(0.5*$incubatorUpgradeSpeed*$incubator*$facilityCost)>>

<<if $dairy > 0>>
	<<set $costs += ($bioreactorsXY+$bioreactorsXX+$bioreactorsHerm+$bioreactorsBarren)*100>>
<</if>>

<<if $brothel > 0>>
	<<set $costs += $brothelAdsSpending>>
<</if>>
<<if $club > 0>>
	<<set $costs += $clubAdsSpending>>
<</if>>

<<if $incubator > 0>>
	<<set $costs += ($incubatorWeightSetting+$incubatorMusclesSetting+$incubatorReproductionSetting)*500>>
<</if>>

<<if ($masterSuitePregnancySlaveLuxuries == 1)>>
	<<set $costs += 500>>
<</if>>
<<if ($masterSuitePregnancyFertilitySupplements == 1)>>
	<<set $costs += 1000>>
<</if>>

<<set $costs += ($girls*(250+($economy*500)))>>

<<if $arcologies[0].FSRepopulationFocusLaw == 1 && $PC.preg > 4>>
	<<set $costs -= 500>>
<</if>>

<<if ($PC.warfare >= 100) || ($PC.career == "arcology owner")>>
	<<set $costs += ($mercenaries*500)>>
<<else>>
	<<set $costs += ($mercenaries*1000)>>
<</if>>

<<set $costs += $FSSpending>>

<<for $i = 0; $i < $slaves.length; $i++>>

<<if $slaves[$i].livingRules == "luxurious">>
	<<if $slaves[$i].relationship >= 4>>
	<<set $costs += ($rulesCost*3)>>
	<<else>>
	<<set $costs += ($rulesCost*4)>>
	<</if>>
<<elseif $slaves[$i].livingRules == "normal">>
	<<set $costs += ($rulesCost*2)>>
<<else>>
	<<set $costs += $rulesCost>>
<</if>>

<<set $costs += $foodCost*4>>
<<switch $slaves[$i].diet>>
<<case "fattening" "muscle building">>
	<<set $costs += $foodCost>>
<<case "restricted" "slimming">>
	<<set $costs -= $foodCost>>
<</switch>>
<<if $slaves[$i].weight > 50>>
	<<set $costs += $foodCost>>
<<elseif $slaves[$i].weight < -50>>
	<<set $costs -= $foodCost>>
<</if>>
<<if $slaves[$i].drugs == "appetite suppressors">>
	<<set $costs -= $foodCost>>
<</if>>
<<if $slaves[$i].lactation > 0>>
	<<set $costs += $foodCost*$slaves[$i].lactation*(1+Math.trunc($slaves[$i].boobs/10000))>>
<</if>>
<<if $slaves[$i].preg > 5>>
	<<if $slaves[$i].assignment == "work in the dairy" && $dairyFeedersSetting > 0>>
	<<elseif ($slaves[$i].assignment == "serve in the master suite" || $slaves[$i].assignment == "be your concubine") && $masterSuiteUpgradePregnancy == 1>>
	<<else>>
		<<if $slaves[$i].pregControl == "speed up">>
			<<set $costs += $foodCost*$slaves[$i].pregType*3>>
		<<else>>
			<<set $costs += $foodCost*$slaves[$i].pregType>>
		<</if>>
	<</if>>
<</if>>

<<if ($slaves[$i].diet == "XX") || ($slaves[$i].diet == "XY")>>
	<<set $costs += 25>>
<<elseif ($slaves[$i].diet == "XXY")>>
	<<set $costs += 75>>
<</if>>

<<if $boobAccessibility != 1>>
	<<if ($slaves[$i].boobs > 7500)>>
	<<if ($slaves[$i].assignment != "work in the dairy") || ($dairyRestraintsSetting < 2)>>
	<<set $costs += 50>>
	<</if>>
	<</if>>
<</if>>

<<if $pregAccessibility != 1>>
	<<if ($slaves[$i].preg > 30 && $slaves[$i].pregType >= 2) || ($slaves[$i].preg > 20 && $slaves[$i].pregType >= 10) || ($slaves[$i].preg > 10 && $slaves[$i].pregType >= 20) || $slaves[$i].bellyImplant >= 10000>>
	<<if ($slaves[$i].assignment != "labor in the production line")>>
	<<set $Costs += 100>>
	<</if>>
	<</if>>
<</if>>

<<if $dickAccessibility != 1>>
	<<if ($slaves[$i].dick > 45)>>
	<<set $costs += 50>>
	<</if>>
<</if>>

<<if $ballsAccessibility != 1>>
	<<if ($slaves[$i].balls > 90)>>
	<<set $costs += 50>>
	<</if>>
<</if>>

<<if $buttAccessibility != 1>>
	<<if ($slaves[$i].butt > 15)>>
	<<set $costs += 50>>
	<</if>>
<</if>>

<<if $slaves[$i].boobs > 10000>>
<<if $slaves[$i].boobsImplantType == 1>>
	<<set $costs += 50>>
<</if>>
<</if>>
<<if $slaves[$i].butt > 10>>
<<if $slaves[$i].buttImplantType == 1>>
	<<set $costs += 50>>
<</if>>
<</if>>

<<if $slaves[$i].preg > 25>>
<<if $slaves[$i].universalRulesBirthing == 1>>
	<<set $costs += 50>>
<</if>>
<</if>>

<<if $CitizenRetirement == 1>>
	<<set $costs += 250>>
<</if>>

<<if ($slaves[$i].assignment == "be a servant") || ($slaves[$i].assignment == "work as a servant")>>
	<<if $slaves[$i].trust < -20>>
		<<set $costs -= ($rulesCost*4)>>
	<<elseif $slaves[$i].devotion < -20>>
		<<set $costs -= ($rulesCost*2)>>
	<<elseif $slaves[$i].devotion <= 20>>
		<<set $costs -= ($rulesCost*3)>>
	<<elseif $slaves[$i].devotion <= 50>>
		<<set $costs -= ($rulesCost*4)>>
	<<else>>
		<<set $costs -= ($rulesCost*5)>>
	<</if>>
	<<if ($slaves[$i].fetish == "submissive")>>
		<<set $costs -= ($rulesCost)>>
	<<elseif ($slaves[$i].fetish == "dom")>>
		<<set $costs += ($rulesCost)>>
	<</if>>
	<<if ($slaves[$i].relationship < -1)>>
		<<set $costs -= ($rulesCost)>>
	<</if>>
	<<if ($slaves[$i].energy < 20)>>
		<<set $costs -= ($rulesCost)>>
	<<elseif ($slaves[$i].energy < 40)>>
		<<set $costs -= ($rulesCost/2)>>
	<</if>>
	<<if ($slaves[$i].lactation > 0)>>
		<<set $costs -= 25>>
	<</if>>
<</if>>

<<if ($slaves[$i].amp != 0)>>
  <<if ($slaves[$i].amp == 1)>>
	<<set $costs += $rulesCost>>
  <<else>>
	<<set $costs += $rulesCost/2>>
  <</if>>
<<elseif !canWalk($slaves[$i])>>
  <<set $costs += $rulesCost>>
<</if>>

<<if !canSee($slaves[$i])>>
	<<set $costs += 50>>
<<elseif $slaves[$i].eyes <= -1>>
	<<if $slaves[$i].eyewear != "corrective glasses">>
	<<if $slaves[$i].eyewear != "corrective contacts">>
	<<set $costs += 25>>
	<</if>>
	<</if>>
<<elseif ($slaves[$i].eyewear == "blurring glasses") || ($slaves[$i].eyewear == "blurring contacts")>>
	<<set $costs += 25>>
<</if>>

<<if ($servantsQuartersUpgradeMonitoring == 1)>>
	<<if ($slaves[$i].assignment == "work as a servant")>>
	<<set $costs -= ($rulesCost)>>
	<</if>>
<</if>>

<<if ($slaves[$i].inflation == 3)>>
	<<switch $slaves[$i].inflationType>>
	<<case "water">>
		<<set $costs += 100>>
	<<case "curative" "aphrodisiac" "tightener">>
		<<set $costs += (100+($drugsCost*2))>>
	<</switch>>
<<elseif ($slaves[$i].inflation == 2)>>
	<<switch $slaves[$i].inflationType>>
	<<case "water">>
		<<set $costs += 50>>
	<<case "curative" "aphrodisiac" "tightener">>
		<<set $costs += (50+($drugsCost*2))>>
	<</switch>>
<<elseif ($slaves[$i].inflation == 1)>>
	<<switch $slaves[$i].inflationType>>
	<<case "water">>
		<<set $costs += 25>>
	<<case "curative" "aphrodisiac" "tightener">>
		<<set $costs += (25+($drugsCost*2))>>
	<</switch>>
<</if>>

<<if ($slaves[$i].drugs == "female hormone injections") || ($slaves[$i].drugs == "male hormone injections")>>
	<<set $costs += ($drugsCost*5)>>
<<elseif ($slaves[$i].drugs == "anti-aging cream")>>
	<<set $costs += ($drugsCost*10)>>
<<elseif ($slaves[$i].drugs != "no drugs")>>
	<<set $costs += ($drugsCost*2)>>
<</if>>
<<if ($slaves[$i].curatives > 0)>>
	<<set $costs += $drugsCost+($slaves[$i].curatives*$drugsCost)>>
<<elseif ndef $slaves[$i].curatives>>
	<<set $slaves[$i].curatives = 0>>
<</if>>
<<if ($slaves[$i].aphrodisiacs > 0)>>
	<<set $costs += $drugsCost*$slaves[$i].aphrodisiacs>>
<<elseif ndef $slaves[$i].aphrodisiacs>>
	<<set $slaves[$i].aphrodisiacs = 0>>
<</if>>

<<set $costs += $drugsCost*Math.abs($slaves[$i].hormones)*0.5>>

<<if ($slaves[$i].preg == -1) && isFertile($slaves[$i])>>
	<<set $costs += $drugsCost*0.5>>
<</if>>

<<if ($studio == 1)>>
	<<set $costs += $slaves[$i].pornFameSpending>>
<</if>>

<</for>>

<<if $Recruiter != 0>>
	<<set $costs += 250>>
<</if>>
<<if $TSS.schoolPresent == 1>>
	<<set $costs += 1000>>
<</if>>
<<if $GRI.schoolPresent == 1>>
	<<set $costs += 1000>>
<</if>>
<<if $SCP.schoolPresent == 1>>
	<<set $costs += 1000>>
<</if>>
<<if $LDE.schoolPresent == 1>>
	<<set $costs += 1000>>
<</if>>
<<if $TGA.schoolPresent == 1>>
	<<set $costs += 1000>>
<</if>>
<<if ($TFS.schoolPresent == 1) && (($PC.dick == 0) || ($PC.vagina == 0) || ($PC.boobs == 0))>>
	<<set $costs += 1000>>
<</if>>
<<if $TSS.subsidize != 0>>
	<<set $costs += 1000>>
<</if>>
<<if $GRI.subsidize != 0>>
	<<set $costs += 1000>>
<</if>>
<<if $SCP.subsidize != 0>>
	<<set $costs += 1000>>
<</if>>
<<if $LDE.subsidize != 0>>
	<<set $costs += 1000>>
<</if>>
<<if $TGA.subsidize != 0>>
	<<set $costs += 1000>>
<</if>>
<<if $TFS.subsidize != 0>>
	<<set $costs += 1000>>
<</if>>

<<if $alwaysSubsidizeGrowth == 1>>
	<<set $costs += $policyCost>>
<</if>>
<<if $alwaysSubsidizeRep == 1>>
	<<set $costs += $policyCost>>
<</if>>
<<if $RegularParties == 1>>
	<<set $costs += $policyCost>>
<</if>>

<<if $ProImmigrationCash == 1>>
	<<set $costs += $policyCost>>
<</if>>
<<if $AntiEnslavementCash == 1>>
	<<set $costs += $policyCost>>
<</if>>

<<if $CoursingAssociation == 1>>
	<<set $costs += 1000>>
<</if>>

<<if ($personalAttention == "trading")>>
	<<set $costs += 10000>>
<<elseif ($personalAttention == "warfare")>>
	<<set $costs += 10000>>
<<elseif ($personalAttention == "slaving")>>
	<<set $costs += 10000>>
<<elseif ($personalAttention == "engineering")>>
	<<set $costs += 10000>>
<<elseif ($personalAttention == "medicine")>>
	<<set $costs += 10000>>
<</if>>

<<if $cyberMod != 0 && $researchLab.built == "true">>
	<<set $costs += ((100*$researchLab.maxSpace)+(300*$researchLab.hired)+(100*$researchLab.hired))>>
<</if>>

<<if $PC.preg == -1>>
	<<set $costs += 25>>
<<elseif $PC.preg >= 16>>
	<<set $costs += 100>>
<</if>>

<<if $PC.career == "servant">>
	<<if $personalAttention == "upkeep">>
		<<if $PC.preg >= 20>>
			<<set $costs = ($costs*0.80)>>
		<<else>>
			<<set $costs = ($costs*0.75)>>
		<</if>>
	<<else>>
	<<set $costs = ($costs*0.90)>>
	<</if>>
<</if>>

<<if $costs < 0>>
	<<set $costs = 0>>
<<else>>
	<<set $costs = Math.trunc($costs)>>
<</if>>
