From a3b38277ab2b194cb5cfad31bf53174d9aca9d9c Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Wed, 3 Feb 2021 23:50:12 -0500
Subject: [PATCH] return to activeSlave

---
 src/npc/startingGirls/startingGirls.js        |   5 +-
 src/npc/startingGirls/startingGirlsPassage.js | 181 +++++++++---------
 2 files changed, 94 insertions(+), 92 deletions(-)

diff --git a/src/npc/startingGirls/startingGirls.js b/src/npc/startingGirls/startingGirls.js
index e404cc4bbdf..b5b72936050 100644
--- a/src/npc/startingGirls/startingGirls.js
+++ b/src/npc/startingGirls/startingGirls.js
@@ -1445,7 +1445,8 @@ App.StartingGirls.skills = function(slave) {
 App.StartingGirls.finalize = function(slave) {
 	const el = new DocumentFragment();
 	const {him} = getPronouns(slave);
-	if (V.cash >= startingSlaveCost(slave)) {
+	const cost = startingSlaveCost(slave);
+	if (V.cash >= cost) {
 		let r = [];
 		if (V.PC.career !== "engineer" && V.PC.career !== "construction" && V.PC.career !== "worksite helper") {
 			r.push(
@@ -1500,6 +1501,8 @@ App.StartingGirls.finalize = function(slave) {
 			),
 			"indent"
 		);
+	} else {
+		App.UI.DOM.appendNewElement("p", el, `Cannot afford the cost of ${cashFormat(cost)}`, "red");
 	}
 	return el;
 };
diff --git a/src/npc/startingGirls/startingGirlsPassage.js b/src/npc/startingGirls/startingGirlsPassage.js
index fc350c1d748..f7116d7c87e 100644
--- a/src/npc/startingGirls/startingGirlsPassage.js
+++ b/src/npc/startingGirls/startingGirlsPassage.js
@@ -2,7 +2,6 @@ App.StartingGirls.passage = function() {
 	if (!V.activeSlave) {
 		V.activeSlave = App.StartingGirls.generate();
 	}
-	let slave = V.activeSlave;
 	const el = new DocumentFragment();
 	let r = [];
 	let linkArray = [];
@@ -43,7 +42,7 @@ App.StartingGirls.passage = function() {
 		App.UI.DOM.link(
 			"Randomize career",
 			() => {
-				slave.career = randomCareer(slave);
+				V.activeSlave.career = randomCareer(V.activeSlave);
 			},
 			[],
 			"Starting Girls"
@@ -54,8 +53,8 @@ App.StartingGirls.passage = function() {
 		App.UI.DOM.link(
 			"Randomize name",
 			() => {
-				nationalityToName(slave);
-				slave.slaveName = slave.birthName;
+				nationalityToName(V.activeSlave);
+				V.activeSlave.slaveName = V.activeSlave.birthName;
 			},
 			[],
 			"Starting Girls"
@@ -66,7 +65,7 @@ App.StartingGirls.passage = function() {
 		App.UI.DOM.link(
 			"Start over with a random slave",
 			() => {
-				slave = App.StartingGirls.generate();
+				V.activeSlave = App.StartingGirls.generate();
 			},
 			[],
 			"Starting Girls"
@@ -82,11 +81,11 @@ App.StartingGirls.passage = function() {
 				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
 					"Irish Rose",
 					() => {
-						slave = App.StartingGirls.generate({nationality: "Irish", race: "white"});
-						slave.eye.origColor = "green";
-						slave.origSkin = "fair";
-						slave.origHColor = "red";
-						slave.markings = "heavily freckled";
+						V.activeSlave = App.StartingGirls.generate({nationality: "Irish", race: "white"});
+						V.activeSlave.eye.origColor = "green";
+						V.activeSlave.origSkin = "fair";
+						V.activeSlave.origHColor = "red";
+						V.activeSlave.markings = "heavily freckled";
 					},
 					[],
 					"Starting Girls"
@@ -96,16 +95,16 @@ App.StartingGirls.passage = function() {
 				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
 					"Cali Girl",
 					() => {
-						slave = App.StartingGirls.generate({nationality: "American"});
-						slave.eye.origColor = "blue";
-						slave.skin = "sun tanned";
-						slave.override_Skin = 1;
-						slave.origHColor = "blonde";
-						slave.markings = "none";
-						slave.face = 95;
-						slave.muscles = 20;
-						slave.weight = -20;
-						slave.height = Math.round(Height.forAge(190, slave));
+						V.activeSlave = App.StartingGirls.generate({nationality: "American"});
+						V.activeSlave.eye.origColor = "blue";
+						V.activeSlave.skin = "sun tanned";
+						V.activeSlave.override_Skin = 1;
+						V.activeSlave.origHColor = "blonde";
+						V.activeSlave.markings = "none";
+						V.activeSlave.face = 95;
+						V.activeSlave.muscles = 20;
+						V.activeSlave.weight = -20;
+						V.activeSlave.height = Math.round(Height.forAge(190, V.activeSlave));
 					},
 					[],
 					"Starting Girls"
@@ -115,18 +114,18 @@ App.StartingGirls.passage = function() {
 				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
 					"Novice",
 					() => {
-						slave = App.StartingGirls.generate();
-						slave.skill.anal = 0;
-						slave.skill.oral = 0;
-						slave.skill.vaginal = 0;
-						slave.skill.whoring = 0;
-						slave.skill.entertainment = 0;
-						slave.skill.combat = 0;
-						slave.actualAge = 18;
-						slave.visualAge = 18;
-						slave.physicalAge = 18;
-						slave.fetishKnown = 0;
-						slave.attrKnown = 0;
+						V.activeSlave = App.StartingGirls.generate();
+						V.activeSlave.skill.anal = 0;
+						V.activeSlave.skill.oral = 0;
+						V.activeSlave.skill.vaginal = 0;
+						V.activeSlave.skill.whoring = 0;
+						V.activeSlave.skill.entertainment = 0;
+						V.activeSlave.skill.combat = 0;
+						V.activeSlave.actualAge = 18;
+						V.activeSlave.visualAge = 18;
+						V.activeSlave.physicalAge = 18;
+						V.activeSlave.fetishKnown = 0;
+						V.activeSlave.attrKnown = 0;
 					},
 					[],
 					"Starting Girls"
@@ -136,10 +135,10 @@ App.StartingGirls.passage = function() {
 				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
 					"Head Girl Prospect",
 					() => {
-						slave = App.StartingGirls.generate({minAge: 36, maxAge: 44});
-						slave.career = App.Data.Careers.Leader.HG.random();
-						slave.intelligence = 70;
-						slave.intelligenceImplant = 0;
+						V.activeSlave = App.StartingGirls.generate({minAge: 36, maxAge: 44});
+						V.activeSlave.career = App.Data.Careers.Leader.HG.random();
+						V.activeSlave.intelligence = 70;
+						V.activeSlave.intelligenceImplant = 0;
 					},
 					[],
 					"Starting Girls"
@@ -151,28 +150,28 @@ App.StartingGirls.passage = function() {
 					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
 						"Wellspring",
 						() => {
-							slave = App.StartingGirls.generate({minAge: 18, maxAge: 18});
-							slave.skill.anal = 0;
-							slave.skill.oral = 0;
-							slave.skill.vaginal = 0;
-							slave.skill.whoring = 0;
-							slave.skill.entertainment = 0;
-							slave.skill.combat = 0;
-							slave.fetishKnown = 0;
-							slave.attrKnown = 0;
-							slave.health.condition = 10;
-							slave.intelligence = -100;
-							slave.intelligenceImplant = 0;
-							slave.vagina = 3;
-							slave.anus = 3;
-							slave.ovaries = 1;
-							slave.dick = 5;
-							slave.balls = 5;
-							slave.prostate = 1;
-							slave.lactation = 2;
-							slave.lactationDuration = 2;
-							slave.nipples = "huge";
-							slave.boobs = 10000;
+							V.activeSlave = App.StartingGirls.generate({minAge: 18, maxAge: 18});
+							V.activeSlave.skill.anal = 0;
+							V.activeSlave.skill.oral = 0;
+							V.activeSlave.skill.vaginal = 0;
+							V.activeSlave.skill.whoring = 0;
+							V.activeSlave.skill.entertainment = 0;
+							V.activeSlave.skill.combat = 0;
+							V.activeSlave.fetishKnown = 0;
+							V.activeSlave.attrKnown = 0;
+							V.activeSlave.health.condition = 10;
+							V.activeSlave.intelligence = -100;
+							V.activeSlave.intelligenceImplant = 0;
+							V.activeSlave.vagina = 3;
+							V.activeSlave.anus = 3;
+							V.activeSlave.ovaries = 1;
+							V.activeSlave.dick = 5;
+							V.activeSlave.balls = 5;
+							V.activeSlave.prostate = 1;
+							V.activeSlave.lactation = 2;
+							V.activeSlave.lactationDuration = 2;
+							V.activeSlave.nipples = "huge";
+							V.activeSlave.boobs = 10000;
 						},
 						[],
 						"Starting Girls"
@@ -182,18 +181,18 @@ App.StartingGirls.passage = function() {
 					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
 						"Onahole",
 						() => {
-							slave = App.StartingGirls.generate();
-							slave.skill.anal = 0;
-							slave.skill.oral = 0;
-							slave.skill.vaginal = 0;
-							slave.skill.whoring = 0;
-							slave.skill.entertainment = 0;
-							slave.skill.combat = 0;
-							slave.fetish = "mindbroken";
-							slave.voice = 0;
-							slave.hears = 0;
-							removeLimbs(slave, "all");
-							eyeSurgery(slave, "both", "normal");
+							V.activeSlave = App.StartingGirls.generate();
+							V.activeSlave.skill.anal = 0;
+							V.activeSlave.skill.oral = 0;
+							V.activeSlave.skill.vaginal = 0;
+							V.activeSlave.skill.whoring = 0;
+							V.activeSlave.skill.entertainment = 0;
+							V.activeSlave.skill.combat = 0;
+							V.activeSlave.fetish = "mindbroken";
+							V.activeSlave.voice = 0;
+							V.activeSlave.hears = 0;
+							removeLimbs(V.activeSlave, "all");
+							eyeSurgery(V.activeSlave, "both", "normal");
 						},
 						[],
 						"Starting Girls"
@@ -219,7 +218,7 @@ App.StartingGirls.passage = function() {
 						App.UI.DOM.link(
 							nation,
 							() => {
-								slave = App.StartingGirls.generate({nationality: nation});
+								V.activeSlave = App.StartingGirls.generate({nationality: nation});
 							},
 							[],
 							"Starting Girls"
@@ -242,33 +241,33 @@ App.StartingGirls.passage = function() {
 
 	App.StartingGirls.cleanup(V.activeSlave);
 
-	if (slave.father === -1) {
+	if (V.activeSlave.father === -1) {
 		if (V.PC.dick === 0) {
-			slave.father = 0;
-		} else if ((V.PC.actualAge - slave.actualAge) < V.minimumSlaveAge || ((V.PC.actualAge - slave.actualAge) < V.potencyAge)) {
-			slave.father = 0;
+			V.activeSlave.father = 0;
+		} else if ((V.PC.actualAge - V.activeSlave.actualAge) < V.minimumSlaveAge || ((V.PC.actualAge - V.activeSlave.actualAge) < V.potencyAge)) {
+			V.activeSlave.father = 0;
 		}
 		if (V.saveImported === 1) {
-			slave.father = 0;
+			V.activeSlave.father = 0;
 		}
 	}
-	if (slave.mother === -1) {
+	if (V.activeSlave.mother === -1) {
 		if (V.PC.vagina === -1) {
-			slave.mother = 0;
-		} else if (((V.PC.actualAge - slave.actualAge) < V.minimumSlaveAge) || ((V.PC.actualAge - slave.actualAge) < V.fertilityAge)) {
-			slave.mother = 0;
+			V.activeSlave.mother = 0;
+		} else if (((V.PC.actualAge - V.activeSlave.actualAge) < V.minimumSlaveAge) || ((V.PC.actualAge - V.activeSlave.actualAge) < V.fertilityAge)) {
+			V.activeSlave.mother = 0;
 		}
 		if (V.saveImported === 1) {
-			slave.mother = 0;
+			V.activeSlave.mother = 0;
 		}
 	}
 	/* this block makes starting girls actually apply the slave origins, mostly since it just hates you and everything you do */
 	if (V.originOverride !== 1) {
-		App.StartingGirls.applyPlayerOrigin(slave);
+		App.StartingGirls.applyPlayerOrigin(V.activeSlave);
 	}
 
 	App.UI.DOM.appendNewElement("h2", el, "You are customizing this slave:");
-	el.append(App.Desc.longSlave(slave, {market: "generic"}));
+	el.append(App.Desc.longSlave(V.activeSlave, {market: "generic"}));
 
 	// TODO: move me
 	/**
@@ -307,14 +306,14 @@ App.StartingGirls.passage = function() {
 		App.UI.tabBar.tabButton('finalize', tabCaptions.finalize),
 	);
 
-	el.append(App.UI.tabBar.makeTab('profile', makeSpanIded("content-profile", App.StartingGirls.profile(slave))));
-	el.append(App.UI.tabBar.makeTab('physical', makeSpanIded("content-physical", App.StartingGirls.physical(slave))));
-	el.append(App.UI.tabBar.makeTab('mental', makeSpanIded("content-mental", App.StartingGirls.mental(slave))));
-	el.append(App.UI.tabBar.makeTab('skills', makeSpanIded("content-skills", App.StartingGirls.skills(slave))));
-	el.append(App.UI.tabBar.makeTab('family', makeSpanIded("content-family", App.Intro.editFamily(slave))));
-	el.append(App.UI.tabBar.makeTab('body-mods', makeSpanIded("content-body-mods", App.UI.bodyModification(slave, true))));
-	el.append(App.UI.tabBar.makeTab('salon', makeSpanIded("content-salon", App.UI.salon(slave, true))));
-	el.append(App.UI.tabBar.makeTab('finalize', makeSpanIded("content-finalize", App.StartingGirls.finalize(slave))));
+	el.append(App.UI.tabBar.makeTab('profile', makeSpanIded("content-profile", App.StartingGirls.profile(V.activeSlave))));
+	el.append(App.UI.tabBar.makeTab('physical', makeSpanIded("content-physical", App.StartingGirls.physical(V.activeSlave))));
+	el.append(App.UI.tabBar.makeTab('mental', makeSpanIded("content-mental", App.StartingGirls.mental(V.activeSlave))));
+	el.append(App.UI.tabBar.makeTab('skills', makeSpanIded("content-skills", App.StartingGirls.skills(V.activeSlave))));
+	el.append(App.UI.tabBar.makeTab('family', makeSpanIded("content-family", App.Intro.editFamily(V.activeSlave))));
+	el.append(App.UI.tabBar.makeTab('body-mods', makeSpanIded("content-body-mods", App.UI.bodyModification(V.activeSlave, true))));
+	el.append(App.UI.tabBar.makeTab('salon', makeSpanIded("content-salon", App.UI.salon(V.activeSlave, true))));
+	el.append(App.UI.tabBar.makeTab('finalize', makeSpanIded("content-finalize", App.StartingGirls.finalize(V.activeSlave))));
 
 	return el;
 };
-- 
GitLab