From 234acf79e269a9e4ed300aa6e8f5e4eec601fd93 Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Mon, 8 Apr 2019 03:11:09 -0400
Subject: [PATCH] Superfetation finishing touches

---
 src/js/wombJS.js                       |   2 +-
 src/uncategorized/remoteSurgery.tw     |   4 +
 src/utility/descriptionWidgetsFlesh.tw | 211 ++++++++++++++++++++++---
 3 files changed, 198 insertions(+), 19 deletions(-)

diff --git a/src/js/wombJS.js b/src/js/wombJS.js
index b26f1029f15..4c4969e7602 100644
--- a/src/js/wombJS.js
+++ b/src/js/wombJS.js
@@ -752,7 +752,7 @@ data.litterData[x] = contain array with actual fetuses that belong to a litter "
 
 Sample of usage in SugarScript: 
 ---
-<<set _wd = WombGetLitterData($activeSlave)>>
+<<set _wd = WombGetLittersData($activeSlave)>>
 She is _wd.litters[0] weeks pregnant with her first set of _wd.countLitter[0] children<<if _wd.litters > 1>>, _wd.litters[1] weeks along with her second set<</if>><<if _wd.litters > 2>>, _wd.litters[2] and _wd.litters[2] weeks along with her third<</if>>.
 In summary she carry _wd.litters.length separate sets of children. Her most progressed fetus of second pregnancy is already reached _wd.litterData[1][0].age biological week of gestation.
 ---
diff --git a/src/uncategorized/remoteSurgery.tw b/src/uncategorized/remoteSurgery.tw
index 81bb13dbda4..110ff0c8651 100644
--- a/src/uncategorized/remoteSurgery.tw
+++ b/src/uncategorized/remoteSurgery.tw
@@ -1430,6 +1430,10 @@ $He has
 			<br>&nbsp;&nbsp;&nbsp;&nbsp;
 			[[Correct heightened fertility|Surgery Degradation][$activeSlave.geneticQuirks.fertility = 0,cashX(forceNeg($surgeryCost*4), "slaveSurgery", $activeSlave), $activeSlave.health -= 40, $activeSlave.chem += 100,$surgeryType = "gene treatment"]]
 		<</if>>
+		<<if $activeSlave.geneticQuirks.superfetation == 2>>
+			<br>&nbsp;&nbsp;&nbsp;&nbsp;
+			[[Correct ova release during pregnancy|Surgery Degradation][$activeSlave.geneticQuirks.superfetation = 0,cashX(forceNeg($surgeryCost*4), "slaveSurgery", $activeSlave), $activeSlave.health -= 40, $activeSlave.chem += 100,$surgeryType = "gene treatment"]]
+		<</if>>
 		<<if $activeSlave.geneticQuirks.wellHung == 2>>
 			<br>&nbsp;&nbsp;&nbsp;&nbsp;
 			[[Corret genetic predisposition for large genitals|Surgery Degradation][$activeSlave.geneticQuirks.wellHung = 0,cashX(forceNeg($surgeryCost*4), "slaveSurgery", $activeSlave), $activeSlave.health -= 40, $activeSlave.chem += 100,$surgeryType = "gene treatment"]]
diff --git a/src/utility/descriptionWidgetsFlesh.tw b/src/utility/descriptionWidgetsFlesh.tw
index 55edf906efb..a133ffb39e1 100644
--- a/src/utility/descriptionWidgetsFlesh.tw
+++ b/src/utility/descriptionWidgetsFlesh.tw
@@ -16603,6 +16603,7 @@ $He has
 	<<else>>
 		a staggering $activeSlave.pregType babies.
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyPreg >= 750000>>
 	$He is
 	<<if $activeSlave.belly > ($activeSlave.pregAdaptation*1000)>>
