:: Incubator Retrieval Workaround [nobr]

<<set $nextLink = "AS Dump", $returnTo = "Main">>

<<if $readySlave != 0>>
	<<setLocalPronouns $readySlave>>
	$readySlave.slaveName has been discharged from $incubatorName and is ready for $his first ever inspection.

	<br><br>

	<<set $activeSlave = $readySlave>>
	<<set $saleDescription = 0, $applyLaw = 0>>
	<<set $incubatorSlaves-->>
	<<include "Long Slave Description">>
	<<if $readySlave.tankBaby != 3>>
		<<if $incubatorOrgans.length > 0>>
			<<for _irw = 0; _irw < $incubatorOrgans.length; _irw++>>
				<<if $incubatorOrgans[_irw].ID == $incubatorOldID>>
					<<set _newOrgan = {type: $incubatorOrgans[_irw].type, weeksToCompletion: $incubatorOrgans[_irw].weeksToCompletion, ID: $activeSlave.ID}>>
					<<if _newOrgan.weeksToCompletion <= 0>>
						<<set $completedOrgans.push($incubatorOrgans[_irw])>>
					<<else>>
						<<set $organs.push(_newOrgan)>>
					<</if>>
					<<set $incubatorOrgans.deleteAt(_irw), _irw-->>
				<</if>>
			<</for>>
		<</if>>
		<<run newSlave($activeSlave)>>
		<<include "New Child Intro">>
	<<else>>
		A husk is ready to be used.
		<br>
		//As expected, $he is a complete vegetable, but that is what you wanted after all. You lack the facilities to care for $him in this state, so you should do what you are planning quickly. Or you could sell $him to the Flesh Heap.//
		<span id="result">
		<<if $cash >= $surgeryCost>>
			<br>[[Contact the bodyswap surgeon.|husk Slave Swap Workaround]] //Will significantly increase the selected slave's upkeep.//
			<br>[[Sell the husk to Flesh Heap.|Main][cashX(Math.trunc(slaveCost($activeSlave)/3), "slaveTransfer")]]
//This body can be bought by the Flesh Heap for <<print cashFormat(Math.trunc(slaveCost($activeSlave)/3))>>//.
		<<else>>
			<<run cashX(Math.trunc(slaveCost($activeSlave)/3), "slaveTransfer")>>
			//You can't sustain $him and thus must sell $him for <<print cashFormat(Math.trunc(slaveCost($activeSlave)/3))>>.//
		<</if>>
		</span>
	<</if>>
<<else>>
	The following slaves were discharged from $incubatorName:

	<<for _irw = 0; _irw < $newSlavePool.length; _irw++>>
		<br><br>
		<<set $incubatorSlaves-->>
		<<set _newSlave = $newSlavePool[_irw].object>>

		Name: <<= SlaveFullName(_newSlave)>>
		<br>Mother:
		<<if _newSlave.mother > 0>>
			<<set _tempMom = getSlave(_newSlave.mother)>>
			<<if ndef _tempMom>>
				Unknown.
			<<else>>
				<<= SlaveFullName(_tempMom)>>
			<</if>>
		<<elseif _newSlave.mother == -1>>
			<<= PlayerName()>>.
		<<else>>
			Your former slave, $missingTable[_newSlave.mother].slaveName.
		<</if>>
		<br>Father:
		<<if _newSlave.father > 0>>
			<<set _tempDad = getSlave(_newSlave.father)>>
			<<if ndef _tempDad>>
				Unknown.
			<<else>>
				<<= SlaveFullName(_tempDad)>>
			<</if>>
		<<elseif _newSlave.father == -1>>
			<<= PlayerName()>>.
		<<elseif _newSlave.father == -2>>
			Unknown citizen.
		<<elseif _newSlave.father == -3>>
			Your former Master.
		<<elseif _newSlave.father == -4>>
			Another arcology's owner.
		<<elseif _newSlave.father == -5>>
			One of your clients.
		<<elseif _newSlave.father == -6>>
			Societal Elite.
		<<elseif _newSlave.father == -7>>
			Lab crafted.
		<<elseif _newSlave.father == -8>>
			//Error! Animal fathered children shouldn't be here!//
		<<elseif _newSlave.father == -9>>
			Futanari Sister.
		<<else>>
			<<if def $missingTable[_newSlave.father]>>
				Your former slave, $missingTable[_newSlave.father].slaveName.
			<<else>>
				Unknown.
			<</if>>
		<</if>>

		<<run newSlave(_newSlave)>>
		<<if $incubatorOrgans.length > 0>>
			<<for _irw2 = 0; _irw2 < $incubatorOrgans.length; _irw2++>>
				<<if $incubatorOrgans[_irw2].ID == $newSlavePool[_irw].ID>>
					<<set _newOrgan = {type: $incubatorOrgans[_irw2].type, weeksToCompletion: $incubatorOrgans[_irw2].weeksToCompletion, ID: _newSlave.ID}>>
					<<if _newOrgan.weeksToCompletion <= 0>>
						<<set $completedOrgans.push($incubatorOrgans[_irw2])>>
					<<else>>
						<<set $organs.push(_newOrgan)>>
					<</if>>
					<<set $incubatorOrgans.deleteAt(_irw2), _irw2-->>
				<</if>>
			<</for>>
		<</if>>

	<</for>>
	<<set $newSlavePool = 0>>
<</if>>

src/pregmod/incubatorRetrievalWorkaround.tw