From 49c9317b444cd8d7b0a5dae9cc91208b9b88b0d4 Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Wed, 21 Nov 2018 03:43:02 -0500
Subject: [PATCH] breeding mark stuff

---
 devNotes/twine JS.txt                 | 29 +++++++++++++++++++++++++--
 src/pregmod/analyzePlayerPregnancy.tw |  2 +-
 src/pregmod/analyzePregnancy.tw       |  2 +-
 src/pregmod/surrogacyWorkaround.tw    |  2 +-
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt
index 8a251f6b725..95d2355c9dc 100644
--- a/devNotes/twine JS.txt	
+++ b/devNotes/twine JS.txt	
@@ -324,7 +324,7 @@ window.isFertile = function(slave) {
 	if (slave.womb.length > 0 && slave.geneticQuirks.superfetation < 2 && slave.ovaImplant < 1) { /* currently pregnant without superfetation */
 		return false;
 	} else if (slave.womb.length > 0) { /* temp failure condition to prevent current double preg bug */
-		return false;
+	    return false;
 	} else if (slave.broodmother > 0) { /* currently broodmother */
 		return false;
 	} else if (slave.preg < -1) { /* sterile */
@@ -987,6 +987,19 @@ window.SoftenSexualFlaw = function SoftenSexualFlaw(slave) {
 	slave.sexualFlaw = "none";
 };
 
+window.genUUID = function() {
+    var d = new Date().getTime();
+    if(Date.now){
+        d = Date.now(); //high-precision timer
+    }
+    var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+        var r = (d + Math.random()*16)%16 | 0;
+        d = Math.floor(d/16);
+        return (c=='x' ? r : (r&0x3|0x8)).toString(16);
+    });
+    return uuid;
+};
+
 /*:: itemAvailability [script]*/
 
 /* intended to condense the clothing/toy/etc availability checks into something less asinine */
@@ -10916,6 +10929,7 @@ window.WombImpregnate = function(actor, fCount, fatherID, age) {
 		tf.identical = 0; //Initial, to create property. Updated with actual data during fetalSplit call.
         tf.splitted = 0; //marker for already splitted fetus.
 		tf.genetics = generateGenetics(actor, fatherID, i+1); //Stored genetic information.
+        tf.ID = genUUID();
 
 		try {
 			if (actor.womb.length == 0) {
@@ -11188,7 +11202,14 @@ window.fetalSplit = function(actor, chance) {
             s.splitted = 1; //this is marker that this is already splitted fetus (to not split second time in loop), only source fetus needed it.
             nft.identical = 1; //this is marker that this fetus has at least one twin.
             s.identical = 1; //this is marker that this fetus has at least one twin.
-			actor.womb.push(nft);
+
+            if (s.twinID == "" || s.twinID == undefined)
+                s.twinID = genUUID();
+
+            nft.twinID = s.twinID;
+
+            actor.womb.push(nft);
+
 		}
 	});
 	WombNormalizePreg(actor);
@@ -11432,6 +11453,10 @@ window.BCReserveInit = function()
                 ft.reserve = "";
                 if (typeof ft.motherID != 'number') //setting missing biological mother ID for fetus.
                     ft.motherID = slave.ID; 
+
+                if (ft.ID == undefined)
+                    ft.ID = genUUID();
+
             try {
                     if (slave.reservedChildren > 0)
                         WombSetGenericReserve(slave, "incubator", reservedChildren);
diff --git a/src/pregmod/analyzePlayerPregnancy.tw b/src/pregmod/analyzePlayerPregnancy.tw
index 54312276a75..ff1a0cbee13 100644
--- a/src/pregmod/analyzePlayerPregnancy.tw
+++ b/src/pregmod/analyzePlayerPregnancy.tw
@@ -178,7 +178,7 @@ Deep scan:
 	<br><br>&nbsp;&nbsp;&nbsp;&nbsp;
 	
 	Rename: <<textbox "_tempName" _tempName >> [[Apply | Analyze Pregnancy][$PC.womb[_ap].genetics.name = _tempName]]
-	<<if $PC.womb[_ap].age < 4>>
+	<<if $PC.womb[_ap].age < 4 && $PC.womb[_ap].fatherID != -6>>
 		<br>&nbsp;&nbsp;&nbsp;&nbsp;
 		<<link "Terminate ovum" "Analyze Pregnancy">><<run WombRemoveFetus($PC, _ap)>><</link>>
 	<</if>>
diff --git a/src/pregmod/analyzePregnancy.tw b/src/pregmod/analyzePregnancy.tw
index beb3213c65b..fa2cd3a65d0 100644
--- a/src/pregmod/analyzePregnancy.tw
+++ b/src/pregmod/analyzePregnancy.tw
@@ -182,7 +182,7 @@ Deep scan:
 	<br><br>&nbsp;&nbsp;&nbsp;&nbsp;
 	
 	Rename: <<textbox "_tempName" _tempName >> [[Apply | Analyze Pregnancy][$activeSlave.womb[_ap].genetics.name = _tempName]]
-	<<if $activeSlave.womb[_ap].age < 4>>
+	<<if $activeSlave.womb[_ap].age < 4 && ($activeSlave.womb[_ap].fatherID != -1 || $activeSlave.breedingMark == 0)>>
 		<br>&nbsp;&nbsp;&nbsp;&nbsp;
 		<<link "Terminate ovum" "Analyze Pregnancy">><<run WombRemoveFetus($activeSlave, _ap)>><</link>>
 	<</if>>
diff --git a/src/pregmod/surrogacyWorkaround.tw b/src/pregmod/surrogacyWorkaround.tw
index e2f8fe30c28..10cab8752e7 100644
--- a/src/pregmod/surrogacyWorkaround.tw
+++ b/src/pregmod/surrogacyWorkaround.tw
@@ -68,7 +68,7 @@ __Chosen surrogate: _recieve __
 
 <<for _sw1 = 0; _sw1 < $slaves.length; _sw1++>>
 <<capture _sw1>>
-	<<if ($slaves[_sw1].ovaries > 0 || $slaves[_sw1].mpreg > 0) && isSlaveAvailable($slaves[_sw1]) && $slaves[_sw1].preg >= 0 && $slaves[_sw1].preg < 4 && $slaves[_sw1].pubertyXX == 1>>
+	<<if ($slaves[_sw1].ovaries > 0 || $slaves[_sw1].mpreg > 0) && isSlaveAvailable($slaves[_sw1]) && $slaves[_sw1].preg >= 0 && $slaves[_sw1].preg < 4 && $slaves[_sw1].pregWeek >= 0 && $slaves[_sw1].pubertyXX == 1 && $slaves[_sw1].bellyImplant != -1 && $slaves[_sw1].broodmother == 0 && $slaves[_sw1].inflation <= 2 && $slaves[_sw1].ovaryAge < 47>>
 		<<set _name2 = SlaveFullName($slaves[_sw1])>>
 		<br><<print "[[_name2|Surrogacy Workaround][$receptrix = $slaves[" + _sw1 + "]]]">>
 		<<set _eligibility2 = 1>>
-- 
GitLab