@@ -16617,6 +16618,7 @@ $He has
 	<<elseif $activeSlave.preg >= $activeSlave.pregData.normalBirth*1.075>>
 		$He is very overdue; $he should have given birth <<print ($activeSlave.preg-$activeSlave.pregData.normalBirth)>> weeks ago.
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 750000>>
 	$He looks @@.red;ready to pop!@@ $His stomach is <<if $activeSlave.belly > ($activeSlave.pregAdaptation*1000)>>painfully<<else>>frighteningly<</if>> stretched by $his straining <<print $activeSlave.bellyImplant>>cc belly implant. It is well past it's recommended capacity and at risk of rupturing.
 <<elseif $activeSlave.bellyPreg >= 600000>>
@@ -16645,6 +16647,7 @@ $He has
 	<<else>>
 		$activeSlave.pregType babies.
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 600000>>
 	$He looks @@.pink;dangerously pregnant.@@ $He stomach is massively stretched by $his absurdly overfilled <<print $activeSlave.bellyImplant>>cc belly implant.
 <<elseif $activeSlave.bellyPreg >= 450000>>
@@ -16673,6 +16676,7 @@ $He has
 	<<else>>
 		$activeSlave.pregType babies.
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 450000>>
 	$He looks @@.pink;absurdly pregnant.@@ $He stomach is massively stretched by $his overfilled <<print $activeSlave.bellyImplant>>cc belly implant.
 <<elseif $activeSlave.bellyPreg >= 300000>>
@@ -16701,6 +16705,7 @@ $He has
 	<<else>>
 		$activeSlave.pregType children.
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 300000>>
 	$He looks @@.pink;absurdly pregnant.@@ $He overburdened middle is filled by $his <<print $activeSlave.bellyImplant>>cc belly implant.
 <<elseif $activeSlave.bellyPreg >= 120000>>
@@ -16746,6 +16751,7 @@ $He has
 			ready to give birth to octuplets.
 		<</if>>
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 120000>>
 	$He looks @@.pink;obscenely pregnant with octuplets.@@ $He overburdened middle is filled by $his <<print $activeSlave.bellyImplant>>cc belly implant.
 <<elseif $activeSlave.bellyPreg >= 15000>>
@@ -17101,6 +17107,7 @@ $He has
 			<</if>>
 		<</if>>
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 105000>>
 	$He looks @@.pink;massively pregnant with septuplets.@@ $He greatly rounded middle is filled by $his <<print $activeSlave.bellyImplant>>cc belly implant.
 <<elseif $activeSlave.bellyImplant >= 90000>>
@@ -17148,6 +17155,7 @@ $He has
 			almost ready to give birth.
 		<</if>>
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 10000>>
 	$He looks @@.pink;hugely pregnant.@@ $He greatly rounded middle is filled by $his <<print $activeSlave.bellyImplant>>cc belly implant.
 <<elseif $activeSlave.bellyPreg >= 5000>>
@@ -17183,6 +17191,7 @@ $He has
 			the baby inside $him is growing rapidly.
 		<</if>>
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 5000>>
 	$He looks @@.pink;very pregnant.@@ $He rounded middle is filled by $his <<print $activeSlave.bellyImplant>>cc belly implant.
 <<elseif $activeSlave.bellyPreg >= 1500>>
@@ -17215,16 +17224,19 @@ $He has
 	<<else>>
 		@@.pink;visibly pregnant.@@
 	<</if>>
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant >= 1500>>
 	$He looks @@.pink;visibly pregnant.@@ $He rounded middle is caused by $his <<print $activeSlave.bellyImplant>>cc belly implant.
 <<elseif $activeSlave.bellyPreg >= 100>>
 	$He is @@.pink;pregnant@@ and just beginning to show, though it is hard to tell at a glance.
+	<<superfetationDesc>>
 <<elseif $activeSlave.bellyImplant > 0>>
 	$He has an abdominal implant, though it doesn't round out $his belly too much yet at a tiny <<print $activeSlave.bellyImplant>>ccs.
 <<elseif $activeSlave.bellyImplant == 0>>
 	$He has an abdominal implant, but it is completely empty.
 <<elseif $activeSlave.pregKnown == 1>>
 	$He is @@.pink;pregnant,@@ though it isn't visible yet.
