code:
:: Bulk Slave Generate [nobr]

<<set $newSlaves = [], $returnTo = "Main", $newSlavesDone = 0, $spent = 0, $newSlaveIndex = 0>>

<<if ndef $numSlaves>>
	<<set $numSlaves = 5>>
<</if>>

/* Discount calculation. Gives 5% on top of slave school discount */
<<set $discount = 475>>
<<switch $slaveMarket>>
<<case "TSS">>
	<<if $TSS.schoolUpgrade != 0>>
		<<set $discount = 375>>
	<</if>>

<<case "GRI">>
	<<if $GRI.schoolUpgrade != 0>>
		<<set $discount = 375>>
	<</if>>

<<case "SCP">>
	<<if $SCP.schoolUpgrade != 0>>
		<<set $discount = 375>>
	<</if>>

<<case "LDE">>
	<<if $LDE.schoolUpgrade != 0>>
		<<set $discount = 375>>
	<</if>>

<<case "TGA">>
	<<if $TGA.schoolUpgrade != 0>>
		<<set $discount = 375>>
	<</if>>

<<case "HA">>
	<<if $HA.schoolUpgrade != 0>>
		<<set $discount = 375>>
	<</if>>

<<case "NUL">>
	<<if $NUL.schoolUpgrade != 0>>
		<<set $discount = 375>>
	<</if>>

<<case "TCR">>
	<<if $TCR.schoolUpgrade != 0>>
		<<set $discount = 375>>
	<</if>>

<<case "TFS">>
	<<if $TFS.schoolUpgrade != 0>>
		<<set $discount = 300>>
	<<else>>
		<<set $discount = 380>>
	<</if>>

<<case "corporate">>
	<<if $corp.Market == 1>>
		<<set $discount = 350>>
	<</if>>

<<case "neighbor">>
	<<if $numArcology >= $arcologies.length>>
		<<set $numArcology = 1>>
	<</if>>
	<<set _opinion = App.Neighbor.opinion(0, $numArcology)>>
	<<set _opinion = Math.clamp(Math.trunc(_opinion/20), -10, 10)>>
	<<set $discount -= (_opinion * 25)>>

<</switch>>

/* Determine if Law Compliance effects must be applied to this transaction */
<<if App.Data.misc.lawlessMarkets.includes($slaveMarket)>>
	<<set $applyLaw = 0>>
<<else>>
	<<set $applyLaw = 1>>
<</if>>

<<for _i = 0; _i < $numSlaves; _i++>>
	<<set $activeSlave = (generateMarketSlave($slaveMarket, $numArcology)).slave>>
	<<set $slavesSeen++>>
	<<if $applyLaw == 0>>
		<<set _slaveCost = slaveCost($activeSlave)>>
	<<else>>
		<<set _backup = $activeSlave>> /* backup newly generated slave */
		<<silently>>
			<<include "Law Compliance">> /* includes CheckForGingering — slave stats may change, affecting price */
		<</silently>>
		<<set _slaveCost = slaveCost($activeSlave)>>
		<<run removeGingering()>> /* remove gingered state, if applied, so we can apply it again later */
		<<set $activeSlave = _backup>> /* restore backup so we can apply Law Compliance again later */
	<</if>>

	/* Adjust _slaveCost according to $slavesSeen */
	<<if $slavesSeen > $slaveMarketLimit>>
		<<set _slaveCost += _slaveCost*(($slavesSeen-$slaveMarketLimit)*0.1)>>
		<<if $introType == "inStock">>
			<<break>>
		<</if>>
	<</if>>

	/* Apply discount modifier */
	<<set _slaveCost = $discount*Math.trunc(_slaveCost/500)>>

	/* Charge the Player for the slave, or break out if cannot afford */
	<<if $cash < _slaveCost>>
		<<set _i = $numSlaves>>
		<<break>>
	<<else>>
		<<run cashX(forceNeg(_slaveCost), "slaveTransfer", $activeSlave)>>
		<<set $newSlaves.push($activeSlave)>>
		<<set $spent += _slaveCost>>
	<</if>>
<</for>>

/* Max Buy clean-up */
<<if $numSlaves == 9999>>
	<<set $numSlaves = $newSlaves.length>>
<</if>>

/* increment Slave school purchase counts if needed */
<<switch $slaveMarket>>
<<case "TSS">>
	<<set $TSS.studentsBought += $newSlaves.length>>
<<case "GRI">>
	<<set $GRI.studentsBought += $newSlaves.length>>
<<case "SCP">>
	<<set $SCP.studentsBought += $newSlaves.length>>
<<case "LDE">>
	<<set $LDE.studentsBought += $newSlaves.length>>
<<case "TGA">>
	<<set $TGA.studentsBought += $newSlaves.length>>
<<case "HA">>
	<<set $HA.studentsBought += $newSlaves.length>>
<<case "TCR">>
	<<set $TCR.studentsBought += $newSlaves.length>>
<<case "TFS">>
	<<set $TFS.studentsBought += $newSlaves.length>>
<<case "NUL">>
	<<set $NUL.studentsBought += $newSlaves.length>>
<</switch>>

<<goto "Bulk Slave Intro">>


code:
:: Bulk Slave Intro [nobr]

<<if ndef $introType || $newSlaves.length == 0>>
	<<set $introType = "">>
<</if>>

<<switch $introType>>
<<case "">>
	/* No message to give */
<<case "multi">>
	<<if $newSlaves.length > 1>>
		Your selection of $newSlaves.length slaves arrives from <<MarketNamePeriod $slaveMarket $numArcology>>
	<<else>>
		Your new slave from <<MarketName $slaveMarket $numArcology>> has arrived.
	<</if>>

<<case "bulk">>
	Your delivery of $newSlaves.length slaves arrives from <<MarketNamePeriod $slaveMarket $numArcology>>
	<<if $newSlaves.length != $numSlaves>>
		You were going to order $numSlaves, but $assistant.name lowered it on financial grounds.
	<</if>>
	<<set _seed = Math.ceil($slavesSeen - $slaveMarketLimit)>>
	<<if _seed > $newSlaves.length>>
		You have cast such a wide net for slaves this week that all are more expensive than normal.
	<<elseif _seed > 0>>
		You have cast such a wide net for slaves this week that some (_seed) are more expensive than normal.
	<</if>>
	<<if $slaveMarket == "TFS">>
		/* Put line about The Futanari Sisters discount & pricing */
	<<elseif $discount == 475>>
		Your bulk delivery came with a @@.yellowgreen;5%@@ discount.
	<<else>>
		With all your discounts factored in you got a @@.yellowgreen;<<print (500-$discount)/5>>%@@ discount;
	<</if>>
	You spent @@.yellowgreen;<<print cashFormat($spent)>>@@ on your new slaves.

<<case "inStock">>
	You clear out <<MarketName $slaveMarket $numArcology>> of its stock of $newSlaves.length slaves.
	<<if $slaveMarket == "TFS">>
		/* Put line about The Futanari Sisters discount & pricing */
	<<elseif $discount == 475>>
		Your bulk delivery came with a @@.yellowgreen;5%@@ discount.
	<<else>>
		With all your discounts factored in you got a @@.yellowgreen;<<print (500-$discount)/5>>%@@ discount;
	<</if>>
	You spent @@.yellowgreen;<<print cashFormat($spent)>>@@ on your new slaves.

<<case "liquidator">>

Your new pair of slaves look frightened and uncertain, but seem encouraged by each other's presence.

<<case "egyptian">>

They arrive hand-in-hand and don't let go of each other until the end of the enslavement process, and even after they break their grip and undress at your instruction, their eyes never stray far from each other. With a closer look at them, their blood relation is as obvious as their infatuation with one another. No wonder they couldn't keep it a secret.

<<case "event">>
	This is placeholder event info.

<</switch>>
/* remove the below line to make the intro blurb show up for every slave, not just the first */
<<set $introType = "">>

<<if ($newSlaveIndex >= $newSlaves.length) || ($newSlavesDone == 1)>>
	<<if $newSlaves.length > 0>>
		/* Push the induction changes for the final slave to the newSlave array */
		<<run newSlave($activeSlave)>>

		/* Variable Clean-up */
		<<set $newSlaves = []>>
		<<set $newSlavesDone = 0>>
		<<set $introType = "">>
	<</if>>
	<<goto $returnTo>>
<<else>>
	/* If looking at 2nd slave, push the induction changes for the prior slave to the newSlave array */
	<<if $newSlaveIndex > 0>>
		<<run newSlave($activeSlave)>>
	<</if>>
	<<if $newSlaves.length > 1>>
		Showing new slave <<print $newSlaveIndex+1>> of <<print $newSlaves.length>>:
	<</if>>

	/* Set activeSlave to the desired newSlave so that existing code can be used */
	<<set $activeSlave = $newSlaves[$newSlaveIndex]>>

	/* Due to possible gingering, the Long Slave Description must be displayed before the New Slave Intro */
	<<set $saleDescription = 1>> /* policies were applied earlier, if needed */
	<<include "Long Slave Description">>

	/* Use existing New Slave Intro */
	<<include "New Slave Intro">> /* calls removeGingering() if needed */

	/* Override nextButton setting from New Slave Intro */
	<<set $nextButton = "Continue">>
	<<set $nextLink = "Bulk Slave Intro">>

	/* Add an option = goto the next slave below the New Slave Intro section */

	<<if $newSlaveIndex < ($newSlaves.length - 1)>>
		[[Next Slave|Bulk Slave Intro]]
	<<else>>
		[[Finish introducing slaves|Bulk Slave Intro][$newSlavesDone = 1]]
	<</if>>

<</if>> /* Closes no new Slaves check */

<<set $newSlaveIndex++>>

repo_name: KnightBoulegard/fc

license: mit


code:
:: Buy Slaves [nobr jump-to-safe jump-from-safe]

<<set $nextButton = "Back">>
<<set $nextLink = "Main">>
<<set _minimumFive = minimumSlaveCost() * 5>>
<<set _minimumTen = minimumSlaveCost() * 10>>

The Market

	//There are many different organizations to purchase slaves from, but many of them are selective about their customers and will only sell to you if you are reputable.//

Market status

	<<if ($slaveCostFactor > 1.1)>>
		@@.yellow;There is a bull market for slaves; the price of slaves is very high.@@
	<<elseif ($slaveCostFactor > 1)>>
		@@.yellow;The slave market is bullish; the price of slaves is high.@@
	<<elseif ($slaveCostFactor < 0.9)>>
		@@.yellow;There is a bear market for slaves; the price of slaves is very low.@@
	<<elseif ($slaveCostFactor < 1)>>
		@@.yellow;The slave market is bearish; the price of slaves is low.@@
	<<else>>
		The slave market is stable; the price of slaves is average.
	<</if>>

