From a81ae90a0464736fd191bcadb61bd877c293f944 Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Sat, 29 Aug 2020 18:27:49 -0700
Subject: [PATCH] Replace halfhearted impregnation check with canImpreg, fix up
 some JSDoc, and fix a bad jsRandom.

---
 src/js/statsChecker/statsChecker.js |   4 +-
 src/js/storyJS.js                   |  12 +-
 src/npc/generate/newSlaveIntro.js   | 203 ++++++++++++++--------------
 3 files changed, 108 insertions(+), 111 deletions(-)

diff --git a/src/js/statsChecker/statsChecker.js b/src/js/statsChecker/statsChecker.js
index afb63c489bc..a0143692a45 100644
--- a/src/js/statsChecker/statsChecker.js
+++ b/src/js/statsChecker/statsChecker.js
@@ -619,7 +619,7 @@ globalThis.isEliteBreeder = function(slave) {
 };
 
 /**
- * @param {App.Entity.SlaveState} slave
+ * @param {App.Entity.SlaveState|App.Entity.PlayerState} slave
  * @returns {boolean}
  */
 globalThis.canGetPregnant = function(slave) {
@@ -639,7 +639,7 @@ globalThis.canGetPregnant = function(slave) {
 };
 
 /** contraceptives (.preg === -1) do not negate this function
- * @param {App.Entity.SlaveState} slave
+ * @param {App.Entity.SlaveState|App.Entity.PlayerState} slave
  * @returns {boolean}
  */
 globalThis.isFertile = function(slave) {
diff --git a/src/js/storyJS.js b/src/js/storyJS.js
index f33c613061c..f975ebf56eb 100644
--- a/src/js/storyJS.js
+++ b/src/js/storyJS.js
@@ -69,8 +69,8 @@ globalThis.filterInPlace = function(arr, callback, thisArg) {
 };
 
 /** pregmod: are slave2's sperm compatible with slave1's eggs?
- * @param {App.Entity.SlaveState} slave1
- * @param {App.Entity.SlaveState} slave2
+ * @param {App.Entity.SlaveState|App.Entity.PlayerState} slave1
+ * @param {App.Entity.SlaveState|App.Entity.PlayerState} slave2
  * @returns {boolean}
  */
 globalThis.canBreed = function(slave1, slave2) {
@@ -83,8 +83,8 @@ globalThis.canBreed = function(slave1, slave2) {
 /** assuming slave1 is fertile, could slave2 impregnate slave1?
  * slave2 must have dick and balls with compatible sperm;
  * both slaves must not be in chastity; slave2 need not achieve erection
- * @param {App.Entity.SlaveState} slave1
- * @param {App.Entity.SlaveState} slave2
+ * @param {App.Entity.SlaveState|App.Entity.PlayerState} slave1
+ * @param {App.Entity.SlaveState|App.Entity.PlayerState} slave2
  * @returns {boolean}
  */
 globalThis.canImpreg = function(slave1, slave2) {
@@ -114,8 +114,8 @@ globalThis.canImpreg = function(slave1, slave2) {
 /** assuming slave1 is fertile, could slave2 impregnate slave1?
  * slave2 must have balls with compatible sperm;
  * a special function intended for tribbing scenes;
- * @param {App.Entity.SlaveState} slave1
- * @param {App.Entity.SlaveState} slave2
+ * @param {App.Entity.SlaveState|App.Entity.PlayerState} slave1
+ * @param {App.Entity.SlaveState|App.Entity.PlayerState} slave2
  * @returns {boolean}
  */
 globalThis.canFemImpreg = function(slave1, slave2) {
diff --git a/src/npc/generate/newSlaveIntro.js b/src/npc/generate/newSlaveIntro.js
index 176cdd9a7e5..ce40d4138e0 100644
--- a/src/npc/generate/newSlaveIntro.js
+++ b/src/npc/generate/newSlaveIntro.js
@@ -788,7 +788,7 @@ App.UI.newSlaveIntro = function(slave, slave2 = V.eventSlave) {
 		if (slave.devotion < -50 && slave.rudeTitle !== 1) {
 			if (jsRandom(-100, 0) >= slave.devotion) {
 				slave.rudeTitle = 1;
-				slave.custom.title = setup.badNames.jsRandom();
+				slave.custom.title = setup.badNames.random();
 				slave.custom.titleLisp = lispReplace(slave.custom.title);
 			}
 		}
@@ -2518,117 +2518,114 @@ App.UI.newSlaveIntro = function(slave, slave2 = V.eventSlave) {
 				});
 			}
 
-			if (V.seePreg !== 0) {
-				if (isFertile(slave) && slave.womb.length === 0 && V.PC.dick !== 0 && slave.eggType === "human") {
-					choice({
-						linkName: `Impregnate ${him}`,
-						result(slave) {
-							const el = new DocumentFragment();
-							let r = [];
-							r.push(`You perform a careful medical examination to verify fertility, and then`);
-							if (slave.devotion > 20 || slave.trust < -20) {
-								r.push(`lay the obedient ${desc} across your desk`);
-							} else {
-								r.push(`restrain the resistant ${desc} in your office with ${his} ass in the air`);
-							}
-							r.push(`and gently slide your hard cock`);
-							if (slave.mpreg === 1) {
-								r.push(`up ${his} butt.`);
-							} else {
-								r.push(`inside ${his} womanhood.`);
-							}
-							r.push(`You take ${him} with care, enjoying ${his} body`);
-							if (slave.devotion > 20 || slave.trust < -20) {
-								r.push(`and doing your best to give ${him} pleasure, too.`);
-							} else {
-								r.push(`without hurting ${him}.`);
-							}
-							r.push(`You empty your balls inside ${him}, thrusting in as far as you can go as you climax. When ${he} feels the hot liquid jet into ${him},`);
-							if (slave.devotion > 20) {
-								if (slave.fetish === "pregnancy") {
-									if (slave.fetishKnown === 0) {
-										r.push(`${he} gasps with unaccustomed pleasure, and climaxes so strongly that ${he} cries a little from the pain in ${his} flexing abs. <span class="green">${He}'s an impregnation fetishist!</span>`);
-										slave.fetishKnown = 1;
-									} else {
-										r.push(`${he} climaxes, ${his} impregnation fetish displayed cutely on ${his} face.`);
-									}
-									r.push(`As you ${him} go, ${he} feels your cum dripping out of ${him}, and ${he} <span class="hotpink">feels like your property.</span>`);
-									slave.devotion += 5;
+			if (V.seePreg !== 0 && canImpreg(slave, V.PC)) {
+				choice({
+					linkName: `Impregnate ${him}`,
+					result(slave) {
+						const el = new DocumentFragment();
+						let r = [];
+						r.push(`You perform a careful medical examination to verify fertility, and then`);
+						if (slave.devotion > 20 || slave.trust < -20) {
+							r.push(`lay the obedient ${desc} across your desk`);
+						} else {
+							r.push(`restrain the resistant ${desc} in your office with ${his} ass in the air`);
+						}
+						r.push(`and gently slide your hard cock`);
+						if (slave.mpreg === 1) {
+							r.push(`up ${his} butt.`);
+						} else {
+							r.push(`inside ${his} womanhood.`);
+						}
+						r.push(`You take ${him} with care, enjoying ${his} body`);
+						if (slave.devotion > 20 || slave.trust < -20) {
+							r.push(`and doing your best to give ${him} pleasure, too.`);
+						} else {
+							r.push(`without hurting ${him}.`);
+						}
+						r.push(`You empty your balls inside ${him}, thrusting in as far as you can go as you climax. When ${he} feels the hot liquid jet into ${him},`);
+						if (slave.devotion > 20) {
+							if (slave.fetish === "pregnancy") {
+								if (slave.fetishKnown === 0) {
+									r.push(`${he} gasps with unaccustomed pleasure, and climaxes so strongly that ${he} cries a little from the pain in ${his} flexing abs. <span class="green">${He}'s an impregnation fetishist!</span>`);
+									slave.fetishKnown = 1;
 								} else {
-									r.push(`${he} gasps and does ${his} best to relax, accepting the flow.`);
-									if (slave.fetishKnown === 0) {
-										r.push(`It seems ${he}`);
-									} else {
-										r.push(`${He}`);
-									}
-									r.push(`isn't an impregnation fetishist, but ${he} is <span class="hotpink">willing to submit</span> to have ${his} body used as your receptacle.`);
-									slave.devotion += 4;
+									r.push(`${he} climaxes, ${his} impregnation fetish displayed cutely on ${his} face.`);
 								}
+								r.push(`As you ${him} go, ${he} feels your cum dripping out of ${him}, and ${he} <span class="hotpink">feels like your property.</span>`);
+								slave.devotion += 5;
 							} else {
-								if (slave.fetish === "pregnancy") {
-									if (slave.fetishKnown === 0) {
-										r.push(`${he} shudders with a sensation of perverted pleasure, and climaxes despite all ${his} feelings about the situation. <span class="green">${He}'s an impregnation fetishist!</span>`);
-										slave.fetishKnown = 1;
-									} else {
-										r.push(`${he} climaxes, ${his} impregnation fetish forcing ${him} to feel pleasure ${his} mind would prefer to reject.`);
-									}
-									r.push(`As you ${him} go, ${he} cries openly, your cum dripping out of ${him}, and ${he} <span class="hotpink">feels like your property.</span>`);
-									slave.devotion += 4;
+								r.push(`${he} gasps and does ${his} best to relax, accepting the flow.`);
+								if (slave.fetishKnown === 0) {
+									r.push(`It seems ${he}`);
 								} else {
-									r.push(`${he} groans and struggles a little, disgusted to be filled by your fluids so immediately.`);
-									if (slave.fetishKnown === 0) {
-										r.push(`It seems ${he}`);
-									} else {
-										r.push(`${He}`);
-									}
-									r.push(`isn't an impregnation fetishist, and is <span class="gold">afraid</span> that ${he}'ll be treated as nothing more than your receptacle.`);
-									slave.trust -= 4;
+									r.push(`${He}`);
 								}
+								r.push(`isn't an impregnation fetishist, but ${he} is <span class="hotpink">willing to submit</span> to have ${his} body used as your receptacle.`);
+								slave.devotion += 4;
 							}
-
-							App.UI.DOM.appendNewElement("p", el, r.join(" "));
-							r = [];
-							r.push(`Whenever you feel able, you drain your balls into ${his}`);
-							if (slave.mpreg === 1) {
-								r.push(`ass,`);
-							} else {
-								r.push(`cunt,`);
-							}
-							r.push(`only releasing ${him} for other duties when scans verify a fertilized ovum.`);
-							if (slave.intelligence + slave.intelligenceImplant < -50) {
-								r.push(`${He} didn't properly understand the scans, so ${he} just thought it was bound, forced sex; ${he} won't realize what happened for some weeks at least.`);
-							} else if (slave.fetish === "pregnancy") {
-								r.push(`${He} is thrilled to imagine ${he} might be pregnant.`);
-							} else {
-								r.push(`${He} wasn't sure what this was all about, but ${he} has ${his} suspicions.`);
-							}
-							if (slave.mpreg === 1) {
-								r.push(VCheck.Anal());
+						} else {
+							if (slave.fetish === "pregnancy") {
+								if (slave.fetishKnown === 0) {
+									r.push(`${he} shudders with a sensation of perverted pleasure, and climaxes despite all ${his} feelings about the situation. <span class="green">${He}'s an impregnation fetishist!</span>`);
+									slave.fetishKnown = 1;
+								} else {
+									r.push(`${he} climaxes, ${his} impregnation fetish forcing ${him} to feel pleasure ${his} mind would prefer to reject.`);
+								}
+								r.push(`As you ${him} go, ${he} cries openly, your cum dripping out of ${him}, and ${he} <span class="hotpink">feels like your property.</span>`);
+								slave.devotion += 4;
 							} else {
-								r.push(VCheck.Vaginal());
-							}
-							if (V.arcologies[0].FSRestart !== "unset" && V.eugenicsFullControl !== 1) {
-								r.push(`The Societal Elite <span class="green">disapprove</span> of this breach of eugenics.`);
-								V.failedElite += 5;
-							} else if (V.arcologies[0].FSGenderFundamentalist !== "unset" && slave.mpreg === 0) {
-								r.push(`Society <span class="green">approves</span> of your promptly putting a new slave in ${him}; this advances the idea that all slaves should bear their masters' babies.`);
-								FutureSocieties.Change("GenderFundamentalist", 2);
-							} else if (V.arcologies[0].FSGenderFundamentalist !== "unset") {
-								r.push(`Society <span class="red">is disgusted</span> by you promptly knocking up ${his} ass; babies come from women, not men.`);
-								FutureSocieties.Change("GenderFundamentalist", -2);
+								r.push(`${he} groans and struggles a little, disgusted to be filled by your fluids so immediately.`);
+								if (slave.fetishKnown === 0) {
+									r.push(`It seems ${he}`);
+								} else {
+									r.push(`${He}`);
+								}
+								r.push(`isn't an impregnation fetishist, and is <span class="gold">afraid</span> that ${he}'ll be treated as nothing more than your receptacle.`);
+								slave.trust -= 4;
 							}
-							App.UI.DOM.appendNewElement("p", el, r.join(" "));
-							slave.preg = 1;
-							slave.pregType = setPregType(slave);
-							slave.pregWeek = 1;
-							slave.pregKnown = 1;
-							slave.pregSource = -1;
-							WombImpregnate(slave, slave.pregType, -1, 1);
-							return el;
-						},
+						}
 
-					});
-				}
+						App.UI.DOM.appendNewElement("p", el, r.join(" "));
+						r = [];
+						r.push(`Whenever you feel able, you drain your balls into ${his}`);
+						if (slave.mpreg === 1) {
+							r.push(`ass,`);
+						} else {
+							r.push(`cunt,`);
+						}
+						r.push(`only releasing ${him} for other duties when scans verify a fertilized ovum.`);
+						if (slave.intelligence + slave.intelligenceImplant < -50) {
+							r.push(`${He} didn't properly understand the scans, so ${he} just thought it was bound, forced sex; ${he} won't realize what happened for some weeks at least.`);
+						} else if (slave.fetish === "pregnancy") {
+							r.push(`${He} is thrilled to imagine ${he} might be pregnant.`);
+						} else {
+							r.push(`${He} wasn't sure what this was all about, but ${he} has ${his} suspicions.`);
+						}
+						if (slave.mpreg === 1) {
+							r.push(VCheck.Anal());
+						} else {
+							r.push(VCheck.Vaginal());
+						}
+						if (V.arcologies[0].FSRestart !== "unset" && V.eugenicsFullControl !== 1) {
+							r.push(`The Societal Elite <span class="green">disapprove</span> of this breach of eugenics.`);
+							V.failedElite += 5;
+						} else if (V.arcologies[0].FSGenderFundamentalist !== "unset" && slave.mpreg === 0) {
+							r.push(`Society <span class="green">approves</span> of your promptly putting a new slave in ${him}; this advances the idea that all slaves should bear their masters' babies.`);
+							FutureSocieties.Change("GenderFundamentalist", 2);
+						} else if (V.arcologies[0].FSGenderFundamentalist !== "unset") {
+							r.push(`Society <span class="red">is disgusted</span> by you promptly knocking up ${his} ass; babies come from women, not men.`);
+							FutureSocieties.Change("GenderFundamentalist", -2);
+						}
+						App.UI.DOM.appendNewElement("p", el, r.join(" "));
+						slave.preg = 1;
+						slave.pregType = setPregType(slave);
+						slave.pregWeek = 1;
+						slave.pregKnown = 1;
+						slave.pregSource = -1;
+						WombImpregnate(slave, slave.pregType, -1, 1);
+						return el;
+					},
+				});
 			}
 			lineBreak();
 			if (slave.vagina === 0) {
-- 
GitLab