+	<<superfetationDesc>>
 <<elseif $activeSlave.preg > 0 && $activeSlave.pregKnown == 0>>
 	$His period is late.
 <</if>>
@@ -17294,26 +17306,63 @@ $He has
 	<</if>>
 <</if>>
 <<if $activeSlave.pregKnown == 1 && $saleDescription == 0>>
-	<<if $activeSlave.pregSource == -7>>
-		$His womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>> modified children<<else>>a modified child<</if>> from the gene lab.
-	<<elseif $activeSlave.preg > $activeSlave.pregData.normalBirth/8>>
-		<<if $activeSlave.pregSource == -1>>
-			Tests show $his womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many of <</if>>your growing children<<else>>your growing child<</if>>.
-		<<elseif $activeSlave.pregSource == -2>>
-			Tests show $his womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>>children <<else>>a child <</if>>fathered by one of your citizens.
-		<<elseif $activeSlave.pregSource == -3>>
-			Tests show $his womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>>children <<else>>a child <</if>>fathered by your former Master. He was quite the busy man.
-		<<elseif $activeSlave.pregSource == -9>>
-			$His womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>>children <<else>>a child <</if>>fathered by the Futanari Sisters, given how far along $he is and $his history.
-		<<elseif $activeSlave.pregSource == 0>>
-			Tests are inconclusive on who fathered the <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>>children <<else>>child <</if>>growing in $his womb.
-		<<elseif $activeSlave.pregSource == $activeSlave.ID>>
-			Tests show $he did this to $himself.
-		<<else>>
-			Tests show $his womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many of <</if>><<print _daddy>>'s growing children<<else>><<print _daddy>>'s growing child<</if>>.
+	<<set _slaveWD = WombGetLittersData($activeSlave)>>
+	<<if $activeSlave.geneticQuirks.superfetation == 2 && _slaveWD.litters.length > 1>>
+		<<if $pregnancyMonitoringUpgrade != 1>>
+			<<set _sameFather = 1, _sameFatherID = _slaveWD.litterData[0][0].fatherID>>
+			<<for _litCount = 0; _litCount < _slaveWD.litters.length; _litCount++>>
+				<<if _slaveWD.litterData[_litCount][_litCount] != _sameFatherID>>
+					<<set _sameFather = 0>>
+					<<break>>
+				<</if>>
+			<</for>>
+			$His superfetation has resulted in multiple simultaneous pregnancies;
+			<<if _sameFather != 1>>
+				tests report multiple different sources.
+			<<else>>
+				<<if _slaveWD.litterData[_litCount][0].age > $activeSlave.pregData.normalBirth/8>>
+					all of them too young to tell the father of.
+				<<elseif $activeSlave.pregSource == -7>>
+					all of them modified children from the gene lab.
+				<<elseif $activeSlave.pregSource == -1>>
+					all of them yours.
+				<<elseif $activeSlave.pregSource == -2>>
+					all of them fathered by your citizens.
+				<<elseif $activeSlave.pregSource == -3>>
+					all of them fathered by your former Master. He was quite the busy man.
+				<<elseif $activeSlave.pregSource == -9>>
+					all of them fathered by the Futanari Sisters, given how far along $he is and $his history.
+				<<elseif $activeSlave.pregSource == 0>>
+					all of them of unidentifiable sources.
+				<<elseif $activeSlave.pregSource == $activeSlave.ID>>
+					all of them $his own.
+				<<else>>
+					all of them <<print _daddy>>'s.
+				<</if>>
+			<</if>>
 		<</if>>
 	<<else>>
