:: Analyze Pregnancy [nobr]

<<if lastVisited("Incubator") === 1>>
	<<set $storedLink = "Incubator">>
<<elseif lastVisited("Slave Interact") === 1>>
	<<set $storedLink = "Slave Interact">>
<</if>>
<<set $nextButton = "Continue", $nextLink = $storedLink>>
<<run App.Utils.setLocalPronouns(getSlave($activeSlave.ID))>>

<<set _WL = getSlave($activeSlave.ID).womb.length, _incubatorReservations = WombReserveCount(getSlave($activeSlave.ID), "incubator"), _nurseryReservations = WombReserveCount(getSlave($activeSlave.ID), "nursery"), _freeTanks = $incubator - $incubatorSlaves, _freeCribs = $nursery - $cribs.length>>

	<p class="scene-intro">
		<<= getSlave($activeSlave.ID).slaveName>> is <<if getSlave($activeSlave.ID).devotion < 20>>restrained<<else>>comfortably reclined<</if>> with $his stomach prepped for examination. $He shudders slightly at the cold touch of the sensor against $his skin.
	</p>

	<<set $saleDescription = 1>><<= App.Desc.pregnancy($activeSlave)>><<set $saleDescription = 0>>

	<p>
		<h2>Overall statistics</h2>
		<div class="indent">
			<<set _cc = Math.round(getSlave($activeSlave.ID).bellyPreg)>>
			<<set _safecc = Math.round(getSlave($activeSlave.ID).pregAdaptation*2000)>>
			<<if $geneticMappingUpgrade > 0>>
				<div>
					Estimated physical degree of pregnancy adaptation: <<print num(Math.round(getSlave($activeSlave.ID).pregAdaptation))>>
				</div>
				<div>
					Estimated safe
					<<if getSlave($activeSlave.ID).ovaries == 1 || getSlave($activeSlave.ID).mpreg == 1>>
						womb
					<<else>>
						abdominal
					<</if>>
					volume: <<= num(_safecc)>> cc
				</div>
			<</if>>
			<div>
				Current fetal count: <<= getSlave($activeSlave.ID).womb.length>>
			</div>
			<div>
				Estimated
				<<if getSlave($activeSlave.ID).ovaries == 1 || getSlave($activeSlave.ID).mpreg == 1>>
					womb
				<<else>>
					abdominal
				<</if>>
				volume: <<if _safecc < _cc && $geneticMappingUpgrade > 0>>@@.red;<<= num(_cc)>>@@<<else>><<= num(_cc)>><</if>> cc
			</div>
		</div>
	</p>

	<<if getSlave($activeSlave.ID).womb.length > 0>>
		<p>
			<h2>Furthest developed pregnancy</h2>
			<div class="indent">
				Fetal development week: <<= Math.trunc(getSlave($activeSlave.ID).preg * 1000) / 1000>>
			</div>
		</p>

		<p>
		<<if $incubator + $nursery > 0>>
			<div>
				<<if $incubator > 0>>
					<<if _incubatorReservations > 0>>
						<<link "Remove all of $his children from $incubatorName" "Analyze Pregnancy">>
							<<run WombChangeReserveType(getSlave($activeSlave.ID), "incubator", "")>>
							<<set $reservedChildren -= _incubatorReservations>>
						<</link>> |
					<</if>>
					<<if _incubatorReservations < _WL && ($reservedChildren + _WL - _incubatorReservations <= _freeTanks)>>
						<<link "Keep all of $his children in $incubatorName" "Analyze Pregnancy">>
							<<run WombChangeReserveType(getSlave($activeSlave.ID), "nursery", "incubator")>>
							<<run WombChangeReserveType(getSlave($activeSlave.ID), "", "incubator")>>
							<<set $reservedChildrenNursery -= _nurseryReservations>>
							<<set $reservedChildren += _WL - _incubatorReservations>>
						<</link>>
					<<elseif _incubatorReservations < _WL>>
						There is not enough free space in $incubatorName for the rest of $his children.
					<</if>>
				<</if>>
			</div>

			<div>
				<<if $nursery > 0>>
					<<if _nurseryReservations > 0>>
						<<link "Remove all of $his children from $nurseryName" "Analyze Pregnancy">>
							<<run WombChangeReserveType(getSlave($activeSlave.ID), "nursery", "")>>
							<<set $reservedChildrenNursery -= _nurseryReservations>>
						<</link>> |
					<</if>>
					<<if _nurseryReservations < _WL && ($reservedChildrenNursery + _WL - _nurseryReservations <= _freeCribs)>>
						<<link "Keep all of $his children in $nurseryName" "Analyze Pregnancy">>
							<<run WombChangeReserveType(getSlave($activeSlave.ID), "incubator", "nursery")>>
							<<run WombChangeReserveType(getSlave($activeSlave.ID), "", "nursery")>>
							<<set $reservedChildren -= _incubatorReservations>>
							<<set $reservedChildrenNursery += _WL - _nurseryReservations>>
						<</link>>
					<<elseif _nurseryReservations < _WL>>
						There is not enough free space in $nurseryName for the rest of $his children.
					<</if>>
				<</if>>
			</div>
		<</if>>
		</p>

		<p>
			<h2>Deep scan</h2>
			<<for _ap = 0; _ap < _WL; _ap++>>
				<hr style="margin:0">
				<p>
					<<capture _ap>>
						<<if getSlave($activeSlave.ID).womb[_ap].age >=2 >>
							<div class="indent">
								Ova: <<= getSlave($activeSlave.ID).womb[_ap].genetics.name>>
							</div>
							<div class="indent">
								Age: <<= Math.trunc(getSlave($activeSlave.ID).womb[_ap].age * 1000) / 1000>>
							</div>
							<<if $geneticMappingUpgrade >= 1>>
								<div class="indent">
									Gender: <<= getSlave($activeSlave.ID).womb[_ap].genetics.gender>>
								</div>
								<div class="indent">
									Father ID: <<= getSlave($activeSlave.ID).womb[_ap].genetics.father>>
								</div>
								<div class="indent">
									Father Name:
									<<if ndef getSlave($activeSlave.ID).womb[_ap].genetics.fatherName>>
										name not registered
									<<else>>
										<<= getSlave($activeSlave.ID).womb[_ap].genetics.fatherName>>
									<</if>>
								</div>
								<div class="indent">
									Mother ID: <<= getSlave($activeSlave.ID).womb[_ap].genetics.mother>>
								</div>
								<div class="indent">
									Mother Name:
									<<if ndef getSlave($activeSlave.ID).womb[_ap].genetics.motherName>>
										name not registered
									<<else>>
										<<= getSlave($activeSlave.ID).womb[_ap].genetics.motherName>>
									<</if>>
								</div>
								<div class="indent">
									Nationality: <<= getSlave($activeSlave.ID).womb[_ap].genetics.nationality>>
								</div>
								<div class="indent">
									Race: <<= capFirstChar(getSlave($activeSlave.ID).womb[_ap].genetics.race)>>
								</div>
								<div class="indent">
									Skin tone: <<= capFirstChar(getSlave($activeSlave.ID).womb[_ap].genetics.skin)>>
								</div>
								<div class="indent">
									Intelligence index: <<= getSlave($activeSlave.ID).womb[_ap].genetics.intelligence>> out of 100
								</div>
								<div class="indent">
									Face index: <<= getSlave($activeSlave.ID).womb[_ap].genetics.face>> out of 100
								</div>
								<div class="indent">
									Eye Color: <<= capFirstChar(getSlave($activeSlave.ID).womb[_ap].genetics.eyeColor)>>
								</div>
								<div class="indent">
									Hair Color: <<= capFirstChar(getSlave($activeSlave.ID).womb[_ap].genetics.hColor)>>
								</div>
								<div class="indent">
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.underArmHStyle == "hairless" && getSlave($activeSlave.ID).womb[_ap].genetics.pubicHStyle == "hairless">>
										Body hair: None
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.underArmHStyle == "hairless">>
										Body hair: Lacks underarm hair
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.pubicHStyle == "hairless">>
										Body hair: Lacks pubic hair
									<</if>>
								</div>
								<<if getSlave($activeSlave.ID).womb[_ap].genetics.markings == "freckles" || getSlave($activeSlave.ID).womb[_ap].genetics.markings == "heavily freckled">>
									<div class="indent">
										Markings: <<= capFirstChar(getSlave($activeSlave.ID).womb[_ap].genetics.markings)>>
									</div>
								<</if>>
								<div class="indent">
									Detected abnormalities:
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.albinism == 2>>
										@@.green;alb@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.albinism == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;alb@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.gigantism == 2>>
										@@.red;gnt@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.gigantism == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;gnt@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.dwarfism == 2>>
										@@.red;dwrf@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.dwarfism == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;dwrf@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.heterochromia == 2>>
										@@.green;hetchrom@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.heterochromia == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;hetchrom@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.androgyny == 2>>
										@@.red;andr@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.androgyny == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;andr@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.pFace == 2>>
										@@.green;pfce@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.pFace == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;pfce@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.uFace == 2>>
										@@.red;ufce@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.uFace == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;ufce@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.fertility == 2>>
										@@.green;fert@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.fertility == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;fert@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.hyperFertility == 2>>
										@@.green;hfert@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.hyperFertility == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;hfert@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.superfetation == 2>>
										@@.green;supfet@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.superfetation == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;supfet@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.macromastia >= 2>>
										@@.red;mmast@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.macromastia == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;mast@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.gigantomastia >= 2>>
										@@.red;gmast@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.gigantomastia == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;gmast@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.wellHung == 2>>
										@@.green;bigd@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.wellHung == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;bigd@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.rearLipedema == 2>>
										@@.red;lipe@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.rearLipedema == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;lipe@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.wGain == 2>>
										@@.red;lepti+@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.wGain == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;lepti+@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.wLoss == 2>>
										@@.red;lepti-@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.wLoss == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;lepti-@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.mGain == 2>>
										@@.red;myot+@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.mGain == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;myot+@@
									<</if>>
									<<if getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.mLoss == 2>>
										@@.red;myot-@@
									<<elseif getSlave($activeSlave.ID).womb[_ap].genetics.geneticQuirks.mLoss == 1 && $geneticMappingUpgrade >= 2>>
										@@.yellow;myot-@@
									<</if>>
								</div>
							<<else>>
								<<if getSlave($activeSlave.ID).womb[_ap].age > 13>>
									<div class="indent">
										Gender: <<= getSlave($activeSlave.ID).womb[_ap].genetics.gender>>
									</div>
								<</if>>
								<<if getSlave($activeSlave.ID).womb[_ap].age > 5>>
									<div class="indent">
										Father ID: <<= getSlave($activeSlave.ID).womb[_ap].genetics.father>>
									</div>
									<div class="indent">
										Father Name: <<= getSlave($activeSlave.ID).womb[_ap].genetics.fatherName>>
									</div>
									<div class="indent">
										Mother ID: <<= getSlave($activeSlave.ID).womb[_ap].genetics.mother>>
									</div>
									<div class="indent">
										Mother Name: <<= getSlave($activeSlave.ID).womb[_ap].genetics.motherName>>
									</div>
								<</if>>
							<</if>>
							<<if $incubator > 0 || $nursery > 0>>
								<div class="indent">
									Reserved: <<= getSlave($activeSlave.ID).womb[_ap].reserve>>
								</div>
							<</if>>

							<div class="indent">
								Rename: <<textbox "_tempName" _tempName >> [[Apply | Analyze Pregnancy][getSlave($activeSlave.ID).womb[_ap].genetics.name = _tempName]]
							</div>
							<<if getSlave($activeSlave.ID).womb[_ap].age < 4 && ($arcologies[0].FSRestart == "unset" || $eugenicsFullControl == 1 || getSlave($activeSlave.ID).breedingMark == 0 || $propOutcome == 0 || (getSlave($activeSlave.ID).womb[_ap].fatherID != -1 && getSlave($activeSlave.ID).womb[_ap].fatherID != -6))>>
								<div class="indent">
									<<link "Terminate ovum" "Analyze Pregnancy">><<run WombRemoveFetus(getSlave($activeSlave.ID), _ap)>><<if getSlave($activeSlave.ID).preg == 0>><<set getSlave($activeSlave.ID).pregWeek = -1>><</if>><</link>>
									<<if $surgeryUpgrade == 1>>
										| [[Transplant ovum|Ova Transplant Workaround][$donatrix = getSlave($activeSlave.ID), $wombIndex = _ap, $nextLink = "Analyze Pregnancy"]]
									<</if>>
								</div>
							<</if>>
							<<if $incubator > 0>>
								<div class="indent">
									<<if getSlave($activeSlave.ID).womb[_ap].reserve === "incubator">>
										<<link "Don't keep this child in $incubatorName" "Analyze Pregnancy">>
											<<set getSlave($activeSlave.ID).womb[_ap].reserve = "">>
											<<set $reservedChildren-->>
										<</link>>
									<<elseif _freeTanks - $reservedChildren > 0>>
										<<link "Keep this child in $incubatorName" "Analyze Pregnancy">>
											<<if getSlave($activeSlave.ID).womb[_ap].reserve === "nursery">>
												<<set $reservedChildrenNursery-->>
											<</if>>
											<<set getSlave($activeSlave.ID).womb[_ap].reserve = "incubator">>
											<<set $reservedChildren++>>
										<</link>>
									<<else>>
										There is not enough free space to keep this child in $incubatorName.
									<</if>>
								</div>
							<</if>>
							<<if $nursery > 0>>
								<div class="indent">
									<<if getSlave($activeSlave.ID).womb[_ap].reserve === "nursery">>
										<<link "Don't keep this child in $nurseryName" "Analyze Pregnancy">>
											<<set getSlave($activeSlave.ID).womb[_ap].reserve = "">>
											<<set $reservedChildrenNursery-->>
										<</link>>
									<<elseif _freeCribs - $reservedChildrenNursery > 0>>
										<<link "Keep this child in $nurseryName" "Analyze Pregnancy">>
											<<if getSlave($activeSlave.ID).womb[_ap].reserve === "incubator">>
												<<set $reservedChildren-->>
											<</if>>
											<<set getSlave($activeSlave.ID).womb[_ap].reserve = "nursery">>
											<<set $reservedChildrenNursery++>>
										<</link>>
									<<else>>
										There is not enough free space to keep this child in $nurseryName.
									<</if>>
								</div>
							<</if>>
						<<else>>
							<div class="indent">
								Unidentified ova found, no detailed data available.
							</div>
							<div class="indent">
								Age: too early for scan.
							</div>
							<div class="indent">
								<<link "Terminate ovum" "Analyze Pregnancy">><<run WombRemoveFetus(getSlave($activeSlave.ID), _ap)>><<if getSlave($activeSlave.ID).preg == 0>><<set getSlave($activeSlave.ID).pregWeek = -1>><</if>><</link>>
								<<if $surgeryUpgrade == 1>>
									| [[Transplant ovum|Ova Transplant Workaround][$donatrix = getSlave($activeSlave.ID), $wombIndex = _ap, $nextLink = "Analyze Pregnancy"]]
								<</if>>
							</div>
						<</if>>
					<</capture>>
				</p>
			<</for>>
		</p>
	<<elseif getSlave($activeSlave.ID).pregWeek < 0>> /*special states*/
		Subject is in the postpartem period.
	<<elseif getSlave($activeSlave.ID).preg == -1>> /*special states*/
		Contreceptive agents detected in subject.
	<<elseif getSlave($activeSlave.ID).preg == -2>> /*special states*/
		Subject is infertile.
	<<elseif getSlave($activeSlave.ID).preg == -3>> /*special states*/
		Failure to locate any ova. Subject is infertile.
	<</if>>


src/pregmod/analyzePregnancy.tw