From 37a18d07b93d0a39e1019acebef9e4e690dd5828 Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Sat, 17 Nov 2018 14:35:09 -0500
Subject: [PATCH] fixes and new function to remove duplicates in arrays.

---
 devNotes/Useful JS Function Documentation.txt |  4 ++-
 devNotes/twine JS.txt                         |  4 +++
 src/js/utilJS.tw                              |  4 +++
 src/pregmod/sePlayerBirth.tw                  | 27 +++++++++++++++++--
 src/uncategorized/slaveInteract.tw            |  2 +-
 5 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/devNotes/Useful JS Function Documentation.txt b/devNotes/Useful JS Function Documentation.txt
index 65241f61101..f5cc80a9a67 100644
--- a/devNotes/Useful JS Function Documentation.txt	
+++ b/devNotes/Useful JS Function Documentation.txt	
@@ -343,4 +343,6 @@ UtilJS [script]
 	FSChangePorn() - //Currently unused, widget version routes directly through FSChange()
 
 	ordinalSuffix(i) - takes a value as an input and then appends the appoperiate suffix. e.g.$Day === 1 "today is the <<print ordinalSuffix($Day)>> of the month"
-		would print "today is the 1st of the month"
\ No newline at end of file
+		would print "today is the 1st of the month"
+		
+	removeDuplicates() - Takes an array and returns a new array without duplicate entries
\ No newline at end of file
diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt
index a9fa3a1e256..a91d37abdd7 100644
--- a/devNotes/twine JS.txt	
+++ b/devNotes/twine JS.txt	
@@ -4234,6 +4234,10 @@ window.ordinalSuffix = function ordinalSuffix(i) {
 	return i + "th";
 }
 
+window.removeDuplicates = function removeDuplicates(array) {
+	return [new Set(array)];
+}
+
 /*:: Span Macro JS [script]*/
 
 /*
diff --git a/src/js/utilJS.tw b/src/js/utilJS.tw
index b2c3ac6e22c..e58c17c71d6 100644
--- a/src/js/utilJS.tw
+++ b/src/js/utilJS.tw
@@ -1048,4 +1048,8 @@ window.ordinalSuffix = function ordinalSuffix(i) {
 		return i + "rd";
 	}
 	return i + "th";
+}
+
+window.removeDuplicates = function removeDuplicates(array) {
+	return [new Set(array)];
 }
\ No newline at end of file
diff --git a/src/pregmod/sePlayerBirth.tw b/src/pregmod/sePlayerBirth.tw
index 99b85873ab7..a7d78a02de5 100644
--- a/src/pregmod/sePlayerBirth.tw
+++ b/src/pregmod/sePlayerBirth.tw
@@ -42,34 +42,43 @@ PC.pregSource documentation
 <<set $PC.preg = 0, $PC.pregKnown = 0, $PC.labor = 0, $PC.births += _curBabies>>
 
 /* setting the tallies for each type of child born */
-<<set _others = 0, _self = 0, _citizens = 0, _oldMaster = 0, _arcOwner = 0, _clients = 0, _elite = 0, _lab = 0, _slaveFathers = [], _slavesLength = 0>>
+<<set _others = 0, _self = 0, _citizens = 0, _oldMaster = 0, _arcOwner = 0, _clients = 0, _elite = 0, _lab = 0, _slavesLength = 0, _babies = []>>
 <<for _spb = 0; _spb < $PC.curBabies.length; _spb++>>
 	<<if $PC.curBabies[_spb].fatherID == 0>>
 		<<set _others++>>
+		<<set _babies.push("some guy")>>
 	<<elseif $PC.curBabies[_spb].fatherID == -1>>
 		<<set _self++>>
+		<<set _babies.push("your own")>>
 	<<elseif $PC.curBabies[_spb].fatherID == -2>>
 		<<set _citizens++>>
+		<<set _babies.push("the arcology's citizen")>>
 	<<elseif $PC.curBabies[_spb].fatherID == -3>>
 		<<set _oldMaster++>>
+		<<set _babies.push("your Master")>>
 	<<elseif $PC.curBabies[_spb].fatherID == -4>>
 		<<set _arcOwner++>>
+		<<set _babies.push("another arcology owner")>>
 	<<elseif $PC.curBabies[_spb].fatherID == -5>>
 		<<set _clients++>>
+		<<set _babies.push("your client")>>
 	<<elseif $PC.curBabies[_spb].fatherID == -6>>
 		<<set _elite++>>
 	<<elseif $PC.curBabies[_spb].fatherID == -7>>
 		<<set _lab++>>
+		<<set _babies.push("designer")>>
 	<<else>>
 		<<set _babyDaddy = $slaveIndices[$PC.curBabies[_spb].fatherID]>>
 		<<if def _babyDaddy>>
-			<<set _slaveFathers.push($slaves[_babyDaddy])>>
 			<<set _slavesLength++>>
+			<<set _babies.push(String($slaves[_babyDaddy].slaveName))>>
 		<<else>>
 			<<set _others++>>
+			<<set _babies.push("some guy")>>
 		<</if>>
 	<</if>>
 <</if>>
+<<set _babiesReduced = removeDuplicates(_babies)>>
 
 <<if _elite > 0>> /* for simplicity's sake, not going to allow other embryos to be added during a elite pregnancy */
 	Since you are heavily pregnant with a child of the Societal Elite, you are quickly taken to the finest clinic the arcology has to offer. After a quick sedation, you awake to find your belly no longer round with child; that and a note stating your next breeding partner and a notice that <<print cashFormat(50000)>> has been added to your account. The Societal Elite are @@.green;very pleased@@ at their new addition to the ranks. You just wish you could have seen your <<if _curBabies == 1>>little <<if _gender == "XX">>girl<<else>>boy<</if>> before they took <<if _gender == "XX">>her<<else>>him<</if>><<else>>babies before they took them<</if>> away to be raised into a proper member of the future world.
@@ -549,6 +558,20 @@ You arrange yourself to give birth, relaxing until your body urges you to begin
 			<</for>>
 		<</if>>
 
+		All in all, you've bought a healthy group of
+		<<if _babiesReduced.length > 2>>
+			<<for _spb = 0; _spb < _babiesReduced.length; _spb++>>
+				<<if _spb < _babiesReduced.length-1>>
+					_babiesReduced[_spb],
+				<<else>>
+					and _babiesReduced[_spb]'s
+				<</if>>
+			<</for>>
+		<<else>>
+			_babiesReduced[0] and _babiesReduced[1]'s
+		<</if>>
+		babies into the world.
+		
 	<</if>>
 
 
diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw
index 94cd40a6e49..c61fde71d2a 100644
--- a/src/uncategorized/slaveInteract.tw
+++ b/src/uncategorized/slaveInteract.tw
@@ -1,4 +1,4 @@
-Slave Interact [nobr]
+:: Slave Interact [nobr]
 
 <<if $cheatMode == 1>>
 	<center>//[[Cheat Edit Slave|MOD_Edit Slave Cheat][$cheater = 1]] | [[Cheat Edit Slave Alternative|MOD_Edit Slave Cheat New][$cheater = 1]]//</center>
-- 
GitLab