-		It is too early to tell who exactly fathered the child growing in $his womb.
+		<<if $activeSlave.pregSource == -7>>
+			$His womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>> modified children<<else>>a modified child<</if>> from the gene lab.
+		<<elseif $activeSlave.preg > $activeSlave.pregData.normalBirth/8>>
+			<<if $activeSlave.pregSource == -1>>
+				Tests show $his womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many of <</if>>your growing children<<else>>your growing child<</if>>.
+			<<elseif $activeSlave.pregSource == -2>>
+				Tests show $his womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>>children <<else>>a child <</if>>fathered by one of your citizens.
+			<<elseif $activeSlave.pregSource == -3>>
+				Tests show $his womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>>children <<else>>a child <</if>>fathered by your former Master. He was quite the busy man.
+			<<elseif $activeSlave.pregSource == -9>>
+				$His womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>>children <<else>>a child <</if>>fathered by the Futanari Sisters, given how far along $he is and $his history.
+			<<elseif $activeSlave.pregSource == 0>>
+				Tests are inconclusive on who fathered the <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many <</if>>children <<else>>child <</if>>growing in $his womb.
+			<<elseif $activeSlave.pregSource == $activeSlave.ID>>
+				Tests show $he did this to $himself.
+			<<else>>
+				Tests show $his womb contains <<if $activeSlave.pregType > 1>><<if $activeSlave.pregType > 10>>many of <</if>><<print _daddy>>'s growing children<<else>><<print _daddy>>'s growing child<</if>>.
+			<</if>>
+		<<else>>
+			It is too early to tell who exactly fathered the child growing in $his womb.
+		<</if>>
 	<</if>>
 <</if>>
 <<if $activeSlave.bellyPreg > ($activeSlave.pregAdaptation*1000)>>
@@ -17326,6 +17375,132 @@ $He has
 
 <</widget>>
 