Sex Slave Purchase Options

	<<if $corp.Incorporated == 1>>
		[[Corporate Market][$slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = "corporate", $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = "corporate", $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		<<if $corp.Market == 1>>//Slaves from your corporation purchased at a discounted rate.//<<else>>//Slaves from your corporation//<</if>>
	<</if>>

	[[The Flesh Heap|Slave Markets][$slaveMarket = "heap", $slavesSeen += 1]] | //Broken and discarded slaves. Near useless, but cheap. No longer does bulk orders after complaints.//

	<<if $bodyswapAnnounced == 1>>
		[[Order a custom husk slave from the Flesh Heap|Husk Slave]] | //Will need to be used on arrival.//
	<</if>>

	<<if ($rep > 500)>>
		[[Kidnappers' Market|Slave Markets][$slaveMarket = "kidnappers", $slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = "kidnappers", $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = "kidnappers", $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		//Slaves will tend to be low quality and resistant.//
	<</if>>

	''Neighboring Arcologies:'' //The arcology's prosperity and culture will affect slaves who have lived there.//

<<for _i = 0; _i < $arcologies.length; _i++>>
	<<if $arcologies[_i].direction != 0>>

			<<capture _i>>[[Slaves from|Slave Markets][$slaveMarket = "neighbor", $numArcology = _i]]<</capture>>
			'' $arcologies[_i].name''
			<<if $cash > _minimumFive>>
				| <<capture _i>>[[(x5)|Bulk Slave Generate][$slaveMarket = "neighbor", $introType = "bulk", $numSlaves = 5, $numArcology = _i]]<</capture>>
			<</if>>
			<<if $cash > _minimumTen>>
				| <<capture _i>>[[(x10)|Bulk Slave Generate][$slaveMarket = "neighbor", $introType = "bulk", $numSlaves = 10, $numArcology = _i]]<</capture>>
			<</if>>

	<</if>>
<</for>>

	<<if ($rep > 1000)>>
		[[Runaway Hunters' Market|Slave Markets][$slaveMarket = "hunters", $slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = "hunters", $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = "hunters", $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		//Slaves will tend to be skilled but rebellious.//
	<</if>>

	<<if ($rep > 1500)>>
		[[Indentures Market|Slave Markets][$slaveMarket = "indentures", $slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = "indentures", $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = "indentures", $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		//Temporary enslavement and restrictions on treatment.//
	<</if>>

	<<if ($rep > 2000)>>
		[[Raiders' Market|Slave Markets][$slaveMarket = "raiders", $slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = "raiders", $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = "raiders", $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		//Slaves will always be sold immediately upon reaching majority.//
	<</if>>

	<<if ($pedo_mode == 1 || ($minimumSlaveAge <= 13 && $minimumSlaveAge <= $fertilityAge)) && ($rep > 3000)>>
		[[Raiders' Black Market|Slave Markets][$slaveMarket = "underage raiders", $slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = "underage raiders", $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = "underage raiders", $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		//Very young slaves.//
	<</if>>

<<if ($rep > 4000)>>

		[[Trainers' Market|Slave Markets][$slaveMarket = "trainers", $slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = "trainers", $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = "trainers", $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		//Slaves will tend to be good quality and obedient.//

		<<if $arcologies[0].FSPaternalist == "unset">>
			[[Wetware CPUs|Slave Markets][$slaveMarket = "wetware", $slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "wetware", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "wetware", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//Ruined bodies but keen minds. Requires some TLC, but offers outstanding training at a discount.//
		<<else>>
			//The paternalistic nature of your society blocks the abusive Wetware CPU manufactures from operating within your arcology.//
		<</if>>

<</if>>

	<<if ($rep > 5000)>>
		<<set $weeklyMarket = $prisonCircuit[$prisonCircuitIndex]>>
		[[Prisoner Sale|Criminal Market][$slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = $weeklyMarket, $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = $weeklyMarket, $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		This week
		<<switch $weeklyMarket>>
		<<case "low tier criminals">>
			a minor prison is selling inmates.
			//Slaves will tend to be low to mid quality with few redeeming factors.//
		<<case "gangs and smugglers">>
			a major prison is selling hardened criminals.
			//Slaves will tend to be low quality and difficult but may prove useful once broken.//
		<<case "white collar">>
			a white collar prison is selling inmates.
			//Slaves will tend to be medium to high quality with a variety of useful backgrounds.//
		<<case "military prison">>
			a military prison is selling inmates.
			//Slaves will tend to be high quality but defiant.//
		<</switch>>
	<</if>>

<<if ($rep > 6000)>>

		''Slave Schools:'' //High prices; will be young and healthy.//

	<<if ($seeDicks != 100)>>

			[[The Slavegirl School][$slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "TSS", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "TSS", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//Straightforward slaves with good training.//<<if $TSS.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

			[[Growth Research Institute][$slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "GRI", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "GRI", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//Poorly trained slaves with huge assets.//<<if $GRI.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

			[[St. Claver Preparatory][$slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "SCP", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "SCP", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//Slaves with basic training and solid implants.//<<if $SCP.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

			[[The Cattle Ranch][$slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "TCR", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "TCR", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//Mentally conditioned free-range cowgirls.//<<if $TCR.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

			[[The Hippolyta Academy][$slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "HA", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "HA", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//High quality slaves of powerful physique and refined skills.//<<if $HA.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

	<</if>>
	<<if ($seeDicks != 0)>>

			[[L'École des Enculées][$slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "LDE", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "LDE", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//Slaves optimized and trained for anal.//<<if $LDE.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

			[[The Gymnasium-Academy][$slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "TGA", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "TGA", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//Well trained slaves with dicks.//<<if $TGA.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

			[[The Futanari Sisters][$slavesSeen += 1]] |
			<<if $cash > _minimumFive>>
				[[(x5)|Bulk Slave Generate][$slaveMarket = "TFS", $introType = "bulk", $numSlaves = 5]] |
			<</if>>
			<<if $cash > _minimumTen>>
				[[(x10)|Bulk Slave Generate][$slaveMarket = "TFS", $introType = "bulk", $numSlaves = 10]] |
			<</if>>
			//Highly skilled, highly feminine hermaphrodites.//<<if $TFS.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

	<</if>>

		[[Nueva Universidad de Libertad][$slavesSeen += 1]] |
		<<if $cash > _minimumFive>>
			[[(x5)|Bulk Slave Generate][$slaveMarket = "NUL", $introType = "bulk", $numSlaves = 5]] |
		<</if>>
		<<if $cash > _minimumTen>>
			[[(x10)|Bulk Slave Generate][$slaveMarket = "NUL", $introType = "bulk", $numSlaves = 10]] |
		<</if>>
		//Androgynous slaves lacking genitalia.//<<if $NUL.schoolSale == 1>> //@@.yellow;Offering your first purchase at half price this week.@@//<</if>>

<</if>>

	<<if ($arcologies[0].FSDegradationist != "unset")>>
		//The Slave Shelter does not place slaves into Degradationist arcologies.//
	<<elseif ($shelterAbuse > 10)>>
		//The Slave Shelter has banned you due to dark rumors about you.//
	<<elseif ($shelterAbuse > 5)>>
		//The Slave Shelter has banned you due to rumors that you resell its slaves.//
	<<elseif ($shelterSlaveBought == 1)>>
		>//The Slave Shelter will not offer another slave for placement until next week.//
	<<elseif ($rep > 7000)>>
		[[Take in a shelter slave|Slave Shelter]] | //Presents charity cases for a nominal fee.//
	<</if>>

	<<if ($rep > 8000)>>
		[[Consult the household liquidator|Household Liquidator][$slavesSeen += 2]] | //Offers slaves close to one another at a very high price.//
	<</if>>

<<if ($rep > 10000)>>

[[Place a special order|Custom Slave]] | //Customizable but very expensive.//

[[Place a fulfillment order|JobFulfillmentCenterOrder]] | //Fills leaderships roles for a price.//

<</if>>

<<if ($rep > 12000)>>

[[Attend an auction of a prestigious slave|Prestigious Slave]] | //Variable and expensive.//

<</if>>

<<if ($propOutcome == 1)>>

[[Attend an auction of other Elite's stock|Elite Slave]] | //Limited and very expensive.//

<</if>>

<<if ($rep > 14000)>>

[[Acquire other slaveowners' stock|Special Slave]] | //Variable and expensive.//

<</if>>

	<<if ($rep <= 500)>>
		//You are not reputable enough to buy kidnapped slaves.//
	<<elseif ($rep <= 1000)>>
		//You are not reputable enough to buy recaptured slaves.//
	<<elseif ($rep <= 1500)>>
		//You are not reputable enough to buy indentured servants.//
	<<elseif ($rep <= 2000)>>
		//You are not reputable enough to buy teenaged slaves.//
	<<elseif ($pedo_mode == 1 || ($minimumSlaveAge <= 13 && $minimumSlaveAge <= $fertilityAge)) && ($rep <= 3000)>>
		//You are not reputable enough to buy underaged slaves.//
	<<elseif ($rep <= 4000)>>
		//You are not reputable enough to buy trained slaves.//
	<<elseif ($rep <= 5000)>>
		//You are not reputable enough to buy prison slaves.//
	<<elseif ($rep <= 6000)>>
		//You are not reputable enough to acquire fresh school slaves.//
	<<elseif ($rep <= 7000)>>
		//You are not reputable enough to take in Shelter slaves.//
	<<elseif ($rep <= 8000)>>
		//You are not reputable enough to consult the household liquidator.//
	<<elseif ($rep <= 1000)>>
		//You are not reputable enough to order custom slaves.//
	<<elseif ($rep <= 12000)>>
		//You are not reputable enough to bid on prestigious slaves.//
	<<elseif ($rep <= 14000)>>
		//You are not reputable enough to acquire other slaveowners' stock.//
	<<else>>
		You are so reputable that you can access all of the Free Cities' slaving markets.
	<</if>>

Selling slaves

	While you are at the market, you may want to [[look at your own underperforming slaves|Underperforming Slaves]].

Menial Slaves

	Slave demand is
	<<if $menialDemandFactor <= -35000>>
		@@.red;''extremely low''@@
	<<elseif $menialDemandFactor <= -20000>>
		@@.red;''very low''@@
	<<elseif $menialDemandFactor <= 0>>
		@@.yellow;''weak''@@
	<<elseif $menialDemandFactor >= 35000>>
		@@.green;''extremely high''@@
	<<elseif $menialDemandFactor >= 20000>>
		@@.green;''very high''@@
	<<else>>
		@@.yellow;''strong''@@
	<</if>>
	<<if $deltaDemand > 0>>
		and @@.green;''improving''@@
	<<elseif $deltaDemand < 0>>
		and @@.red;''decreasing''@@
	<</if>>
	<<if $deltaDemand != 0>>
		<<if $demandTimer - $elapsedDemandTimer < 3>>
			but it might change soon
		<</if>>
	<</if>>
	<<if ($cheatMode) && ($cheatModeM)>>

			@@.yellowgreen;Slave Demand@@
			| <<print $menialDemandFactor>>

		<<set _TmenialDemandFactor = $menialDemandFactor>>
		<<textbox "_TmenialDemandFactor" _TmenialDemandFactor>>
		<<link "Apply">>
			<<set $menialDemandFactor = Math.clamp(Math.trunc(Number(_TmenialDemandFactor)),-50000,50000) || $menialDemandFactor, $cheater = 1>>
			<<replace "#menialDemandFactor">>
				@@.yellowgreen; Slave Demand@@
				| <<print $menialDemandFactor>>
			<</replace>>
		<</link>>
	<</if>>

	Slave supply is
	<<if $menialSupplyFactor <= -35000>>
		@@.green;''extremely low''@@
	<<elseif $menialSupplyFactor <= -20000>>
		@@.green;''very low''@@
	<<elseif $menialSupplyFactor <= 0>>
		@@.yellow;''weak''@@
	<<elseif $menialSupplyFactor >= 35000>>
		@@.red;''extremely high''@@
	<<elseif $menialSupplyFactor >= 20000>>
		@@.red;''very high''@@
	<<else>>
		@@.yellow;''strong''@@
	<</if>>
	<<if $deltaSupply > 0>>
		and @@.red;''improving''@@
	<<elseif $deltaSupply < 0>>
		and @@.green;''decreasing''@@
	<</if>>
	<<if $deltaSupply != 0>>
		<<if $supplyTimer - $elapsedDemandTimer < 3>>
			but it might change soon
		<</if>>
	<</if>>
	<<if ($cheatMode) && ($cheatModeM)>>

			@@.yellowgreen;Slave Supply@@
			| <<print $menialSupplyFactor>>

		<<set _TmenialSupplyFactor = $menialSupplyFactor>>
		<<textbox "_TmenialSupplyFactor" _TmenialSupplyFactor>>
		<<link "Apply">>
			<<set $menialSupplyFactor = Math.clamp(Math.trunc(Number(_TmenialSupplyFactor)),-50000,50000) || $menialSupplyFactor, $cheater = 1>>
			<<replace "#menialSupplyFactor">>
				@@.yellowgreen; Slave Supply@@
				| <<print $menialSupplyFactor>>
			<</replace>>
		<</link>>
	<</if>>

	<<= MenialPopCap()>>
	The parts of your arcology you own can house a total of <<= num($PopCap)>> menial slaves.

<<set _menialPrice = menialSlaveCost()>>
<<set _bulkMax = $PopCap-$menials-$fuckdolls-$menialBioreactors>>

	<<if $menials > 1>>
		You own <<print num(Math.trunc($menials))>> menial slaves.
	<<elseif $menials > 0>>
		You own one menial slave.
	<<else>>
		You do not own any menial slaves.
	<</if>>
	The market price of menials is <<print cashFormat(_menialPrice)>>.
	<<set _optionsBreak = 0>>
	<<if _bulkMax > 0 && $cash > _menialPrice>>
		[[Buy|Buy Slaves][$menials+=1,$menialSupplyFactor-=1,cashX(forceNeg(_menialPrice), "menialTransfer")]]
		<<if $cash > (menialSlaveCost(10))*10>>
			[[(x10)|Buy Slaves][$menials+=10,$menialSupplyFactor-=10,cashX(forceNeg((menialSlaveCost(10))*10), "menialTransfer")]]
		<</if>>
		<<if $cash > (menialSlaveCost(100))*100>>
			[[(x100)|Buy Slaves][$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)|Buy Slaves][$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.//
		<<set _optionsBreak = 1>>
	<</if>>
	<<if $menials >= 1>>
		<<if _optionsBreak>>|<</if>>
		[[Sell|Buy Slaves][$menials-=1,$menialDemandFactor-=1,cashX(_menialPrice, "menialTransfer")]]
		<<if $menials >= 10>>
			[[(x10)|Buy Slaves][$menials-=10,$menialDemandFactor-=10,cashX(((menialSlaveCost(-10))*10), "menialTransfer")]]
			<<if $menials >= 100>>
				[[(x100)|Buy Slaves][$menials-=100,$menialDemandFactor-=100,cashX(((menialSlaveCost(-100))*100), "menialTransfer")]]
			<</if>>
		<</if>>
		[[(all)|Buy Slaves][cashX(($menials*(menialSlaveCost(-$menials))), "menialTransfer"),$menialDemandFactor-=$menials,$menials = 0]]
		<<if $arcologies[0].FSPaternalist == "unset">>
			<<if $arcadeUpgradeFuckdolls > 0>>
				<<set _fconvertCost = 100>>

					[[Convert to Fuckdoll|Buy Slaves][$menials-=1,$fuckdolls+=1,cashX(forceNeg(_fconvertCost), "menialTransfer")]]
					<<if $menials >= 10>>
						[[(x10)|Buy Slaves][$menials-=10,$fuckdolls+=10,cashX(forceNeg(10*(_fconvertCost)), "menialTransfer")]]
						<<if $menials >= 100>>
							[[(x100)|Buy Slaves][$menials-=100,$fuckdolls+=100,cashX(forceNeg(100*(_fconvertCost)), "menialTransfer")]]
						<</if>>
					<</if>>
					[[(all)|Buy Slaves][$fuckdolls+=$menials,cashX(forceNeg((_fconvertCost)*($menials)), "menialTransfer"),$menials=0]]
					//Conversion costs <<print cashFormat(_fconvertCost)>> each//

			<</if>>
			<<if $dairyFeedersUpgrade > 0>>

					[[Convert to Bioreactor|Buy Slaves][$menials-=1,$menialBioreactors+=1,cashX(-100, "menialTransfer")]]
					<<if $menials >= 10>>
						[[(x10)|Buy Slaves][$menials-=10,$menialBioreactors+=10,cashX(-1000, "menialTransfer")]]
						<<if $menials >= 100>>
							[[(x100)|Buy Slaves][$menials-=100,$menialBioreactors+=100,cashX(-10000, "menialTransfer")]]
						<</if>>
					<</if>>
					[[(all)|Buy Slaves][$menialBioreactors+=$menials,cashX(forceNeg(500*$menials), "menialTransfer"),$menials=0]]
					//Conversion costs <<print cashFormat(500)>> each//

			<</if>>
		<</if>>
	<</if>>

	<<if $fuckdolls > 1>>
		You own <<print num(Math.trunc($fuckdolls))>> standard Fuckdolls.
	<<elseif $fuckdolls > 0>>
		You own one standard Fuckdoll.
	<<elseif $arcologies[0].FSPaternalist == "unset">>
		You do not own any standard Fuckdolls.
	<</if>>
	<<if ($fuckdolls > 0) || ($arcologies[0].FSPaternalist == "unset")>>
		The market price of standard Fuckdolls is <<print cashFormat(_menialPrice)>>.
		<<set _optionsBreak = 0>>
		<<if _bulkMax > 0>>
			<<if $arcologies[0].FSPaternalist == "unset" && $cash > _menialPrice>>
				[[Buy|Buy Slaves][$fuckdolls+=1,$menialSupplyFactor-=1,cashX(forceNeg(_menialPrice), "fuckdollsTransfer")]]
				<<if $cash > menialSlaveCost(10)*10>>
					[[(x10)|Buy Slaves][$fuckdolls+=10,$menialSupplyFactor-=10,cashX(forceNeg(menialSlaveCost(10)*10), "fuckdollsTransfer")]]
				<</if>>
				<<if $cash > menialSlaveCost(100)*100>>
					[[(x100)|Buy Slaves][$fuckdolls+=100,$menialSupplyFactor-=100,cashX(forceNeg(menialSlaveCost(100)*100), "fuckdollsTransfer")]]
				<</if>>
				<<if $cash > ((_menialPrice+1)*2)>>
					[[(max)|Buy Slaves][$fuckdolls+=Math.trunc(Math.clamp($cash/_menialPrice,0,_bulkMax)),$menialSupplyFactor-=Math.trunc(Math.clamp($cash/_menialPrice,0,_bulkMax)),cashX(forceNeg(Math.trunc(Math.clamp($cash/_menialPrice,0,_bulkMax))*_menialPrice), "fuckdollsTransfer")]]
				<</if>>
				//Bulk transactions may require offering a premium.//
				<<set _optionsBreak = 1>>
			<</if>>
		<</if>>
		<<if $fuckdolls >= 1>>
			<<if _optionsBreak>>|<</if>>
			[[Sell|Buy Slaves][$fuckdolls-=1,$menialDemandFactor-=1,cashX(_menialPrice, "fuckdollsTransfer")]]
		<<if $fuckdolls >= 10>>
			[[(x10)|Buy Slaves][$fuckdolls-=10,$menialDemandFactor-=10,cashX((menialSlaveCost(-10)*10), "fuckdollsTransfer")]]
			<<if $fuckdolls >= 100>>
				[[(x100)|Buy Slaves][$fuckdolls-=100,$menialDemandFactor-=100,cashX((menialSlaveCost(-100)*100), "fuckdollsTransfer")]]
			<</if>>
		<</if>>
		[[(all)|Buy Slaves][cashX($fuckdolls*(menialSlaveCost(-$fuckdolls)), "fuckdollsTransfer"),$menialDemandFactor-=$fuckdolls,$fuckdolls = 0]]
		<</if>>
	<</if>>

	<<if $menialBioreactors > 1>>
		You own <<print num(Math.trunc($menialBioreactors))>> standard bioreactors.
	<<elseif $menialBioreactors > 0>>
		You own one standard bioreactor.
	<<elseif $arcologies[0].FSPaternalist == "unset">>
		You do not own any standard bioreactors.
	<</if>>
	<<if ($menialBioreactors > 0) || ($arcologies[0].FSPaternalist == "unset")>>
		The market price of standard bioreactors is <<print cashFormat((_menialPrice-100))>>.
		<<set _optionsBreak = 0>>
		<<if _bulkMax > 0>>
			<<if $arcologies[0].FSPaternalist == "unset" && $cash > _menialPrice+100>>
				[[Buy|Buy Slaves][$menialBioreactors+=1,$menialSupplyFactor-=1,cashX(forceNeg(_menialPrice+100), "menialBioreactors")]]
				<<if $cash > (menialSlaveCost(10)-100)*10>>
					[[(x10)|Buy Slaves][$menialBioreactors+=10,$menialSupplyFactor-=10,cashX(forceNeg((menialSlaveCost(10)-100)*10), "menialBioreactors")]]
				<</if>>
				<<if $cash > (menialSlaveCost(100)-100)*100>>
					[[(x100)|Buy Slaves][$menialBioreactors+=100,$menialSupplyFactor-=100,cashX(forceNeg((menialSlaveCost(100)-100)*100), "menialBioreactors")]]
				<</if>>
				<<if $cash > (_menialPrice-99)*2>>
					<<set _bioreactorBulkPremium = Math.trunc(1+ Math.clamp($cash/(_menialPrice-99),0,_bulkMax)/400)>>
					[[(max)|Buy Slaves][$menialBioreactors+=Math.trunc(Math.clamp($cash/(_menialPrice-99+_bioreactorBulkPremium),0,_bulkMax)),$menialSupplyFactor-=Math.trunc(Math.clamp($cash/(_menialPrice-99+_bioreactorBulkPremium),0,_bulkMax)),cashX(forceNeg(Math.trunc(Math.clamp($cash/(_menialPrice-99+_bioreactorBulkPremium),0,_bulkMax))*(_menialPrice-99+_bioreactorBulkPremium)), "menialBioreactors")]]
				<</if>>
				//Bulk transactions may require offering a premium.//
				<<set _optionsBreak = 1>>
			<</if>>
		<</if>>
		<<if $menialBioreactors >= 1>>
			<<if _optionsBreak>>|<</if>>
			[[Sell|Buy Slaves][$menialBioreactors-=1,$menialDemandFactor-=1,cashX((_menialPrice-100), "menialBioreactors")]]
			<<if $menialBioreactors >= 10>>
				[[(x10)|Buy Slaves][$menialBioreactors-=10,$menialDemandFactor-=10,cashX(((menialSlaveCost(-10)-100)*10), "menialBioreactors")]]
				<<if $menialBioreactors >= 100>>
					[[(x100)|Buy Slaves][$menialBioreactors-=100,$menialDemandFactor-=100,cashX(((menialSlaveCost(-100)-100)*100), "menialBioreactors")]]
				<</if>>
			<</if>>
			[[(all)|Buy Slaves][cashX(($menialBioreactors*(menialSlaveCost(-$menialBioreactors)-100)), "menialBioreactors"),$menialDemandFactor-=$menialBioreactors,$menialBioreactors = 0]]
		<</if>>
	<</if>>


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

<<set $nextButton = "Back to Main", $nextLink = "Main", $returnTo = "Cellblock", $encyclopedia = "Cellblock", _CL = App.Entity.facilities.cellblock.employeesIDs().size>>

<<if $cellblockName != "the Cellblock">>
	<<set $cellblockNameCaps = $cellblockName.replace("the ", "The ")>>
<</if>>

	$cellblockNameCaps
	<<switch $cellblockDecoration>>
		<<case "Roman Revivalist">>
			is designed to resemble the holding pens beneath the old Coliseum. Whenever there's a fight in the arcology, screens in each cell helpfully keep inmates informed of what awaits (otherwise) useless slaves.
		<<case "Aztec Revivalist">>
			is designed to frighten the prisoners to submission. All the cells look to the center of the facility, where a sacrificial altar stands, adorned with ceremonial <<if $arcologies[0].FSPaternalist != "unset">>ropes and penetrators<<else>>knives, ropes and blunt instruments<</if>>.
		<<case "Egyptian Revivalist">>
			uses the climate of Egypt as an additional source of discomfort. The air here is hot and dry, and inmates can easily imagine themselves confined in mud brick cells in a baking desert.
		<<case "Edo Revivalist">>
			is furnished in a severely medieval Japanese style. There is one refinement, but it's of exquisite cruelty. At the end of the hall, there's a fountain with a traditional bamboo boar scarer. As it fills with water, it tips against a stone with a thunk... thunk... thunk... thunk...
		<<case "Arabian Revivalist">>
			is furnished as imagined Arabian slave pens, all set around a central pillar. This pillar is capped by shackles, so that slaves can be bound by their hands and whipped on the backs, buttocks, and thighs in clear view of all their fellow chattel.
		<<case "Chinese Revivalist">>
			is furnished in a severely medieval Chinese style. There is one refinement, but it's of exquisite cruelty. Somewhere out of sight, water is dripping into an urn, drop by drop... drop... drop... drop...
		<<case "Chattel Religionist">>
			is built of cold stone. Most of the cells are unfurnished little cubes inside which the only bed is the bare floor. A few are smaller still, so that the inmates can neither stand nor lie flat.
		<<case "Degradationist">>
			is a nightmare. Everything is made of metal, and almost everything menaces with spikes of steel. Inmates must carefully avoid the walls of their own cells if they wish to avoid being stabbed.
		<<case "Asset Expansionist">>
			is a straightforward prison, with one exception. Each cell features a screen displaying plans for its inmate's expansion. Day and night, inmates are confronted with the sight of themselves transformed.
		<<case "Transformation Fetishist">>
			is a straightforward prison, with one exception. Each cell features a screen displaying plans for its inmate's expansion. Day and night, inmates are confronted with the sight of themselves transformed.
		<<case "Gender Radicalist">>
			is a straightforward prison, with one exception. Each cell features a screen displaying plans for its inmate's bimbofication. Day and night, inmates are confronted with the sight of themselves dyed, pierced, tattooed, gaped, filled with implants, or all of these.
		<<case "Gender Fundamentalist">>
			is a block of barred cells whose sides, offering a clear view of the whole prison, provide much menace. Anyone who abuses an inmate does so in full view of every other slave here, keeping the jailbirds in a state of constant fear that they're next.
		<<case "Physical Idealist">>
			is a block of barred cells whose sides, offering a clear view of the whole prison, provide much menace. Anyone who rapes an inmate does so in full view of every other slave here, keeping the bitches in a state of constant fear that their asses are next.
		<<case "Supremacist">>
			is a straightforward prison whose menace is provided by context that, although subtle, adds up to a nightmare. Everyone outside the cells is $arcologies[0].FSSupremacistRace, and everyone inside them is not. The darkness of history is palpable here.
		<<case "Subjugationist">>
			is a straightforward prison whose menace is provided by context that, although subtle, adds up to a nightmare. The inmates inside the cells are $arcologies[0].FSSubjugationistRace, and everyone outside them is not. The darkness of history is palpable here.
		<<case "Repopulation Focus">>
			is a straightforward prison, with two exceptions. One cell style features a screen displaying plans for its inmate's impregnation, the other is covered with mirrors for its inmate to watch her pregnancy grow. Day and night, inmates are confronted with the sight of themselves transformed.
		<<case "Eugenics">>
			is designed to make very clear to its inmates that they are subhuman. Many screens showcasing their inadequacy intermingled with propaganda play on nonstop loops.
		<<case "Paternalist">>
			is a prison, but a modern and scientific one. The cells, the common areas, and even the color of the walls are all carefully designed to communicate the feeling that inmates can better themselves.
		<<case "Pastoralist">>
			requires its inmates to drink as much breast milk as they can hold. This sounds like a small thing, but for an unbroken slave, conquering the revulsion of drinking another slave's milk is an important step.
		<<case "Maturity Preferentialist">>
			is subtly designed to make very clear to its inmates that they are sex objects. Many screens showing pornography make it clear to the maturest slave here that they're still an object of lust, and will be used to slake others' pleasure.
		<<case "Youth Preferentialist">>
			is subtly designed to make the breadth of sex acts performed in the arcology clear to its inmates. A cacophony of pornography makes clear to the most innocent inmate that <<if $seeDicks != 100>>her pussy is a fuck hole, <</if>>her mouth is a fuck hole, her anus is a fuck hole, and, in fact, <<if $seeDicks != 100>>all three<<else>>both<</if>> can be fuck holes at once.
		<<case "Body Purist">>
			requires its inmates to drink as much filtered water as they can, all the time. This sounds like a petty thing, but most inmates are very aware that they're being flushed out. Cleaned. It is an oddly menacing thought.
		<<case "Slimness Enthusiast">>
			is torture for chubby slaves. Fat bitches that pass through here soon learn that they're going to be slim and pretty one day, but that it isn't going to be much fun getting there.
		<<case "Hedonistic">>
			is torture for thin slaves. The first thing they notice is the heavily reinforced cot they will reside upon. The second is the feeding tube that will be anchored in their stomach for the duration of their stay. Slaves imprisoned here will have their body stuffed to capacity with concentrated slave food, ensuring a plump, docile slave by the end of their sentence.
		<<case "Intellectual Dependency">>
			is a straightforward prison, with one exception. Each cell comes equipped with sound dampening shutters so slaves may be cut off from all outside stimulation. They are forced to be alone with their thoughts for most of their stay.
		<<case "Slave Professionalism">>
			is torture for dumb slaves. Everything in the cell is a puzzle, from the food dispenser to the cot cover. Slaves are frequently rotated so that they may never become accustomed to any solutions.
		<<case "Petite Admiration">>
			is designed to make tall slaves know they are unwelcome. What amounts a basic prison for a short slave is positively torturous when one is far too large to even move in it.
		<<case "Statuesque Glorification">>
			is designed to make short slaves know they are unwelcome. Where a tall slave will find nothing more than a standard cell, the vertically challenged while will find an insurmountable trial designed to teach them their place.
		<<default>>
			could be mistaken for a modern prison. A close inspection, however, reveals restraints in each cell that will hold inmates in sexually compromising positions, and compliance systems to force them to place their wrists and ankles in them.
	<</switch>>

	<<if _CL > 2>>
		$cellblockNameCaps is full of slaves, though it's difficult to tell at first. In many of the cells, a scene of loneliness and misery may be witnessed, but not one sound escapes them in fear of the punishment that would follow.
	<<elseif _CL > 0>>
		$cellblockNameCaps holds a few slaves, though it's difficult to tell at first. In several of the cells, a scene of loneliness and misery may be witnessed, but not one sound escapes them in fear of the punishment that would follow.
	<<elseif $Wardeness != 0>>
		$Wardeness.slaveName is alone in the cellblock, and seems rather lonely without anyone to oppress.
	<<else>>
		None of your slaves are confined in the cellblock.

			[[Decommission the cellblock|Main][$cellblock = 0, $cellblockDecoration = "standard", $cellblockUpgrade = 0]]

	<</if>>

<<if _CL > 0>>
	<<removeFacilityWorkers "cellblock" "rest" "stay confined">>
<</if>>

	<<set _Tmult0 = Math.trunc($cellblock*1000*$upgradeMultiplierArcology)>>
	$cellblockNameCaps has room for $cellblock slaves to be kept in close confinement.
	There <<if _CL == 1>>is<<else>>are<</if>> currently _CL slaves<<if _CL != 1>>s<</if>> kept in close confinement in $cellblockName.

		[[Expand the cellblock|Cellblock][cashX(forceNeg(_Tmult0), "capEx"), $cellblock += 5, $PC.skill.engineering += .1]]

			Costs <<print cashFormat(_Tmult0)>>

	<<if $cellblockUpgrade == 1>>
		Its compliance systems have been upgraded to allow slaves no mental respite, painstakingly correcting the tiniest misbehaviors to soften flaws into quirks at the cost of considerable anguish to inmates denied any rest from correction.
	<<else>>
		<<set _Tmult1 = Math.trunc(20000*$upgradeMultiplierArcology*$HackingSkillMultiplier)>>
		Its compliance systems are standard.

			[[Upgrade them to soften slave flaws|Cellblock][cashX(forceNeg(_Tmult1), "capEx"), $cellblockUpgrade = 1, $PC.skill.engineering += 0.1, $PC.skill.hacking += 0.1]]

				Costs <<print cashFormat(_Tmult1)>>

	<</if>>

	<<if $Wardeness != 0 && canPenetrate($Wardeness)>>
		<<setLocalPronouns $Wardeness>>
		<<if $cellblockWardenCumsInside == 1>>
			$Wardeness.slaveName is permitted to cum inside $his inmates when $he disciplines them.

				<<link "Forbid $him from cumming inside" "Cellblock">>
					<<set $cellblockWardenCumsInside = 0>>
				<</link>>

		<<else>>
			$Wardeness.slaveName is not permitted to cum inside $his inmates.

				<<link "Let $him cum inside" "Cellblock">>
					<<set $cellblockWardenCumsInside = 1>>
				<</link>>

					May result in pregnancies

		<</if>>
	<</if>>

	<<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.cellblock)>>

	Rename $cellblockName: <<textbox "$cellblockName" $cellblockName "Cellblock">>

		Use a noun or similar short phrase

<<run App.UI.SlaveList.ScrollPosition.restore()>>


code:
:: Cellblock Report [nobr]

<<set _slaves = App.Utils.sortedEmployees(App.Entity.facilities.cellblock)>>
<<set _DL = _slaves.length, _SL = $slaves.length, _brokenSlaves = 0, _idleBonus = 0, _softenedQuirks = 0, _trustMalus = 0, _FLsFetish = 0>>

<<if $cellblockDecoration != "standard">>
	<<set _devBonus = 1>>
<<else>>
	<<set _devBonus = 0>>
<</if>>

<<if ($Wardeness != 0)>>
	<<set _FLs = $slaveIndices[$Wardeness.ID]>>
	<<setLocalPronouns $Wardeness>>

	<<if ($slaves[_FLs].health.condition < -80)>>
		<<run improveCondition($slaves[_FLs], 20)>>
	<<elseif ($slaves[_FLs].health.condition < -40)>>
		<<run improveCondition($slaves[_FLs], 15)>>
	<<elseif ($slaves[_FLs].health.condition < 0)>>
		<<run improveCondition($slaves[_FLs], 10)>>
	<<elseif ($slaves[_FLs].health.condition < 90)>>
		<<run improveCondition($slaves[_FLs], 7)>>
	<</if>>
	<<if ($slaves[_FLs].devotion <= 60)>>
		<<set $slaves[_FLs].devotion += 2>>
	<</if>>
	<<set $slaves[_FLs].devotion += _devBonus>>
	<<if $slaves[_FLs].trust < 60>>
		<<set $slaves[_FLs].trust += 3>>
	<</if>>
	<<if ($slaves[_FLs].rules.living != "luxurious")>>
		<<set $slaves[_FLs].rules.living = "luxurious">>
	<</if>>
	<<if $slaves[_FLs].fetishStrength <= 95>>
		<<if $slaves[_FLs].fetish != "sadist">>
			<<if fetishChangeChance($slaves[_FLs]) > random(0,100)>>
				<<set _FLsFetish = 1, $slaves[_FLs].fetishKnown = 1, $slaves[_FLs].fetish = "sadist">>
			<</if>>
		<<elseif $slaves[_FLs].fetishKnown == 0>>
			<<set _FLsFetish = 1, $slaves[_FLs].fetishKnown = 1>>
		<<else>>
			<<set _FLsFetish = 2, $slaves[_FLs].fetishStrength += 4>>
		<</if>>
	<</if>>
	<<set $Wardeness = $slaves[_FLs]>>
	<<if ($Wardeness.energy > 95) || ($Wardeness.fetish == "sadist")>>
		<<set _devBonus++, _trustMalus++, _idleBonus++>>
	<</if>>
	    <<= SlaveFullName($Wardeness)>> is serving as the Wardeness.
	<<if $Wardeness.relationship == -3 && $Wardeness.devotion > 50>>
		<<set _devBonus++, _trustMalus++, _idleBonus++>>
		As your $wife, $he tries $his best to break the disobedient slaves to your will.
	<</if>>
	<<if (_FLsFetish == 1)>>
		One day $he demands obedience. The next day $he strikes a slave when it isn't given. The next, $he seems more excited than embarrassed when beating a prisoner. Soon, $he's looking for an excuse to punish. $He's @@.pink;become more of a sadist.@@
	<<elseif (_FLsFetish == 2)>>
		Being not only allowed but encouraged to get off while punishing prisoners @@.lightsalmon;deepens $his sadism.@@
	<</if>>
	<<if setup.wardenessCareers.includes($Wardeness.career)>>
		<<set _devBonus++, _trustMalus++, _idleBonus++>>
		$He has experience with detecting security issues and grinding down potential miscreants from $his life before $he was a slave, making $him more effective.
	<<elseif $Wardeness.skill.wardeness >= $masteredXP>>
		<<set _devBonus++, _trustMalus++, _idleBonus++>>
		$He has experience with detecting security issues and grinding down potential miscreants from working for you, making $him more effective.
	<<else>>
		<<set $slaves[_FLs].skill.wardeness += random(1,Math.ceil(($Wardeness.intelligence+$Wardeness.intelligenceImplant)/15) + 8)>>
	<</if>>
	<<if $Wardeness.fetish == "sadist">>
		$He uses the prisoners to gratify $his sadism, terrifying them and quickly breaking their resistance.
	<<elseif $Wardeness.energy > 95>>
		$He is so sexually depraved that $he constantly molests the prisoners, breaking them to a life of servitude.
	<</if>>
	<<if $Wardeness.sexualFlaw == "malicious" || $Wardeness.sexualFlaw == "abusive">>
		<<set _devBonus++, _trustMalus += 2, _idleBonus += 2>>
		Sexual abuse of prisoners has become an end for $him, not a means. $He inspires $his prisoners to do everything possible to qualify to get away from $him, even as $he slowly grinds away their interest in sex to do it.
	<<elseif $Wardeness.sexualQuirk == "caring">>
		<<set _devBonus--, _trustMalus--, _idleBonus-->>
		$His kindness sometimes shows through $his tough facade, letting prisoners get off easier than they should.
	<</if>>
	<<if ($Wardeness.dick > 2) && (canPenetrate($Wardeness))>>
		<<set _devBonus++, _trustMalus++, _idleBonus++>>
		$His molestation of the prisoners is more varied and effective because $he has a dick to fuck them with.
	<</if>>
	<<if ($Wardeness.muscles > 35)>>
		<<set _devBonus++, _trustMalus++, _idleBonus++>>
		$He is strong enough to restrain anyone that tries anything with $his own hands.
	<</if>>
	<<if ($Wardeness.devotion > 95)>>
		<<set _devBonus++, _trustMalus++, _idleBonus++>>
		$His devotion to you is so absolute that $he sees breaking bitches for your service as a noble calling.
	<</if>>
	<<for _slave range _slaves>>
		<<if $Wardeness.rivalryTarget == _slave.ID>>
			$He greatly enjoys breaking $his <<print rivalryTerm($Wardeness)>>, _slave.slaveName's will.
			<<set _slave.devotion++, _slave.trust -= 3>>
			<<if random(1,100) > 30>>
				<<set $Wardeness.rivalry++, $slaves[_FLs].rivalry++, _slave.rivalry++>>
			<</if>>
		<<elseif $Wardeness.relationshipTarget == _slave.ID>>
			$He hates having to break $his <<print relationshipTerm($Wardeness)>>, _slave.slaveName, but $his devotion to you wins out in the end.
			<<set _slave.devotion++, _slave.trust -= 3>>
			<<if random(1,100) >= 50>>
				$His and _slave.slaveName's relationship has been shattered by these events.
				<<set $Wardeness.relationship = 0, $Wardeness.relationshipTarget = 0, $slaves[_FLs].relationship = 0, $slaves[_FLs].relationshipTarget = 0, _slave.relationship = 0, _slave.relationshipTarget = 0>>
			<</if>>
		<<elseif areRelated($Wardeness, _slave)>>
			<<setLocalPronouns _slave 2>>
			$He shows $his <<print relativeTerm($Wardeness,_slave)>> _slave.slaveName no mercy, making sure _he2 understands _his2 place.
			<<set _slave.devotion++, _slave.trust-->>
		<</if>>
	<</for>>
	<<if (_DL < $cellblock)>>
		<<set _seed = random(1,10)+(($cellblock-_DL)*(random(150,170)+(_idleBonus*10)))>>
		<<run cashX(_seed, "cellblock", $Wardeness)>>

    Since $he doesn't have enough prisoners to manage to keep $him busy, $he works on citizens' slaves, earning @@.yellowgreen;<<print cashFormat(_seed)>>.@@
	<</if>>
	<<if (_DL > 0)>>

<</if>>
<</if>>

<<if (_DL > 0)>>
	    <<if (_DL == 1)>>''One slave is being confined in $cellblockName until they are willing to obey.''<<else>>''_DL slaves are being confined in $cellblockName until they are willing to obey.''<</if>>
<</if>>

<<if ($Wardeness != 0)>>
	<<set $i = _FLs>> /* apply following SA passages to facility leader */
	<<if $showEWD != 0>>

		/* 000-250-006 */
		<<if $seeImages && $seeReportImages>>

			<<= SlaveArt($slaves[_FLs], 0, 0)>>

		<</if>>
		/* 000-250-006 */
		<<= SlaveFullName($slaves[$i])>> is serving as the Wardeness in $cellblockName.

		<<= App.SlaveAssignment.choosesOwnClothes($slaves[$i])>>
		<<run tired($slaves[$i])>>
		<<include "SA rules">>
		<<include "SA diet">>
		<<include "SA long term effects">>
		<<= App.SlaveAssignment.drugs($slaves[$i])>>
		<<include "SA relationships">>
		<<include "SA rivalries">>

<<include "SA devotion">>
	<<else>>
		<<silently>>
		<<run App.SlaveAssignment.choosesOwnClothes($slaves[$i])>>
		<<run tired($slaves[$i])>>
		<<include "SA rules">>
		<<include "SA diet">>
		<<include "SA long term effects">>
		<<run App.SlaveAssignment.drugs($slaves[$i])>>
		<<include "SA relationships">>
		<<include "SA rivalries">>
		<<include "SA devotion">>
		<</silently>>
	<</if>>
	<<set $Wardeness = $slaves[_FLs]>>
<</if>>

<<for _slave range _slaves>>
	<<set $i = $slaveIndices[_slave.ID]>>
	<<setLocalPronouns _slave>>
	<<if (_slave.devotion <= 20)>>
		<<if (_slave.trust >= -20)>>
			<<if ((_slave.hears == -1 && _slave.earwear != "hearing aids") || (_slave.hears == 0 && _slave.earwear == "muffling ear plugs") ||(_slave.hears == -2))>>
				<<set _slave.devotion -= 2, _slave.trust -= 2>>
			<<else>>
				<<set _slave.devotion -= 4, _slave.trust -= 4>>
			<</if>>
		<<else>>
			<<set _slave.devotion++>>
		<</if>>
	<</if>>
	<<switch $cellblockDecoration>>
	<<case "Paternalist">>
		<<set _slave.rules.living = "normal">>
		<<if (_slave.inflation > 0)>>
			<<set _slave.inflation = 0, _slave.inflationType = "none", _slave.inflationMethod = 0, _slave.milkSource = 0>>
			<<run SetBellySize(_slave)>>
		<</if>>
	<<case "Pastoralist">>
		<<set _slave.rules.living = "spare">>
		<<if _slave.inflation == 0>>
			<<if _slave.pregKnown == 0 && _slave.bellyImplant < 1500>>
				<<set _slave.inflation = 2, _slave.inflationType = "milk", _slave.inflationMethod = 1>>
			<<else>>
				<<set _slave.inflation = 1, _slave.inflationType = "milk", _slave.inflationMethod = 1>>
			<</if>>
			<<run SetBellySize(_slave)>>
		<</if>>
	<<case "Hedonistic">>
		<<set _slave.rules.living = "spare">>
		<<if _slave.weight < 200>>
			<<if _slave.weightDirection == 1>>
				<<set _slave.weight += 5>>
			<<elseif _slave.weightDirection == -1>>
				<<set _slave.weight += 1>>
			<<else>>
				<<set _slave.weight += 3>>
			<</if>>
		<</if>>
		<<if _slave.muscles > -100>>
			<<set _slave.muscles -= 2>>
		<</if>>
		<<if _slave.inflation == 0>>
			<<if _slave.pregKnown == 0 && _slave.bellyImplant < 1500>>
				<<set _slave.inflation = 3, _slave.inflationType = "food", _slave.inflationMethod = 1>>
			<<else>>
				<<set _slave.inflation = 1, _slave.inflationType = "food", _slave.inflationMethod = 1>>
			<</if>>
			<<run SetBellySize(_slave)>>
		<</if>>
	<<default>>
		<<set _slave.rules.living = "spare">>
		<<if (_slave.inflation > 0)>>
			<<set _slave.inflation = 0, _slave.inflationType = "none", _slave.inflationMethod = 0, _slave.milkSource = 0>>
			<<run SetBellySize(_slave)>>
		<</if>>
	<</switch>>
	<<if $cellblockUpgrade == 1>>
		<<if (_slave.behavioralFlaw != "none") && (_slave.behavioralQuirk == "none")>>
			<<run SoftenBehavioralFlaw(_slave)>>
			<<set _slave.devotion -= 10, _softenedQuirks++>>
		<<elseif (_slave.sexualFlaw != "none") && (_slave.sexualQuirk == "none")>>
			<<run SoftenSexualFlaw(_slave)>>
			<<set _slave.devotion -= 10, _softenedQuirks++>>
		<</if>>
	<</if>>
	<<set _slave.devotion += _devBonus, _slave.trust -= _trustMalus>>
	<<if ($Wardeness != 0) && ($Wardeness.sexualFlaw == "malicious") && (_slave.energy >= 2)>>
		<<set _slave.energy -= 2>>
	<</if>>
	<<if (_slave.health.condition < -80)>>
		<<run improveCondition(_slave, 20)>>
	<<elseif (_slave.health.condition < -40)>>
		<<run improveCondition(_slave, 15)>>
	<<elseif (_slave.health.condition < 0)>>
		<<run improveCondition(_slave, 10)>>
	<<elseif (_slave.health.condition < 40)>>
		<<run improveCondition(_slave, 7)>>
	<<elseif (_slave.health.condition < 100)>>
		<<run improveCondition(_slave, 3)>>
	<</if>>
	<<if $showEWD != 0>>

		/* 000-250-006 */
		<<if $seeImages && $seeReportImages>>

			<<= SlaveArt(_slave, 0, 0)>>

		<</if>>
		/* 000-250-006 */
		<<= SlaveFullName(_slave)>>
		<<if _slave.choosesOwnAssignment == 2>>
			<<include "SA chooses own job">>
		<<else>>
			is confined in $cellblockName.
		<</if>>

    $He <<= App.SlaveAssignment.stayConfined(_slave)>>

		<<include "SA rules">>
		<<include "SA diet">>
		<<include "SA long term effects">>
		<<= App.SlaveAssignment.drugs(_slave)>>
		<<include "SA relationships">>
		<<include "SA rivalries">>

<<include "SA devotion">>
	<<else>>
		<<silently>>
		<<include "SA chooses own job">>
		<<run App.SlaveAssignment.stayConfined(_slave)>>
		<<include "SA rules">>
		<<include "SA diet">>
		<<include "SA long term effects">>
		<<run App.SlaveAssignment.drugs(_slave)>>
		<<include "SA relationships">>
		<<include "SA rivalries">>
		<<include "SA devotion">>
		<</silently>>
	<</if>>
<</for>>
<<if (_softenedQuirks) || (_brokenSlaves)>>

	<<if (_softenedQuirks > 0)>>
		$cellblockNameCaps's advanced compliance systems successfully softened
		<<if (_softenedQuirks == 1)>>
			one slave's mental flaw into an @@.green;appealing quirk,@@ though the constant correction caused them @@.mediumorchid;considerable anguish.@@
		<<else>>
			_softenedQuirks slaves' mental flaws into @@.green;appealing quirks,@@ though the constant correction caused them @@.mediumorchid;considerable anguish.@@
		<</if>>
	<</if>>
	<<if (_brokenSlaves > 0)>>
		<<if (_brokenSlaves == 1)>>
			One slave is now willing to @@.hotpink;do as they're told@@ and has been released.
		<<else>>
			_brokenSlaves slaves are now willing to @@.hotpink;do as they're told@@ and have been released.
		<</if>>
		<<if $cellblockDecoration != "standard">>

    $cellblockNameCaps's $cellblockDecoration atmosphere @@.hotpink;had an impact on them while they were@@ imprisoned.
		<</if>>
	<</if>>
<</if>>
<<if _DL > 0 || $Wardeness != 0>>

<</if>>


code:
:: Change Language [nobr jump-from-safe]

<<set $nextButton = "Confirm changes">>
<<set $nextLink = "Main">>

<<set $revivalistLanguage = 0>>
<<if $arcologies[0].FSRomanRevivalist != "unset">>
	<<if $language != "Latin">>
		<<set $revivalistLanguage = "Latin">>
	<</if>>
<<elseif $arcologies[0].FSAztecRevivalist != "unset">>
	<<if $language != "Nahuatl">>
		<<set $revivalistLanguage = "Nahuatl">>
	<</if>>
<<elseif $arcologies[0].FSEgyptianRevivalist != "unset">>
	<<if $language != "Ancient Egyptian">>
		<<set $revivalistLanguage = "Ancient Egyptian">>
	<</if>>
<<elseif $arcologies[0].FSEdoRevivalist != "unset">>
	<<if $language != "Japanese">>
		<<set $revivalistLanguage = "Japanese">>
	<</if>>
<<elseif $arcologies[0].FSArabianRevivalist != "unset">>
	<<if $language != "Arabic">>
		<<set $revivalistLanguage = "Arabic">>
	<</if>>
<<elseif $arcologies[0].FSChineseRevivalist != "unset">>
	<<if $language != "Chinese">>
		<<set $revivalistLanguage = "Chinese">>
	<</if>>
<</if>>

The lingua franca of the arcology is ''$language''.

//Changing the lingua franca of the arcology is a difficult process. Doing so will slightly reduce the arcology's prosperity due to the difficulty changing languages will impose on businesses. It will also cost <<print cashFormat(500)>> for each mentally competent slave you own, since it will be necessary to build time into their schedules for them to learn basic commands in the new language. Slaves' starting fluency in the new language will depend on their intelligence, nationality, education, and in some cases, ethnicity. Previous linguistic experience will not be saved, meaning that repeated language changes will wipe out slaves' previous language skills.//

Select a custom language to be applied: <<textbox "$seed" $seed "Change Language">> //A single capitalized word is recommended.//

<<if $language != "English">>

<<link "English">>
	<<replace "#result">>
	<<set $language = "English">>
	<<set $arcologies[0].prosperity = Math.trunc(0.9*$arcologies[0].prosperity)>>
	<<for _cl = 0; _cl < $slaves.length; _cl++>>
		<<if $slaves[_cl].fetish != "mindbroken">>
			<<run nationalityToAccent($slaves[_cl])>>
			<<if ($slaves[_cl].accent >= 3)>>
				<<if ($slaves[_cl].intelligence+$slaves[_cl].intelligenceImplant+100) > random(0,100)>>
					<<set $slaves[_cl].accent -= 1>>
				<</if>>
			<</if>>
			<<run cashX(-500, "capEx")>>
		<</if>>
	<</for>>

//Language changed.//
	<</replace>>
	<</link>>
<</if>>
<<if $language != "Spanish">>

<<link "Spanish">>
	<<replace "#result">>
	<<set $language = "Spanish">>
	<<set $arcologies[0].prosperity = Math.trunc(0.9*$arcologies[0].prosperity)>>
	<<for _cl = 0; _cl < $slaves.length; _cl++>>
		<<if $slaves[_cl].fetish != "mindbroken">>
			<<run nationalityToAccent($slaves[_cl])>>
			<<if ($slaves[_cl].accent >= 3)>>
				<<if ($slaves[_cl].intelligence+$slaves[_cl].intelligenceImplant+100) > random(0,100)>>
					<<set $slaves[_cl].accent -= 1>>
				<</if>>
			<</if>>
			<<run cashX(-500, "capEx")>>
		<</if>>
	<</for>>

//Language changed.//
	<</replace>>
	<</link>>
<</if>>
<<if $language != "Portuguese">>

<<link "Portuguese">>
	<<replace "#result">>
	<<set $language = "Portuguese">>
	<<set $arcologies[0].prosperity = Math.trunc(0.9*$arcologies[0].prosperity)>>
	<<for _cl = 0; _cl < $slaves.length; _cl++>>
		<<if $slaves[_cl].fetish != "mindbroken">>
			<<run nationalityToAccent($slaves[_cl])>>
			<<if ($slaves[_cl].accent >= 3)>>
				<<if ($slaves[_cl].intelligence+$slaves[_cl].intelligenceImplant+100) > random(0,100)>>
					<<set $slaves[_cl].accent -= 1>>
				<</if>>
			<</if>>
			<<run cashX(-500, "capEx")>>
		<</if>>
	<</for>>

//Language changed.//
	<</replace>>
	<</link>>
<</if>>
<<if $language != "Arabic">>

<<link "Arabic">>
	<<replace "#result">>
	<<set $language = "Arabic">>
	<<set $arcologies[0].prosperity = Math.trunc(0.9*$arcologies[0].prosperity)>>
	<<for _cl = 0; _cl < $slaves.length; _cl++>>
		<<if $slaves[_cl].fetish != "mindbroken">>
			<<run nationalityToAccent($slaves[_cl])>>
			<<if ($slaves[_cl].accent >= 3)>>
				<<if ($slaves[_cl].intelligence+$slaves[_cl].intelligenceImplant+100) > random(0,100)>>
					<<set $slaves[_cl].accent -= 1>>
				<</if>>
			<</if>>
			<<run cashX(-500, "capEx")>>
		<</if>>
	<</for>>

//Language changed.//
	<</replace>>
	<</link>>
<</if>>
<<if $language != "Chinese">>

<<link "Chinese">>
	<<replace "#result">>
	<<set $language = "Chinese">>
	<<set $arcologies[0].prosperity = Math.trunc(0.9*$arcologies[0].prosperity)>>
	<<for _cl = 0; _cl < $slaves.length; _cl++>>
		<<if $slaves[_cl].fetish != "mindbroken">>
			<<run nationalityToAccent($slaves[_cl])>>
			<<if ($slaves[_cl].accent >= 3)>>
				<<if ($slaves[_cl].intelligence+$slaves[_cl].intelligenceImplant+100) > random(0,100)>>
					<<set $slaves[_cl].accent -= 1>>
				<</if>>
			<</if>>
			<<run cashX(-500, "capEx")>>
		<</if>>
	<</for>>

//Language changed.//
	<</replace>>
	<</link>>
<</if>>
<<if $language != $seed>>

<<link "Apply custom language">>
	<<replace "#result">>
	<<set $language = $seed>>
	<<set $arcologies[0].prosperity = Math.trunc(0.9*$arcologies[0].prosperity)>>
	<<for _cl = 0; _cl < $slaves.length; _cl++>>
		<<if $slaves[_cl].fetish != "mindbroken">>
			<<run nationalityToAccent($slaves[_cl])>>
			<<if ($slaves[_cl].accent >= 3)>>
				<<if ($slaves[_cl].intelligence+$slaves[_cl].intelligenceImplant+100) > random(0,100)>>
					<<set $slaves[_cl].accent -= 1>>
				<</if>>
			<</if>>
			<<run cashX(-500, "capEx")>>
		<</if>>
	<</for>>

//Language changed.//
	<</replace>>
	<</link>>
<</if>>
<<if $revivalistLanguage != 0>>

<<link "Match language to Revivalist future society">>
	<<replace "#result">>
	<<set $language = $revivalistLanguage>>
	<<set $arcologies[0].prosperity = Math.trunc(0.9*$arcologies[0].prosperity)>>
	<<for _cl = 0; _cl < $slaves.length; _cl++>>
		<<if $slaves[_cl].fetish != "mindbroken">>
			<<run nationalityToAccent($slaves[_cl])>>
			<<if ($slaves[_cl].accent >= 3)>>
				<<if ($slaves[_cl].intelligence+$slaves[_cl].intelligenceImplant+100) > random(0,100)>>
					<<set $slaves[_cl].accent -= 1>>
				<</if>>
			<</if>>
			<<run cashX(-500, "capEx")>>
		<</if>>
	<</for>>

//Language changed.//
	<</replace>>
	<</link>> //Failing to take this step will retard adoption of Revivalism//
<</if>>


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

<<set $nextButton = "Back to Main", $nextLink = "Main", $returnTo = "Clinic", $encyclopedia = "Clinic", _CL = App.Entity.facilities.clinic.employeesIDs().size>>

<<if $clinicName != "the Clinic">>
	<<set $clinicNameCaps = $clinicName.replace("the ", "The ")>>
<</if>>

	$clinicNameCaps
	<<switch $clinicDecoration>>
		<<case "Roman Revivalist">>
			is open and airy; a breeze wafts through the space, and Roman theories on natural cleanliness are very much on display.
		<<case "Aztec Revivalist">>
			is open and airy; a light hint of herbs and natural oil permeates the air. Everything is incredibly sterile, especially the blood management equipment.
		<<case "Egyptian Revivalist">>
			is open and airy; clean rushes are strewn across the floor, making a gentle susurration when anyone crosses the space.
		<<case "Edo Revivalist">>
			is clean and spartan to the point of featurelessness. Spotless tatami mats cover the floor, and partitions divide the space into cubicles.
		<<case "Arabian Revivalist">>
			is open and airy; a thin trail of smoke wafts through the space on a gentle breeze, coming from a brazier burning incense.
		<<case "Chinese Revivalist">>
			is open and airy; a thin trail of smoke wafts through the space on a gentle breeze, coming from a brazier burning medicinal herbs.
		<<case "Chattel Religionist">>
			is open and airy; shaded beams of sunlight shine through skylights to bathe each bed in a pool of healing warmth.
		<<case "Degradationist">>
			is clean and cold, all scrubbed tile and cool steel. The beds have prominent restraint attachment points to force patients into any position desired.
		<<case "Repopulation Focus">>
			is warm and inviting, with wide corridors and ample seating for its pregnant clientèle. All the equipment is designed to accommodate heavily pregnant women.
		<<case "Eugenics">>
			is warm and inviting on one side, cold and utilitarian on the other. Only the toys of the elite are allowed the best of care.
		<<case "Asset Expansionist">>
			is utilitarian, without any concession to style. Every available <<if $showInches == 2>>inch<<else>>centimeter<</if>> of space is used for equipment specialized to support growth.
		<<case "Transformation Fetishist">>
			is utilitarian, without any concession to style. Every available <<if $showInches == 2>>inch<<else>>centimeter<</if>> of space is used for equipment specialized to support radical surgery.
		<<case "Gender Radicalist">>
			is comfortable and feminine. Its curving walls and soft colors are designed to present slaves coming out of anesthesia with an impression of girlishness.
		<<case "Gender Fundamentalist">>
			is comfortable and feminine. Its curving walls and soft colors are designed to keep slaves here for their female health nice and comfortable.
		<<case "Physical Idealist">>
			is utilitarian, without any concession to style. Every available <<if $showInches == 2>>inch<<else>>centimeter<</if>> of space is used for some piece of equipment useful in making the human body faster or stronger.
		<<case "Supremacist">>
			is clean and cold, all scrubbed tile and cool steel. The only hint of its radical uses are the pseudoscientific racialist charts on the walls.
		<<case "Subjugationist">>
			is clean and cold, all scrubbed tile and cool steel. The only hint of its radical uses are the pseudoscientific racialist charts on the walls.
		<<case "Paternalist">>
			is warm and inviting, with curved walls and warm colors designed to put patients at their ease. Each bed is well provided with entertainment options.
		<<case "Pastoralist">>
			is utilitarian, without any concession to style. Every available <<if $showInches == 2>>inch<<else>>centimeter<</if>> of space is used for equipment specialized for human veterinary medicine.
		<<case "Maturity Preferentialist">>
			is comfortable and soothing, with curved walls and cool colors designed to keep patients relaxed. Each bed is provided with refined yet invariably pornographic entertainment options.
		<<case "Youth Preferentialist">>
			is bright and cheerful, with curved walls and pastel colors designed to keep patients in good spirits. Each bed is provided with light entertainment options.
		<<case "Body Purist">>
			is utilitarian, without any concession to style. Every available <<if $showInches == 2>>inch<<else>>centimeter<</if>> of space is filled with equipment designed to make medicine as low-impact as possible.
		<<case "Slimness Enthusiast">>
			is warm and inviting, with curved walls and warm colors designed to put patients at their ease. Each bed is well provided with entertainment options.
		<<case "Hedonistic">>
			is warm and comfortable, with extra wide, soft, heated beds and ample morphine. Pleasant smells are pumped into the recovery wards, plenty of entertainment is available and chubby nurse in a too small dress with a big bowl of slave food is only a button press away. It can be quite difficult to convince patients to leave.
		<<case "Intellectual Dependency">>
			is bright and cheerful, with plenty of simple amusements to keep bimbos distracted and in bed. A complex locking mechanism promises no chance of a slave wandering off to slake their lust.
		<<case "Slave Professionalism">>
			is clean and cold, all scrubbed tile and cool steel. Any delays in recovery are nothing more than time spent not honing one's talents.
		<<case "Petite Admiration">>
			is open and airy due to all the extra space freed up by shortening the beds. A footrest is the only accommodation made for tall slaves.
		<<case "Statuesque Glorification">>
			is warm and comfortable, if a little cramped; tall slaves require long beds, after all. A meager footstool is the only accommodation made for short slaves.
		<<default>>
			is a well-equipped modern medical facility. Each patient has their own area, with heavy automation to provide them treatment without any human intervention at all.
	<</switch>>

	<<if _CL > 2>>
		$clinicNameCaps is busy. Patients occupy many of the beds; most are alert, but a few are dozing under medication designed to promote healing through deep rest.
	<<elseif _CL > 0>>
		$clinicNameCaps is sparsely populated. Patients occupy a few of the beds; most are alert, but a few are dozing under medication designed to promote healing through deep rest.
	<<elseif $Nurse != 0>>
		$Nurse.slaveName is alone in the clinic, and has nothing to do but keep the place spotlessly clean and ready for its next patients.
	<<else>>
		$clinicNameCaps is empty and quiet.

			[[Decommission the Clinic|Main][$clinic = 0, $clinicDecoration = "standard", $clinicUpgradeScanner = 0, $clinicUpgradeFilters = 0, $clinicUpgradePurge = 0, $clinicInflateBelly = 0, $clinicSpeedGestation = 0]]

	<</if>>

	<<set _Tmult0 = Math.trunc($clinic*1000*$upgradeMultiplierArcology)>>
	$clinicNameCaps has room to support $clinic slaves while they receive treatment.
	There <<if _CL == 1>>is<<else>>are<</if>> currently _CL slave<<if _CL != 1>>s<</if>> receiving treatment in $clinicName.

		[[Expand the clinic|Clinic][cashX(forceNeg(_Tmult0), "capEx"), $clinic += 5, $PC.skill.engineering += .1]]

			Costs <<print cashFormat(_Tmult0)>>

		<<if _CL > 0>>
			<<removeFacilityWorkers "clinic" "rest" "rest">>
		<</if>>

	<<if $clinicUpgradeScanner == 1>>
		$clinicNameCaps's scanners have been upgraded with a sampling system that can estimate carcinogenic damage to a slave's body.
	<<else>>
		<<set _Tmult1 = Math.trunc(10000*$upgradeMultiplierArcology*Math.min($upgradeMultiplierMedicine, $HackingSkillMultiplier))>>
		It mounts powerful medical scanning technology.

			[[Upgrade the scanners to help detect genomic damage|Clinic][cashX(forceNeg(_Tmult1), "capEx"), $clinicUpgradeScanner = 1, $PC.skill.hacking += 0.1]]

				Costs <<print cashFormat(_Tmult1)>>

	<</if>>

	<<if $clinicUpgradeFilters == 1>>
		<<if $clinicUpgradePurge >= 1>>
			The entire floor beneath $clinicName is occupied by a huge filtration plant that constantly cycles out the patients' blood to remove impurities.
			<<if $clinicUpgradePurge > 1>>
				Microscopic magnets have been added to better facilitate the leeching of impurities from cells.
			<</if>>
			The blood is intensely cleaned to greatly decrease the presence of impurities at the cost of compatibility. Patients will likely be ill for the duration of the treatment.
		<</if>>
		<<set _Tmult3 = Math.trunc(150000*$upgradeMultiplierArcology*Math.min($upgradeMultiplierMedicine, $HackingSkillMultiplier))>>
		<<if $clinicUpgradePurge === 0>>
			The entire floor beneath $clinicName is occupied by a huge filtration plant that constantly cycles out the patients' blood to remove impurities.

				[[Increase the effectiveness of the impurity purging|Clinic][cashX(forceNeg(_Tmult3), "capEx"), $clinicUpgradePurge = 1, $PC.skill.hacking += 0.1]]

					Costs <<print cashFormat(_Tmult3)>> and may cause health problems in slaves.

		<<elseif $clinicUpgradePurge === 1>>
			Add nano magnets into the process to increase the rate that impurities are pulled from the body.

				[[Further increase the effectiveness of the impurity purging|Clinic][cashX(forceNeg(_Tmult3*2), "capEx"), $clinicUpgradePurge = 3, $PC.skill.hacking += 0.1]]

					Costs <<print cashFormat(_Tmult3*2)>>

		<</if>>
		<<if $Nurse == 0>>

				However, without a nurse in attendance, the @@.yellow;blood treatment equipment remains idle.@@

		<</if>>
	<<else>>
		<<set _Tmult2 = Math.trunc(50000*$upgradeMultiplierArcology*Math.min($upgradeMultiplierMedicine, $HackingSkillMultiplier))>>
		It includes standard dialysis equipment.

			[[Install advanced blood treatment equipment to help address drug side effects|Clinic][cashX(forceNeg(_Tmult2), "capEx"), $clinicUpgradeFilters = 1, $PC.skill.hacking += 0.1]]

				Costs <<print cashFormat(_Tmult2)>>

	<</if>>

	<<if $bellyImplants == 1 && $Nurse == 0>>
		A resident nurse could be used to safely regulate the rate a slave's fillable belly implant for maximum size with minimum health loss.
	<<elseif $bellyImplants == 1 && $clinicInflateBelly == 1>>
		$clinicNameCaps is useful for keeping slaves healthy during long term procedures. Slaves in $clinicName with inflatable belly implants will be filled during their time under $Nurse.slaveName's supervision to maximize growth with minimized health complications.

			[[Do not fill belly implants|Clinic][$clinicInflateBelly = 0]]

	<<elseif $bellyImplants == 1 && $Nurse != 0 && $clinicInflateBelly != 1>>
		$clinicNameCaps is useful for keeping slaves healthy during long term procedures. $Nurse.slaveName can supervise weekly filling regimens for clinic slaves with fillable belly implants during their stay to maximize growth with minimal health complications.

			[[Fill belly implants|Clinic][$clinicInflateBelly = 1]]

	<</if>>

	<<if $seePreg == 1>>
		<<if $clinicObservePregnancy != 1>>
			Pregnant patients will not be kept under observation.

				[[Keep high-risk pregnancies under observation|Clinic][$clinicObservePregnancy = 1]]

		<<else>>
			Patients undergoing a high-risk pregnancy or are close to giving birth will be kept under observation.

				[[Stop observing pregnancies|Clinic][$clinicObservePregnancy = 0]]

		<</if>>
	<</if>>

	<<if $pregSpeedControl == 1 && $Nurse == 0>>
		A resident nurse could be used to supervise patients under rapid gestation agents while minimizing strain and health complications.
	<<elseif $pregSpeedControl == 1 && $clinicSpeedGestation == 1>>
		It's exceedingly dangerous to speed up gestation without constant supervision. In $clinicName, $Nurse.slaveName will monitor slaves on rapid gestation agents; making sure the growing patients' food demands are met, monitoring their skin and womb and, if need be, perform an emergency c-section should the need arise.

			[[Limit rapid gestation agents to selected slaves only|Clinic][$clinicSpeedGestation = 0]]

	<<elseif $pregSpeedControl == 1 && $Nurse != 0 && $clinicSpeedGestation != 1>>
		$clinicNameCaps is currently not applying rapid gestation agents to pregnant patients. Only individually selected slaves will undergo this procedure

			[[Speed up gestation for all pregnant patients|Clinic][$clinicSpeedGestation = 1]]

	<</if>>

	<<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.clinic, true)>>

	Rename $clinicName: <<textbox "$clinicName" $clinicName "Clinic">>

		Use a noun or similar short phrase

<<run App.UI.SlaveList.ScrollPosition.restore()>>


code:
:: Clinic Report [nobr]

<<set _slaves = App.Utils.sortedEmployees(App.Entity.facilities.clinic)>>
<<set _DL = _slaves.length, _SL = $slaves.length, _healthBonus = 0, _idleBonus = 0, _FLsFetish = 0, _restedSlaves = 0>>

<<if $clinicDecoration != "standard">>
	<<set _devBonus = 1>>
<<else>>
	<<set _devBonus = 0>>
<</if>>

<<if $Nurse != 0>>
	<<set _FLs = $slaveIndices[$Nurse.ID]>>

	<<if ($slaves[_FLs].health.condition < 100)>>
		<<run improveCondition($slaves[_FLs], 20)>>
	<</if>>
	<<if ($slaves[_FLs].devotion <= 60)>>
		<<set $slaves[_FLs].devotion++>>
	<</if>>
	<<if $slaves[_FLs].trust < 60>>
		<<set $slaves[_FLs].trust++>>
	<</if>>

	<<if $slaves[_FLs].rules.living != "luxurious">>
		<<set $slaves[_FLs].rules.living = "luxurious">>
	<</if>>

	<<set $slaves[_FLs].devotion += _devBonus>>
	<<if $slaves[_FLs].fetishStrength <= 95>>
		<<if $slaves[_FLs].fetish != "dom">>
			<<if fetishChangeChance($slaves[_FLs]) > random(0,100)>>
				<<set _FLsFetish = 1, $slaves[_FLs].fetishKnown = 1, $slaves[_FLs].fetish = "dom">>
			<</if>>
		<<elseif $slaves[_FLs].fetishKnown == 0>>
			<<set _FLsFetish = 1, $slaves[_FLs].fetishKnown = 1>>
		<<else>>
			<<set _FLsFetish = 2, $slaves[_FLs].fetishStrength += 4>>
		<</if>>
	<</if>>
	<<set $Nurse = $slaves[_FLs]>>
	<<setLocalPronouns $Nurse>>
	    <<= SlaveFullName($Nurse)>> is serving as the clinical nurse.
	<<if $Nurse.relationship == -3 && $Nurse.devotion > 50>>
		$He does $his best to be a caring and nurturing $wife.
		<<set _healthBonus += 2>>
	<</if>>
	<<if (_FLsFetish == 1)>>
		$His job involves giving naked sex slaves orders for their own good. Even though most of these commands are medical rather than sexual, $he can be forgiven for not always seeing the difference, and @@.lightsalmon;becomes more dominant.@@
	<<elseif (_FLsFetish == 2)>>
		Every new patient in the clinic is a new target for $his authority. @@.lightsalmon;$He becomes more dominant.@@
	<</if>>
	<<if setup.nurseCareers.includes($Nurse.career)>>
		$He has experience with medicine from $his life before $he was a slave, and can often recognize conditions before even the medical scanners can.
		<<set _idleBonus++, _healthBonus++>>
	<<elseif $Nurse.skill.nurse >= $masteredXP>>
		$He has experience with medicine from working for you, and can often recognize conditions before even the medical scanners can.
		<<set _idleBonus++, _healthBonus++>>
	<<else>>
		<<set $slaves[_FLs].skill.nurse += random(1,Math.ceil(($Nurse.intelligence+$Nurse.intelligenceImplant)/15) + 8)>>
	<</if>>
	<<if ($Nurse.fetish == "dom")>>
		$He raps out commands with the confidence of long and partly sexual experience, so patients are inclined to follow even unpleasant medical instructions.
		<<set _idleBonus++, _healthBonus++>>
	<</if>>
	<<if ($Nurse.muscles > 5)>>
		$He's strong enough to gently but firmly restrain resistant slaves, allowing $him to be sparing with the inescapable but less healthy restraints.
		<<set _idleBonus++, _healthBonus++>>
	<</if>>
	<<if ($Nurse.intelligence+$Nurse.intelligenceImplant > 50)>>
		The diagnostic equipment is state-of-the-art, but $he's smart and perceptive enough that on occasion, $he can add meaningfully to its medical scans.
		<<set _idleBonus++, _healthBonus++>>
	<</if>>
	<<if ($Nurse.face > 40)>>
		Patients rarely object to seeing $his gorgeous face hovering over them.
		<<set _idleBonus++, _devBonus++>>
	<</if>>
	<<if ($slaves[_FLs].devotion >= 60)>>
		<<set _healthBonus++>>
	<</if>>
	<<for _slave range _slaves>>
		<<set $i = $slaveIndices[_slave.ID]>>
		<<if $Nurse.rivalryTarget == _slave.ID>>
			<<setLocalPronouns _slave 2>>
			$He purposefully neglects the needs of $his <<print rivalryTerm($Nurse)>>, _slave.slaveName, hindering _his2 recovery and deepening their dislike for each other.
			<<set _slave.devotion--, _slave.trust-->>
			<<run healthDamage(_slave, 3)>>
			<<if random(1,100) > 65>>
				<<set $Nurse.rivalry++, $slaves[_FLs].rivalry++, _slave.rivalry++>>
			<</if>>
		<<elseif $Nurse.relationshipTarget == _slave.ID>>
			<<setLocalPronouns _slave 2>>
			$He dedicates most of $his attention to $his <<print relationshipTerm($Nurse)>>, _slave.slaveName, making sure _he2 has everything _he2 needs and more. This lavish attention detracts from $his overall effectiveness.
			<<set _idleBonus -= 3, _slave.devotion++, _slave.trust++>>
			<<run improveCondition(_slave, 3)>>
		<<elseif areRelated($Nurse, _slave)>>
			$He makes sure to spend extra time caring for $his <<print relativeTerm($Nurse,_slave)>>, _slave.slaveName.
			<<set _slave.trust++>>
			<<run improveCondition(_slave, 1)>>
		<</if>>
		<<switch _slave.prestigeDesc>>
		<<case "$He is a famed Free Cities whore, and commands top prices.">>
			<<setLocalPronouns _slave 2>>
			$He does $his best to aid the famous whore, _slave.slaveName, making sure to pay special attention to _his2 worn holes.
			<<run improveCondition(_slave, 2)>>
		<<case "$He is a famed Free Cities slut, and can please anyone.">>
			<<setLocalPronouns _slave 2>>
			$He does $his best to aid the famous entertainer, _slave.slaveName, making sure _he2 can show off as soon as possible.
			<<run improveCondition(_slave, 2)>>
		<<case "$He is remembered for winning best in show as a cockmilker.">>
			<<setLocalPronouns _slave 2>>
			<<if (_slave.balls > 4) && (_slave.dick != 0)>>
				$He does $his best to aid the dribbling _slave.slaveName, paying special attention to _his2 huge cock and balls as well as making sure to milk _his2 <<if canAchieveErection(_slave)>>erect <</if>>dick hourly.
				<<run improveCondition(_slave, 4)>>
				<<if (random(1,100) > 65) && (($Nurse.fetish == "none") || ($Nurse.fetish == "cumslut"))>>
					<<if $Nurse.fetish == "none">>
						<<set $Nurse.fetish = "cumslut", $slaves[_FLs].fetish = "cumslut">>
					<<else>>
						<<set $Nurse.fetishStrength += 4, $slaves[_FLs].fetishStrength += 4>>
					<</if>>
				<</if>>
			<</if>>
		<<case "$He is remembered for winning best in show as a dairy cow.">>
			<<setLocalPronouns _slave 2>>
			<<if (_slave.lactation > 0) && ((_slave.boobs-_slave.boobsImplant) > 6000)>>
				$He does $his best to aid the leaking _slave.slaveName, paying special attention to _his2 huge breasts as well as making sure to milk _him2 hourly.
				<<run improveCondition(_slave, 4)>>
				<<set _slave.lactationDuration = 2, _slave.boobs -= _slave.boobsMilk, _slave.boobsMilk = 0>>
				<<if (random(1,100) > 65) && (($Nurse.fetish == "none") || ($Nurse.fetish == "boobs"))>>
					<<if $Nurse.fetish == "none">>
						<<set $Nurse.fetish = "boobs", $slaves[_FLs].fetish = "boobs">>
					<<else>>
						<<set $Nurse.fetishStrength += 4, $slaves[_FLs].fetishStrength += 4>>
					<</if>>
				<</if>>
			<</if>>
		<<case "$He is remembered for winning best in show as a breeder.">>
			<<setLocalPronouns _slave 2>>
			<<if _slave.bellyPreg >= 1500>>
				$He does $his best to aid the pregnant _slave.slaveName, paying special attention to _his2 swollen belly and the welfare of the life within.
				<<run improveCondition(_slave, 6)>>
			<<elseif _slave.ovaries == 1 || _slave.mpreg == 1>>
				$He does $his best to aid the breeder _slave.slaveName, paying special attention to _his2 fertility and reproductive organs.
				<<run improveCondition(_slave, 4)>>
			<<else>>
				$He lays out plans on how to restore the breeder _slave.slaveName to _his2 former gravid glory.
			<</if>>
		<</switch>>
		<<if _slave.bellyImplant > -1 && $clinicInflateBelly == 1>>
			<<setLocalPronouns _slave 2>>

''@@.pink;_slave.slaveName@@'' spent a lot of time during the week under IV-like stands with bags of inert filler steadily flowing into _his2 belly implant, slowly pushing _his2 belly further and further out. Careful attention, along with several drug injections, were used to make sure _his2 body was able to safely adjust to the implant's rapid growth.
			<<run healthDamage(_slave, 10)>>
			<<set _slave.bellyImplant += 5000>>
			<<if (_slave.devotion > 50)>>
				<<set _slave.devotion += 4, _slave.trust += 3>>
			<<elseif (_slave.devotion >= -20)>>
				<<set _slave.trust -= 5>>
			<<else>>
				<<set _slave.devotion -= 5, _slave.trust -= 10>>
			<</if>>
			<<if _slave.bellyImplant > ($arcologies[0].FSTransformationFetishistResearch ? 800000 : 130000)>>
				<<set _slave.bellyImplant = ($arcologies[0].FSTransformationFetishistResearch ? 800000 : 130000)>>
				_He2 is filled to the maximum that _his2 implant can stand.
			<</if>>
		<</if>>
		<<if _slave.pregKnown == 1 && _slave.preg < _slave.pregData.normalBirth && _slave.pregControl == "speed up">>
			<<setLocalPronouns _slave 2>>

''@@.pink;_slave.slaveName@@'' spends most of _his2 time on bedrest being filled with rapid gestation agents and concentrated slave food. All _he2 can do is <<if hasAnyArms(_slave) && canSee(_slave)>>watch and feel _his2 belly pushing further and further out with life<<elseif canSee(_slave)>>watch _his2 belly bulging further and further out with life<<elseif hasAnyArms(_slave)>>feel _his2 belly pushing further and further out with life beneath _his2 fingers<<else>>feel the every growing pressure inside _his2 abdomen<</if>>. Careful attention, along with numerous drug injections, are used to make sure _his2 body is able to safely adjust to _his2 pregnancy's rapid growth.
			<<run healthDamage(_slave, 10)>>
			<<if (_slave.devotion > 50)>>
				<<set _slave.devotion += 2, _slave.trust += 1>>
			<<elseif (_slave.devotion >= -20)>>
				<<set _slave.trust -= 5>>
			<<else>>
				<<set _slave.devotion -= 5, _slave.trust -= 10>>
			<</if>>
			<<if _slave.preg >= _slave.pregData.minLiveBirth && _slave.pregControl == "speed up">>
				<<set _slave.pregControl = "none">>
				''@@.pink;_slave.slaveName's@@'' child is ready to pop out of _his2 womb, ''@@.yellow;_his2 course of rapid gestation agents is finished@@''.
			<</if>>
		<<elseif _slave.preg > 2 && _slave.pregKnown == 0>>
			During $his tests, $he discovers that _slave.slaveName @@.lime;is pregnant.@@
			<<set _slave.pregKnown = 1>>
		<</if>>
	<</for>>
	<<if (_DL < $clinic)>>
		<<set _seed = random(1,10)+(($clinic-_DL)*(random(150,170)+(_idleBonus*10)))>>
		<<run cashX(_seed, "clinic", $Nurse)>>

    Since $he doesn't have enough patients to occupy all $his time, the clinic takes in citizens' slaves on a contract basis and $he helps them too, earning @@.yellowgreen;<<print cashFormat(_seed)>>.@@
	<</if>>
	<<if (_DL > 0)>>

<</if>>
<</if>>

<<if (_DL > 0)>>
	    <<if (_DL == 1)>>''There is one slave receiving treatment in the clinic.''<<else>>''There are _DL slaves receiving treatment in the clinic.''<</if>>
<</if>>

<<if ($Nurse != 0)>>
	<<set $i = _FLs>> /* apply following SA passages to facility leader */
	<<if $showEWD != 0>>

		/* 000-250-006 */
		<<if $seeImages && $seeReportImages>>

			<<= SlaveArt($slaves[_FLs], 0, 0)>>

		<</if>>
		/* 000-250-006 */
		<<= SlaveFullName($slaves[_FLs])>> is serving as the clinical nurse.

		<<= App.SlaveAssignment.choosesOwnClothes($slaves[$i])>>
		<<run tired($slaves[$i])>>
		<<include "SA rules">>
		<<include "SA diet">>
		<<include "SA long term effects">>
		<<= App.SlaveAssignment.drugs($slaves[$i])>>
		<<include "SA relationships">>
		<<include "SA rivalries">>

<<include "SA devotion">>
	<<else>>
		<<silently>>
		<<run App.SlaveAssignment.choosesOwnClothes($slaves[$i])>>
		<<run tired($slaves[$i])>>
		<<include "SA rules">>
		<<include "SA diet">>
		<<include "SA long term effects">>
		<<run App.SlaveAssignment.drugs($slaves[$i])>>
		<<include "SA relationships">>
		<<include "SA rivalries">>
		<<include "SA devotion">>
		<</silently>>
	<</if>>
	<<set $Nurse = $slaves[_FLs]>>
<</if>>

<<for _slave range _slaves>>
	<<set $i = $slaveIndices[_slave.ID]>>
	<<setLocalPronouns _slave>>

	<<if _slave.devotion < 45>>
		<<set _slave.devotion += 4>>
	<</if>>
	<<set _slave.devotion += _devBonus>>
	<<if _slave.trust < 45>>
		<<set _slave.trust += 4>>
	<</if>>

	<<if (_slave.health.condition < -80)>>
		<<run improveCondition(_slave, (20 + ($curativeUpgrade * 10) + _healthBonus))>>
	<<elseif (_slave.health.condition < -40)>>
		<<run improveCondition(_slave, (10 + ($curativeUpgrade * 7) + _healthBonus))>>
	<<elseif (_slave.health.condition < 0)>>
		<<run improveCondition(_slave, (7 + ($curativeUpgrade * 5) + _healthBonus))>>
	<<elseif (_slave.health.condition < 90)>>
		<<run improveCondition(_slave, (3 + ($curativeUpgrade * 3) + _healthBonus))>>
	<</if>>

	/* the clinic is a well-equipped medical facility and can allow the Nurse or player to
	* directly cure serious wounds caused by injury and surgery with minimal side effects */
	<<if _slave.health.shortDamage >= 10>>
		<<if ($Nurse != 0)>>
			<<run healthCure(_slave, 5 + _healthBonus)>>
		<<else>>
			<<run healthCure(_slave, $PC.skill.medicine / 15)>> /* maximum of 6...even a bad full-time nurse will be better than a player doctor */
		<</if>>
	<</if>>

	<<switch $clinicDecoration>>
	<<case "Eugenics" "Gender Fundamentalist" "Gender Radicalist" "Hedonistic" "Intellectual Dependency" "Maturity Preferentialist" "Paternalist" "Petite Admiration" "Repopulation Focus" "Slimness Enthusiast" "Statuesque Glorification" "Youth Preferentialist">>
		<<set _slave.rules.living = "luxurious">>
	<<case "Arabian Revivalist" "Aztec Revivalist" "Chattel Religionist" "Chinese Revivalist" "Edo Revivalist" "Egyptian Revivalist" "Roman Revivalist">>
		<<set _slave.rules.living = "normal">>
	<<default>>
		<<set _slave.rules.living = "spare">>
	<</switch>>

	<<if ($Nurse != 0)>>
		<<if ($clinicSpeedGestation == 1) && (_slave.pregKnown == 1)>>
			<<set _slave.pregControl = "speed up">>
		<</if>>
		<<if (_slave.chem > 10) && ($clinicUpgradeFilters >= 1)>>
			<<if _slave.health.health > -50 && ($clinicUpgradePurge > 0)>>
				<<set _slave.chem -= 100 * $clinicUpgradePurge>>
				<<run healthDamage(_slave, 15)>>
			<</if>>
			<<set _slave.chem = Math.max(_slave.chem - 5, 0)>>
		<</if>>
		<<if _slave.lactation == 1>>
			<<set _slave.boobs -= _slave.boobsMilk, _slave.boobsMilk = 0>>
		<</if>>
	<</if>>
	<<if (_slave.health.illness > 0)>>
	<<elseif (_slave.health.shortDamage >= 20)>> /* shortDamage does no real harm, until it gets to 20 */
	<<elseif (_slave.health.condition <= 40)>>
	<<elseif ($Nurse != 0) && (_slave.chem > 15) && ($clinicUpgradeFilters == 1)>>
	<<elseif ($Nurse != 0) && (_slave.pregKnown == 1) && ($clinicSpeedGestation > 0 || _slave.pregControl == "speed up")>>
	<<elseif ($Nurse != 0) && ($clinicObservePregnancy == 1) && (_slave.pregAdaptation*1000 < _slave.bellyPreg || _slave.preg > _slave.pregData.normalBirth/1.33)>>
	<<elseif ($Nurse != 0) && ($clinicInflateBelly > 0) && (_slave.bellyImplant >= 0) && (_slave.bellyImplant <= ($arcologies[0].FSTransformationFetishistResearch ? 800000 : 130000))>>
	<<else>>

			_slave.slaveName has been cured<<if ($Nurse != 0) && ($clinicUpgradeFilters == 1)>> and purified<</if>>,

				<<if $assignmentRecords[_slave.ID]>>
					<<set _oldJob = $assignmentRecords[_slave.ID]>>
					<<= assignJobSafely(_slave, _oldJob)>>
					<<if _slave.choosesOwnAssignment === 1>>
						and $he is resting before choosing another task.
					<<elseif _slave.assignment === "rest">>
						<<if _oldJob != "rest">>
							and since $he was unable to return to $his old task to <<print _oldJob>>, $his assignment has defaulted to rest.
						<<else>>
							so $he has returned to rest.
						<</if>>
					<<else>>
						so $he goes back to <<print _slave.assignment>>.
					<</if>>
				<<else>>
					so $his assignment has defaulted to rest.
					<<= removeJob(_slave, "get treatment in the clinic")>>
				<</if>>

		<<set _restedSlaves++, _dI--, _DL-->>
		<<continue>>
	<</if>>
	<<if $showEWD != 0>>

		/* 000-250-006 */
		<<if $seeImages && $seeReportImages>>

				<<= SlaveArt(_slave, 0, 0)>>

		<</if>>
		/* 000-250-006 */
		<<= SlaveFullName(_slave)>>
		<<if _slave.choosesOwnAssignment == 2>>
			<<include "SA chooses own job">>
		<<else>>
			is receiving treatment in $clinicName.
		<</if>>

    $He <<= App.SlaveAssignment.rest(_slave)>>
		<<if (_slave.health.illness > 0)>>
			$He stays in the clinic since $he is still sick.
		<<elseif (_slave.health.condition <= 40)>>
			$He stays in the clinic since $his health is still poor.
		<<elseif (_slave.health.shortDamage >= 20)>>
			$He stays in the clinic to recover from $his injuries.
		<<elseif ($Nurse != 0) && (_slave.chem > 15) && ($clinicUpgradeFilters == 1)>>
			$He stays in the clinic as unhealthy chemicals are still being flushed from $his system.
		<<elseif ($Nurse != 0) && (_slave.pregKnown == 1) && ($clinicSpeedGestation > 0 || _slave.pregControl == "speed up")>>
			$He stays in the clinic to hurry $his pregnancy along safely.
		<<elseif ($Nurse != 0) && ($clinicInflateBelly > 0) && (_slave.bellyImplant >= 0) && (_slave.bellyImplant <= ($arcologies[0].FSTransformationFetishistResearch ? 800000 : 130000))>>
			$He stays in the clinic as $his implants can still receive more filling.
		<<elseif ($Nurse != 0) && ($clinicObservePregnancy == 1) && (_slave.pregAdaptation*1000 < _slave.bellyPreg || _slave.preg > _slave.pregData.normalBirth/1.33)>>
			$He stays in the clinic waiting for the child to be born.
		<</if>>

		<<= App.SlaveAssignment.choosesOwnClothes(_slave)>>
		<<include "SA rules">>
		<<include "SA diet">>
		<<include "SA long term effects">>
		<<= App.SlaveAssignment.drugs(_slave)>>
		<<include "SA relationships">>
		<<include "SA rivalries">>

<<include "SA devotion">>
	<<else>>
		<<silently>>
		<<include "SA chooses own job">>
		<<run App.SlaveAssignment.rest(_slave)>>
		<<run App.SlaveAssignment.choosesOwnClothes(_slave)>>
		<<include "SA rules">>
		<<include "SA diet">>
		<<include "SA long term effects">>
		<<run App.SlaveAssignment.drugs(_slave)>>
		<<include "SA relationships">>
		<<include "SA rivalries">>
		<<include "SA devotion">>
		<</silently>>
	<</if>>
<</for>>
<<if (_restedSlaves > 0)>>

	<<if (_restedSlaves == 1)>>
		One slave has
	<<else>>
		_restedSlaves slaves have
	<</if>>
	been returned to @@.green;health<<if ($Nurse != 0) && ($clinicUpgradeFilters == 1)>> and purity<</if>>@@ and will be released from the clinic before the end of the week.
	<<if $clinicDecoration != "standard">>

    $clinicNameCaps's $clinicDecoration atmosphere @@.hotpink;had an impact on them while they were@@ getting treatment.
	<</if>>
<</if>>
<<if _DL > 0 || $Nurse != 0>>

<</if>>