+<<widget "superfetationDesc">>
+
+<<set _slaveWD = WombGetLittersData($activeSlave)>>
+<<if $activeSlave.geneticQuirks.superfetation == 2 && _slaveWD.litters.length > 1 && $pregnancyMonitoringUpgrade == 1 && $saleDescription == 0>>
+
+$His womb contains <<= num(_slaveWD.litters.length)>> separate pregnancies;
+<<for _litCount = 0; _litCount < _slaveWD.litters.length; _litCount++>>
+	<<set _countLitter = _slaveWD.countLitter[_litCount]>>
+	<<set _is = _countLitter > 1 ? "are" : "is", _was = _countLitter > 1 ? "were" : "was">>
+	<<if _litCount == 0>>
+		the eldest
+		<<if _countLitter > 1>>
+			set of <<= num(_countLitter)>>,
+		<<else>>
+			one,
+		<</if>>
+		at _slaveWD.litters[_litCount] week<<if _slaveWD.litters[_litCount] > 1>>s<</if>> of development,
+		<<if _slaveWD.litterData[_litCount][0].fatherID == -7>>
+			_is from the gene lab,
+		<<elseif _slaveWD.litterData[_litCount][0].age > $activeSlave.pregData.normalBirth/8>>
+			<<if _slaveWD.litterData[_litCount][0].fatherID == -1>>
+				_was fathered by your seed,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -2>>
+				_was fathered by one of your citizens,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -3>>
+				_was fathered by your former Master,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -9>>
+				_was fathered by the Futanari Sisters,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == 0>>
+				_is from an indentifiable source,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == $activeSlave.ID>>
+				_is from $his own handiwork,
+			<<else>>
+				<<if _slaveWD.litterData[_litCount][0].fatherID > 0>>
+					<<set _lsd = findFather(_slaveWD.litterData[_litCount][0].fatherID)>>
+					<<if def _lsd>>
+						<<set _daddy = SlaveFullName(_lsd)>>
+					<<else>>
+						<<set _daddy = "another slave">>
+					<</if>>
+				<<elseif _slaveWD.litterData[_litCount][0].fatherID in $missingTable && $showMissingSlaves>>
+					<<set _daddy = $missingTable[$activeSlave.pregSource].fullName>>
+				<</if>>
+				_was fathered by <<print _daddy>>'s seed,
+			<</if>>
+		<<else>>
+			_is too young to tell the father of,
+		<</if>>
+	<<elseif _litCount == _slaveWD.litters.length-1>>
+		and the youngest
+		<<if _countLitter > 1>>
+			set of <<= num(_countLitter)>>,
+		<<else>>
+			one,
+		<</if>>
+		at _slaveWD.litters[_litCount] week<<if _slaveWD.litters[_litCount] > 1>>s<</if>> of development,
+		<<if _slaveWD.litterData[_litCount][0].fatherID == -7>>
+			_is from the gene lab.
+		<<elseif _slaveWD.litterData[_litCount][0].age > $activeSlave.pregData.normalBirth/8>>
+			<<if _slaveWD.litterData[_litCount][0].fatherID == -1>>
+				_was fathered by your seed.
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -2>>
+				_was fathered by one of your citizens.
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -3>>
+				_was fathered by your former Master. He was quite the busy man.
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -9>>
+				_was fathered by the Futanari Sisters.
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == 0>>
+				_is from an indentifiable source.
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == $activeSlave.ID>>
+				_is from $his own seed.
+			<<else>>
+				<<if _slaveWD.litterData[_litCount][0].fatherID > 0>>
+					<<set _lsd = findFather(_slaveWD.litterData[_litCount][0].fatherID)>>
+					<<if def _lsd>>
+						<<set _daddy = SlaveFullName(_lsd)>>
+					<<else>>
+						<<set _daddy = "another slave">>
+					<</if>>
+				<<elseif _slaveWD.litterData[_litCount][0].fatherID in $missingTable && $showMissingSlaves>>
+					<<set _daddy = $missingTable[$activeSlave.pregSource].fullName>>
+				<</if>>
+				_was fathered by <<print _daddy>>'s seed.
+			<</if>>
+		<<else>>
+			_is too young to tell the father of.
+		<</if>>
+	<<else>>
+		the next set of <<= num(_countLitter)>> at _slaveWD.litters[_litCount] week<<if _slaveWD.litters[_litCount] > 1>>s<</if>> of development
+		<<if _slaveWD.litterData[_litCount][0].fatherID == -7>>
+			_is from the gene lab,
+		<<elseif _slaveWD.litterData[_litCount][0].age > $activeSlave.pregData.normalBirth/8>>
+			<<if _slaveWD.litterData[_litCount][0].fatherID == -1>>
+				_was fathered by your seed,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -2>>
+				_was fathered by one of your citizens,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -3>>
+				_was fathered by your former Master,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == -9>>
+				_was fathered by the Futanari Sisters,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == 0>>
+				_is from an indentifiable source,
+			<<elseif _slaveWD.litterData[_litCount][0].fatherID == $activeSlave.ID>>
+				_is from $his own handiwork,
+			<<else>>
+				<<if _slaveWD.litterData[_litCount][0].fatherID > 0>>
+					<<set _lsd = findFather(_slaveWD.litterData[_litCount][0].fatherID)>>
+					<<if def _lsd>>
+						<<set _daddy = SlaveFullName(_lsd)>>
+					<<else>>
+						<<set _daddy = "another slave">>
+					<</if>>
+				<<elseif _slaveWD.litterData[_litCount][0].fatherID in $missingTable && $showMissingSlaves>>
+					<<set _daddy = $missingTable[$activeSlave.pregSource].fullName>>
+				<</if>>
+				_was fathered by <<print _daddy>>'s seed,
+			<</if>>
+		<<else>>
+			_is too young to tell the father of,
+		<</if>>
+	<</if>>
+<</for>>
+
+<</if>>
+
+<</widget>>
 
 <<widget "heelDescription">>
 
-- 
GitLab