From 81b12fe6293fbbba1885414a7f66ef5518a6d055 Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 6 Dec 2021 19:31:10 -0500
Subject: [PATCH 1/5] Allow fluids calculation for all kinds of humans, not
 just slaves.  PCs are unaffected by devotion/health penalty.

---
 src/js/storyJS.js | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/src/js/storyJS.js b/src/js/storyJS.js
index 5b8a851fbe5..f006246493c 100644
--- a/src/js/storyJS.js
+++ b/src/js/storyJS.js
@@ -140,16 +140,12 @@ globalThis.canFemImpreg = function(slave1, slave2) {
 };
 
 /**
- * @param {App.Entity.SlaveState | App.Entity.PlayerState} slave
+ * @param {FC.HumanState} slave
  * @returns {number}
  */
 globalThis.milkAmount = function(slave) {
 	let milk;
-	let calcs;
-	if (!slave) {
-		return null;
-	}
-	calcs = slave.boobs - slave.boobsImplant - slave.boobsMilk;
+	let calcs = slave.boobs - slave.boobsImplant - slave.boobsMilk;
 	if (calcs > 40000) {
 		milk = (158 + ((calcs - 40000) / 600));
 	} else if (calcs > 25000) {
@@ -184,22 +180,21 @@ globalThis.milkAmount = function(slave) {
 	milk *= (1 + (slave.weight / 500));
 	milk *= (1 + (slave.lactationAdaptation / 500));
 	milk += (slave.boobsMilk / 100);
-	milk *= healthPenalty(slave);
+	const realSlave = asSlave(slave); // PC milk output is unaltered by health penalties
+	if (realSlave) {
+		milk *= healthPenalty(realSlave);
+	}
 	milk = Math.trunc(milk);
 	milk = Math.clamp(milk, 1, 1000000000000000000);
 	return milk;
 };
 
 /**
- * @param {App.Entity.SlaveState} slave
+ * @param {FC.HumanState} slave
  * @returns {number}
  */
 globalThis.cumAmount = function(slave) {
 	let cum = 0;
-	let calcs = 0;
-	if (!slave) {
-		return null;
-	}
 	if (slave.drugs === "testicle enhancement") {
 		cum = ((slave.balls * 3.5) + 1);
 	} else if (slave.drugs === "hyper testicle enhancement") {
@@ -213,7 +208,7 @@ globalThis.cumAmount = function(slave) {
 	if (slave.diet === "cum production") {
 		cum *= 1.2;
 	}
-	calcs = (slave.hormoneBalance / 50);
+	const calcs = (slave.hormoneBalance / 50);
 	cum *= (1 - (calcs * 0.1));
 	if (slave.scrotum === 0) {
 		cum *= 0.8;
@@ -225,17 +220,20 @@ globalThis.cumAmount = function(slave) {
 	} else if (slave.prostate === 3) {
 		cum *= 1.5;
 	}
-	if (slave.devotion > 50) {
-		cum += (cum * (slave.devotion / 100));
-	} else if (slave.devotion < -50) {
-		cum += (cum * (slave.devotion / 100));
-	}
 	if (slave.health.condition > 50) {
 		cum += (cum * (slave.health.condition / 50));
 	} else if (slave.health.condition < -50) {
 		cum += (cum * (slave.health.condition / 50));
 	}
-	cum *= healthPenalty(slave);
+	const realSlave = asSlave(slave); // PC cum output is unaltered by devotion/health penalties
+	if (realSlave) {
+		if (slave.devotion > 50) {
+			cum += (cum * (slave.devotion / 100));
+		} else if (slave.devotion < -50) {
+			cum += (cum * (slave.devotion / 100));
+		}
+		cum *= healthPenalty(realSlave);
+	}
 	cum = Math.trunc(cum);
 	cum = Math.clamp(cum, 1, 1000000000000000000);
 	return cum;
@@ -243,14 +241,11 @@ globalThis.cumAmount = function(slave) {
 
 /**
  * The amount of fem cum a slave produces in deciliters
- * @param {App.Entity.SlaveState} slave
+ * @param {FC.HumanState} slave
  * @returns {number}
  */
 globalThis.girlCumAmount = function(slave) {
 	let fluid = ((slave.prostate * (slave.energy / 5)) + 1);
-	if (!slave) {
-		return null;
-	}
 	if (slave.vagina >= 0) {
 		if (slave.vaginaLube === 2) {
 			fluid *= 1.3;
-- 
GitLab


From eda80b3aaa26eb000d82d68cb2034e401014d74a Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 6 Dec 2021 19:49:54 -0500
Subject: [PATCH 2/5] 1. Remove PC.sexualEnergy and calculate it when needed.
 2. Simplify calculations in saPleaseYou.  Notably, use cumAmount instead of
 sexualEnergy to estimate PC cum for cumsluts.

---
 .../backwardsCompatibility.js                 |  1 -
 .../backwardsCompatibility/datatypeCleanup.js |  4 +-
 src/endWeek/endWeek.js                        | 60 ----------------
 src/endWeek/saPleaseYou.js                    | 47 +++++++------
 src/endWeek/slaveAssignmentReport.js          |  2 +-
 src/events/intro/pcAppearance.js              |  1 -
 src/js/storyJS.js                             |  1 +
 src/js/utilsPC.js                             | 68 +++++++++++++++++++
 src/player/js/PlayerState.js                  |  4 --
 9 files changed, 97 insertions(+), 91 deletions(-)

diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js
index c5540e649d1..4756f91b2a7 100644
--- a/src/data/backwardsCompatibility/backwardsCompatibility.js
+++ b/src/data/backwardsCompatibility/backwardsCompatibility.js
@@ -2074,7 +2074,6 @@ App.Update.oldVersions = function(node) {
 		newPC.counter.slavesFathered = V.PC.slavesFathered;
 		newPC.counter.slavesKnockedUp = V.PC.slavesKnockedUp;
 		newPC.counter.storedCum = V.PC.storedCum;
-		newPC.sexualEnergy = V.PC.sexualEnergy;
 		newPC.staminaPills = V.PC.staminaPills;
 		newPC.preg = V.PC.preg;
 		newPC.pregType = V.PC.pregType;
diff --git a/src/data/backwardsCompatibility/datatypeCleanup.js b/src/data/backwardsCompatibility/datatypeCleanup.js
index ab3522a1934..b4283090a1a 100644
--- a/src/data/backwardsCompatibility/datatypeCleanup.js
+++ b/src/data/backwardsCompatibility/datatypeCleanup.js
@@ -1607,8 +1607,8 @@ globalThis.PCDatatypeCleanup = (function PCDatatypeCleanup() {
 	 * @param {App.Entity.PlayerState} PC
 	 */
 	function PCPreferencesDatatypeCleanup(PC) {
-		if (PC.sexualEnergy !== 0) {
-			PC.sexualEnergy = +PC.sexualEnergy || 4;
+		if (PC.hasOwnProperty("sexualEnergy")) {
+			delete PC.sexualEnergy;
 		}
 		PC.energy = Math.clamp(+PC.energy, 0, 100) || 80;
 		PC.need = Math.max(+PC.need, 0) || 0;
diff --git a/src/endWeek/endWeek.js b/src/endWeek/endWeek.js
index 8e627d3daa1..ebb42ba1880 100644
--- a/src/endWeek/endWeek.js
+++ b/src/endWeek/endWeek.js
@@ -188,66 +188,6 @@ globalThis.endWeek = (function() {
 	}
 
 	function PC() {
-		V.PC.sexualEnergy = 4;
-		if (V.PCSlutContacts === 2) {
-			V.PC.sexualEnergy -= 3;
-		}
-		if (V.personalAttention.task === PersonalAttention.SEX) {
-			V.PC.sexualEnergy += 2;
-		}
-		if (V.PC.physicalAge >= 80) {
-			V.PC.sexualEnergy -= 6;
-		} else if (V.PC.physicalAge >= 72) {
-			V.PC.sexualEnergy -= 5;
-		} else if (V.PC.physicalAge >= 65) {
-			V.PC.sexualEnergy -= 4;
-		} else if (V.PC.physicalAge >= 58) {
-			V.PC.sexualEnergy -= 3;
-		} else if (V.PC.physicalAge >= 50) {
-			V.PC.sexualEnergy -= 2;
-		} else if (V.PC.physicalAge >= 42) {
-			V.PC.sexualEnergy -= 1;
-		} else if (V.PC.physicalAge >= 35) {
-			V.PC.sexualEnergy += 0;
-		} else if (V.PC.physicalAge >= 31) {
-			V.PC.sexualEnergy += 1;
-		} else if (V.PC.physicalAge >= 28) {
-			V.PC.sexualEnergy += 2;
-		} else if (V.PC.physicalAge >= 21) {
-			V.PC.sexualEnergy += 3;
-		} else if (V.PC.physicalAge >= 13) {
-			V.PC.sexualEnergy += 4;
-		} else if (V.PC.physicalAge === 12) {
-			V.PC.sexualEnergy += 1;
-		} else if (V.PC.physicalAge === 11) {
-			V.PC.sexualEnergy -= 2;
-		} else if (V.PC.physicalAge >= 0) {
-			V.PC.sexualEnergy -= 6;
-		}
-		if (V.PC.balls >= 10) {
-			V.PC.sexualEnergy += 2;
-		} else if (V.PC.balls >= 5) {
-			V.PC.sexualEnergy++;
-		}
-		if (V.PC.preg > 20) {
-			if (V.PC.pregMood === 2) {
-				V.PC.sexualEnergy += 4;
-			} else {
-				V.PC.sexualEnergy -= 3;
-			}
-		} else if (V.PC.preg > 0) {
-			V.PC.sexualEnergy -= 1;
-		} else {
-			if (V.PC.fertDrugs === 1) {
-				V.PC.sexualEnergy++;
-			}
-			if (V.PC.forcedFertDrugs > 0) {
-				V.PC.sexualEnergy += 2;
-			}
-		}
-		if (V.PC.staminaPills > 0) {
-			V.PC.sexualEnergy += 2;
-		}
 		if (V.PC.preg > 0) {
 			WombProgress(V.PC, 1, 1);
 			WombNormalizePreg(V.PC);
diff --git a/src/endWeek/saPleaseYou.js b/src/endWeek/saPleaseYou.js
index b4235526dff..d3ca7369630 100644
--- a/src/endWeek/saPleaseYou.js
+++ b/src/endWeek/saPleaseYou.js
@@ -25,6 +25,7 @@ App.SlaveAssignment.pleaseYou = (function() {
 	let cervixPump;
 	let acts;
 	let demand;
+	let energyUseRatio;
 
 	let fuckSlavesCount;
 
@@ -39,6 +40,7 @@ App.SlaveAssignment.pleaseYou = (function() {
 		fetishChange = fetishChangeChance(slave);
 		arcology = V.arcologies[0];
 		fuckSlavesCount = fuckSlavesLength();
+		energyUseRatio = fuckSlavesCount / basePCSexualEnergy();
 
 		oralUse = 0;
 		analUse = 0;
@@ -119,9 +121,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useVagina(slave) {
-		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+		if (energyUseRatio < 0.5) {
 			vaginalUse = jsRandom(21, 40);
-		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+		} else if (energyUseRatio < 1.0) {
 			vaginalUse = jsRandom(7, 14);
 		} else {
 			vaginalUse = jsRandom(3, 7);
@@ -278,9 +280,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useAnus(slave) {
-		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+		if (energyUseRatio < 0.5) {
 			analUse = jsRandom(21, 40);
-		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+		} else if (energyUseRatio < 1.0) {
 			analUse = jsRandom(7, 14);
 		} else {
 			analUse = jsRandom(3, 7);
@@ -431,9 +433,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useMouth(slave) {
-		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+		if (energyUseRatio < 0.5) {
 			oralUse = jsRandom(21, 40);
-		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+		} else if (energyUseRatio < 1.0) {
 			oralUse = jsRandom(7, 14);
 		} else {
 			oralUse = jsRandom(3, 7);
@@ -488,9 +490,10 @@ App.SlaveAssignment.pleaseYou = (function() {
 				if (V.PC.vagina !== -1) {
 					r.push(`face covered in your pussy juice.`);
 				}
-				if (V.PC.dick !== 0 && (fuckSlavesCount <= (V.PC.sexualEnergy / 2 + (V.PC.balls - 3)))) {
+				const cumPerSlave = cumAmount(V.PC) / fuckSlavesCount; // deciliters per week
+				if (V.PC.dick !== 0 && cumPerSlave > 14) {
 					r.push(`Your balls produce so much cum for ${him} that ${he} has replaced half ${his} diet with your cum, and you often leave ${him} dizzy with a face and chest covered in your sticky pearly semen.`);
-				} else if (V.PC.dick !== 0 && (fuckSlavesCount <= (V.PC.sexualEnergy + (V.PC.balls - 3)))) {
+				} else if (V.PC.dick !== 0 && cumPerSlave > 7) {
 					r.push(`Your balls produce enough cum that ${he} usually gets facials after a mouthful of semen, and ${he} loves you for it.`);
 				} else {
 					r.push(`${He} usually has to fight for ${his} share of cum, making sure to milk cum from your`);
@@ -682,9 +685,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useBoobs(slave) {
-		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+		if (energyUseRatio < 0.5) {
 			mammaryUse = jsRandom(21, 40);
-		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+		} else if (energyUseRatio < 1.0) {
 			mammaryUse = jsRandom(7, 14);
 		} else {
 			mammaryUse = jsRandom(3, 7);
@@ -901,9 +904,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useDick(slave) {
-		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+		if (energyUseRatio < 0.5) {
 			penetrativeUse = jsRandom(21, 40);
-		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+		} else if (energyUseRatio < 1.0) {
 			penetrativeUse = jsRandom(7, 14);
 		} else {
 			penetrativeUse = jsRandom(3, 7);
@@ -1290,11 +1293,11 @@ App.SlaveAssignment.pleaseYou = (function() {
 				r.push(`${He} comes indecently hard whenever ${his} beloved ${getWrittenTitle(slave)} uses ${his} body.`);
 			}
 			r.push(`You have the sexual energy to fuck ${him}`);
-			if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+			if (energyUseRatio < 0.5) {
 				r.push(`several times a day; constant,`);
 				slave.devotion += 3;
 				slave.trust += 3;
-			} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+			} else if (energyUseRatio < 1.0) {
 				r.push(`at least once a day; regular,`);
 				slave.devotion += 2;
 				slave.trust += 2;
@@ -1310,11 +1313,11 @@ App.SlaveAssignment.pleaseYou = (function() {
 				r.push(`By the end of the week ${he} gets a hard-on when you use ${him}.`);
 			}
 			r.push(`You have the sexual energy to fuck ${him}`);
-			if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+			if (energyUseRatio < 0.5) {
 				r.push(`several times a day; constant,`);
 				slave.devotion += 3;
 				slave.trust += 3;
-			} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+			} else if (energyUseRatio < 1.0) {
 				r.push(`at least once a day; regular,`);
 				slave.devotion += 2;
 				slave.trust += 2;
@@ -1359,10 +1362,10 @@ App.SlaveAssignment.pleaseYou = (function() {
 				r.push(`By the end of the week ${he} gets a hard-on when you use ${him}.`);
 			}
 			r.push(`You have the sexual energy to fuck ${him}`);
-			if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+			if (energyUseRatio < 0.5) {
 				r.push(`several times a day; submitting to your constant`);
 				slave.devotion += 3;
-			} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+			} else if (energyUseRatio < 1.0) {
 				r.push(`at least once a day; submitting to your regular`);
 				slave.devotion += 2;
 			} else {
@@ -1376,11 +1379,11 @@ App.SlaveAssignment.pleaseYou = (function() {
 				r.push(`${His} dick stays limp as you rape ${him}.`);
 			}
 			r.push(`You have the sexual energy to fuck ${him}`);
-			if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+			if (energyUseRatio < 0.5) {
 				r.push(`several times a day; the constant`);
 				slave.devotion -= 5;
 				slave.trust -= 15;
-			} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+			} else if (energyUseRatio < 1.0) {
 				r.push(`at least once a day; the regular`);
 				slave.devotion -= 3;
 				slave.trust -= 9;
@@ -1392,9 +1395,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 			r.push(`rape fills ${him} with <span class="mediumorchid">revulsion</span> and <span class="gold">fear.</span>`);
 		}
 
-		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
+		if (energyUseRatio < 0.5) {
 			acts = jsRandom(21, 40);
-		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
+		} else if (energyUseRatio < 1.0) {
 			acts = jsRandom(7, 14);
 		} else {
 			acts = jsRandom(3, 7);
diff --git a/src/endWeek/slaveAssignmentReport.js b/src/endWeek/slaveAssignmentReport.js
index 4f02ad93f8f..245bb061b6c 100644
--- a/src/endWeek/slaveAssignmentReport.js
+++ b/src/endWeek/slaveAssignmentReport.js
@@ -211,7 +211,7 @@ App.EndWeek.slaveAssignmentReport = function() {
 	if (App.EndWeek.saVars.averageDick > 0) {
 		App.EndWeek.saVars.averageDick = App.EndWeek.saVars.averageDick / slavesWithWorkingDicks;
 	}
-	App.EndWeek.saVars.freeSexualEnergy = V.PC.sexualEnergy - fuckSlavesLength();
+	App.EndWeek.saVars.freeSexualEnergy = basePCSexualEnergy() - fuckSlavesLength();
 	const penthouseSlaves = App.Entity.facilities.penthouse.employees().length;
 	if (App.EndWeek.saVars.freeSexualEnergy > 0) {
 		if (App.EndWeek.saVars.freeSexualEnergy > penthouseSlaves / 2) {
diff --git a/src/events/intro/pcAppearance.js b/src/events/intro/pcAppearance.js
index 07206f540ec..d86122ddd11 100644
--- a/src/events/intro/pcAppearance.js
+++ b/src/events/intro/pcAppearance.js
@@ -1205,7 +1205,6 @@ App.UI.Player.design = function() {
 		// Potential
 		App.UI.DOM.appendNewElement("h2", el, "Misc");
 		options = new App.UI.OptionsGroup();
-		options.addOption(`Sexual Energy`, "sexualEnergy", V.PC).showTextBox();
 		options.addOption(`Cum Tap`, "cumTap", V.PC.skill).showTextBox();
 		options.addOption(`Stored Cum`, "storedCum", V.PC.counter).showTextBox();
 		options.addOption(`Fertility Drugs`, "fertDrugs", V.PC)
diff --git a/src/js/storyJS.js b/src/js/storyJS.js
index f006246493c..9a729d414cf 100644
--- a/src/js/storyJS.js
+++ b/src/js/storyJS.js
@@ -190,6 +190,7 @@ globalThis.milkAmount = function(slave) {
 };
 
 /**
+ * The amount of cum a slave produces in deciliters
  * @param {FC.HumanState} slave
  * @returns {number}
  */
diff --git a/src/js/utilsPC.js b/src/js/utilsPC.js
index 535ff207d6a..d15d4b89643 100644
--- a/src/js/utilsPC.js
+++ b/src/js/utilsPC.js
@@ -672,3 +672,71 @@ globalThis.isPCCareerInCategory = function(category) {
 		return false;
 	}
 };
+
+/**
+ * Calculate the base amount of sexual energy the PC has
+ * @returns {number}
+ */
+globalThis.basePCSexualEnergy = function() {
+	let energy = 4;
+	if (V.PCSlutContacts === 2) {
+		energy -= 3;
+	}
+	if (V.personalAttention.task === PersonalAttention.SEX) {
+		energy += 2;
+	}
+	if (V.PC.physicalAge >= 80) {
+		energy -= 6;
+	} else if (V.PC.physicalAge >= 72) {
+		energy -= 5;
+	} else if (V.PC.physicalAge >= 65) {
+		energy -= 4;
+	} else if (V.PC.physicalAge >= 58) {
+		energy -= 3;
+	} else if (V.PC.physicalAge >= 50) {
+		energy -= 2;
+	} else if (V.PC.physicalAge >= 42) {
+		energy -= 1;
+	} else if (V.PC.physicalAge >= 35) {
+		energy += 0;
+	} else if (V.PC.physicalAge >= 31) {
+		energy += 1;
+	} else if (V.PC.physicalAge >= 28) {
+		energy += 2;
+	} else if (V.PC.physicalAge >= 21) {
+		energy += 3;
+	} else if (V.PC.physicalAge >= 13) {
+		energy += 4;
+	} else if (V.PC.physicalAge === 12) {
+		energy += 1;
+	} else if (V.PC.physicalAge === 11) {
+		energy -= 2;
+	} else if (V.PC.physicalAge >= 0) {
+		energy -= 6;
+	}
+	if (V.PC.balls >= 10) {
+		energy += 2;
+	} else if (V.PC.balls >= 5) {
+		energy++;
+	}
+	if (V.PC.preg > 20) {
+		if (V.PC.pregMood === 2) {
+			energy += 4;
+		} else {
+			energy -= 3;
+		}
+	} else if (V.PC.preg > 0) {
+		energy -= 1;
+	} else {
+		if (V.PC.fertDrugs === 1) {
+			energy++;
+		}
+		if (V.PC.forcedFertDrugs > 0) {
+			energy += 2;
+		}
+	}
+	if (V.PC.staminaPills > 0) {
+		energy += 2;
+	}
+	return energy;
+};
diff --git a/src/player/js/PlayerState.js b/src/player/js/PlayerState.js
index f11ed16acd9..9dfbef8c869 100644
--- a/src/player/js/PlayerState.js
+++ b/src/player/js/PlayerState.js
@@ -1448,10 +1448,6 @@ App.Entity.PlayerState = class PlayerState {
 		 * * 30: well educated
 		 */
 		this.intelligenceImplant = 30;
-		/**
-		 * how much fucking you can do in a week
-		 */
-		this.sexualEnergy = 4; // split this into the following two variables somehow
 		/**
 		 * sex drive
 		 * * 0 - 20: no sex drive
-- 
GitLab


From 6cef80f4b0e15ac25c5c5ae2c83f9b8e16b7a8a4 Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 6 Dec 2021 20:43:10 -0500
Subject: [PATCH 3/5] Revert PC sexual energy changes, leaving fluid changes
 only (hopefully)

---
 .../backwardsCompatibility.js                 |  1 +
 .../backwardsCompatibility/datatypeCleanup.js |  4 +-
 src/endWeek/endWeek.js                        | 60 ++++++++++++++++
 src/endWeek/saPleaseYou.js                    | 42 ++++++------
 src/endWeek/slaveAssignmentReport.js          |  2 +-
 src/events/intro/pcAppearance.js              |  1 +
 src/js/utilsPC.js                             | 68 -------------------
 src/player/js/PlayerState.js                  |  4 ++
 8 files changed, 89 insertions(+), 93 deletions(-)

diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js
index 4756f91b2a7..c5540e649d1 100644
--- a/src/data/backwardsCompatibility/backwardsCompatibility.js
+++ b/src/data/backwardsCompatibility/backwardsCompatibility.js
@@ -2074,6 +2074,7 @@ App.Update.oldVersions = function(node) {
 		newPC.counter.slavesFathered = V.PC.slavesFathered;
 		newPC.counter.slavesKnockedUp = V.PC.slavesKnockedUp;
 		newPC.counter.storedCum = V.PC.storedCum;
+		newPC.sexualEnergy = V.PC.sexualEnergy;
 		newPC.staminaPills = V.PC.staminaPills;
 		newPC.preg = V.PC.preg;
 		newPC.pregType = V.PC.pregType;
diff --git a/src/data/backwardsCompatibility/datatypeCleanup.js b/src/data/backwardsCompatibility/datatypeCleanup.js
index b4283090a1a..ab3522a1934 100644
--- a/src/data/backwardsCompatibility/datatypeCleanup.js
+++ b/src/data/backwardsCompatibility/datatypeCleanup.js
@@ -1607,8 +1607,8 @@ globalThis.PCDatatypeCleanup = (function PCDatatypeCleanup() {
 	 * @param {App.Entity.PlayerState} PC
 	 */
 	function PCPreferencesDatatypeCleanup(PC) {
-		if (PC.hasOwnProperty("sexualEnergy")) {
-			delete PC.sexualEnergy;
+		if (PC.sexualEnergy !== 0) {
+			PC.sexualEnergy = +PC.sexualEnergy || 4;
 		}
 		PC.energy = Math.clamp(+PC.energy, 0, 100) || 80;
 		PC.need = Math.max(+PC.need, 0) || 0;
diff --git a/src/endWeek/endWeek.js b/src/endWeek/endWeek.js
index ebb42ba1880..8e627d3daa1 100644
--- a/src/endWeek/endWeek.js
+++ b/src/endWeek/endWeek.js
@@ -188,6 +188,66 @@ globalThis.endWeek = (function() {
 	}
 
 	function PC() {
+		V.PC.sexualEnergy = 4;
+		if (V.PCSlutContacts === 2) {
+			V.PC.sexualEnergy -= 3;
+		}
+		if (V.personalAttention.task === PersonalAttention.SEX) {
+			V.PC.sexualEnergy += 2;
+		}
+		if (V.PC.physicalAge >= 80) {
+			V.PC.sexualEnergy -= 6;
+		} else if (V.PC.physicalAge >= 72) {
+			V.PC.sexualEnergy -= 5;
+		} else if (V.PC.physicalAge >= 65) {
+			V.PC.sexualEnergy -= 4;
+		} else if (V.PC.physicalAge >= 58) {
+			V.PC.sexualEnergy -= 3;
+		} else if (V.PC.physicalAge >= 50) {
+			V.PC.sexualEnergy -= 2;
+		} else if (V.PC.physicalAge >= 42) {
+			V.PC.sexualEnergy -= 1;
+		} else if (V.PC.physicalAge >= 35) {
+			V.PC.sexualEnergy += 0;
+		} else if (V.PC.physicalAge >= 31) {
+			V.PC.sexualEnergy += 1;
+		} else if (V.PC.physicalAge >= 28) {
+			V.PC.sexualEnergy += 2;
+		} else if (V.PC.physicalAge >= 21) {
+			V.PC.sexualEnergy += 3;
+		} else if (V.PC.physicalAge >= 13) {
+			V.PC.sexualEnergy += 4;
+		} else if (V.PC.physicalAge === 12) {
+			V.PC.sexualEnergy += 1;
+		} else if (V.PC.physicalAge === 11) {
+			V.PC.sexualEnergy -= 2;
+		} else if (V.PC.physicalAge >= 0) {
+			V.PC.sexualEnergy -= 6;
+		}
+		if (V.PC.balls >= 10) {
+			V.PC.sexualEnergy += 2;
+		} else if (V.PC.balls >= 5) {
+			V.PC.sexualEnergy++;
+		}
+		if (V.PC.preg > 20) {
+			if (V.PC.pregMood === 2) {
+				V.PC.sexualEnergy += 4;
+			} else {
+				V.PC.sexualEnergy -= 3;
+			}
+		} else if (V.PC.preg > 0) {
+			V.PC.sexualEnergy -= 1;
+		} else {
+			if (V.PC.fertDrugs === 1) {
+				V.PC.sexualEnergy++;
+			}
+			if (V.PC.forcedFertDrugs > 0) {
+				V.PC.sexualEnergy += 2;
+			}
+		}
+		if (V.PC.staminaPills > 0) {
+			V.PC.sexualEnergy += 2;
+		}
 		if (V.PC.preg > 0) {
 			WombProgress(V.PC, 1, 1);
 			WombNormalizePreg(V.PC);
diff --git a/src/endWeek/saPleaseYou.js b/src/endWeek/saPleaseYou.js
index d3ca7369630..395bcf4fd1c 100644
--- a/src/endWeek/saPleaseYou.js
+++ b/src/endWeek/saPleaseYou.js
@@ -25,7 +25,6 @@ App.SlaveAssignment.pleaseYou = (function() {
 	let cervixPump;
 	let acts;
 	let demand;
-	let energyUseRatio;
 
 	let fuckSlavesCount;
 
@@ -40,7 +39,6 @@ App.SlaveAssignment.pleaseYou = (function() {
 		fetishChange = fetishChangeChance(slave);
 		arcology = V.arcologies[0];
 		fuckSlavesCount = fuckSlavesLength();
-		energyUseRatio = fuckSlavesCount / basePCSexualEnergy();
 
 		oralUse = 0;
 		analUse = 0;
@@ -121,9 +119,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useVagina(slave) {
-		if (energyUseRatio < 0.5) {
+		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 			vaginalUse = jsRandom(21, 40);
-		} else if (energyUseRatio < 1.0) {
+		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 			vaginalUse = jsRandom(7, 14);
 		} else {
 			vaginalUse = jsRandom(3, 7);
@@ -280,9 +278,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useAnus(slave) {
-		if (energyUseRatio < 0.5) {
+		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 			analUse = jsRandom(21, 40);
-		} else if (energyUseRatio < 1.0) {
+		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 			analUse = jsRandom(7, 14);
 		} else {
 			analUse = jsRandom(3, 7);
@@ -433,9 +431,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useMouth(slave) {
-		if (energyUseRatio < 0.5) {
+		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 			oralUse = jsRandom(21, 40);
-		} else if (energyUseRatio < 1.0) {
+		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 			oralUse = jsRandom(7, 14);
 		} else {
 			oralUse = jsRandom(3, 7);
@@ -685,9 +683,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useBoobs(slave) {
-		if (energyUseRatio < 0.5) {
+		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 			mammaryUse = jsRandom(21, 40);
-		} else if (energyUseRatio < 1.0) {
+		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 			mammaryUse = jsRandom(7, 14);
 		} else {
 			mammaryUse = jsRandom(3, 7);
@@ -904,9 +902,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 	 *
 	 */
 	function useDick(slave) {
-		if (energyUseRatio < 0.5) {
+		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 			penetrativeUse = jsRandom(21, 40);
-		} else if (energyUseRatio < 1.0) {
+		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 			penetrativeUse = jsRandom(7, 14);
 		} else {
 			penetrativeUse = jsRandom(3, 7);
@@ -1293,11 +1291,11 @@ App.SlaveAssignment.pleaseYou = (function() {
 				r.push(`${He} comes indecently hard whenever ${his} beloved ${getWrittenTitle(slave)} uses ${his} body.`);
 			}
 			r.push(`You have the sexual energy to fuck ${him}`);
-			if (energyUseRatio < 0.5) {
+			if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 				r.push(`several times a day; constant,`);
 				slave.devotion += 3;
 				slave.trust += 3;
-			} else if (energyUseRatio < 1.0) {
+			} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 				r.push(`at least once a day; regular,`);
 				slave.devotion += 2;
 				slave.trust += 2;
@@ -1313,11 +1311,11 @@ App.SlaveAssignment.pleaseYou = (function() {
 				r.push(`By the end of the week ${he} gets a hard-on when you use ${him}.`);
 			}
 			r.push(`You have the sexual energy to fuck ${him}`);
-			if (energyUseRatio < 0.5) {
+			if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 				r.push(`several times a day; constant,`);
 				slave.devotion += 3;
 				slave.trust += 3;
-			} else if (energyUseRatio < 1.0) {
+			} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 				r.push(`at least once a day; regular,`);
 				slave.devotion += 2;
 				slave.trust += 2;
@@ -1362,10 +1360,10 @@ App.SlaveAssignment.pleaseYou = (function() {
 				r.push(`By the end of the week ${he} gets a hard-on when you use ${him}.`);
 			}
 			r.push(`You have the sexual energy to fuck ${him}`);
-			if (energyUseRatio < 0.5) {
+			if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 				r.push(`several times a day; submitting to your constant`);
 				slave.devotion += 3;
-			} else if (energyUseRatio < 1.0) {
+			} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 				r.push(`at least once a day; submitting to your regular`);
 				slave.devotion += 2;
 			} else {
@@ -1379,11 +1377,11 @@ App.SlaveAssignment.pleaseYou = (function() {
 				r.push(`${His} dick stays limp as you rape ${him}.`);
 			}
 			r.push(`You have the sexual energy to fuck ${him}`);
-			if (energyUseRatio < 0.5) {
+			if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 				r.push(`several times a day; the constant`);
 				slave.devotion -= 5;
 				slave.trust -= 15;
-			} else if (energyUseRatio < 1.0) {
+			} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 				r.push(`at least once a day; the regular`);
 				slave.devotion -= 3;
 				slave.trust -= 9;
@@ -1395,9 +1393,9 @@ App.SlaveAssignment.pleaseYou = (function() {
 			r.push(`rape fills ${him} with <span class="mediumorchid">revulsion</span> and <span class="gold">fear.</span>`);
 		}
 
-		if (energyUseRatio < 0.5) {
+		if (fuckSlavesCount <= V.PC.sexualEnergy / 2) {
 			acts = jsRandom(21, 40);
-		} else if (energyUseRatio < 1.0) {
+		} else if (fuckSlavesCount <= V.PC.sexualEnergy) {
 			acts = jsRandom(7, 14);
 		} else {
 			acts = jsRandom(3, 7);
diff --git a/src/endWeek/slaveAssignmentReport.js b/src/endWeek/slaveAssignmentReport.js
index 245bb061b6c..4f02ad93f8f 100644
--- a/src/endWeek/slaveAssignmentReport.js
+++ b/src/endWeek/slaveAssignmentReport.js
@@ -211,7 +211,7 @@ App.EndWeek.slaveAssignmentReport = function() {
 	if (App.EndWeek.saVars.averageDick > 0) {
 		App.EndWeek.saVars.averageDick = App.EndWeek.saVars.averageDick / slavesWithWorkingDicks;
 	}
-	App.EndWeek.saVars.freeSexualEnergy = basePCSexualEnergy() - fuckSlavesLength();
+	App.EndWeek.saVars.freeSexualEnergy = V.PC.sexualEnergy - fuckSlavesLength();
 	const penthouseSlaves = App.Entity.facilities.penthouse.employees().length;
 	if (App.EndWeek.saVars.freeSexualEnergy > 0) {
 		if (App.EndWeek.saVars.freeSexualEnergy > penthouseSlaves / 2) {
diff --git a/src/events/intro/pcAppearance.js b/src/events/intro/pcAppearance.js
index d86122ddd11..07206f540ec 100644
--- a/src/events/intro/pcAppearance.js
+++ b/src/events/intro/pcAppearance.js
@@ -1205,6 +1205,7 @@ App.UI.Player.design = function() {
 		// Potential
 		App.UI.DOM.appendNewElement("h2", el, "Misc");
 		options = new App.UI.OptionsGroup();
+		options.addOption(`Sexual Energy`, "sexualEnergy", V.PC).showTextBox();
 		options.addOption(`Cum Tap`, "cumTap", V.PC.skill).showTextBox();
 		options.addOption(`Stored Cum`, "storedCum", V.PC.counter).showTextBox();
 		options.addOption(`Fertility Drugs`, "fertDrugs", V.PC)
diff --git a/src/js/utilsPC.js b/src/js/utilsPC.js
index d15d4b89643..535ff207d6a 100644
--- a/src/js/utilsPC.js
+++ b/src/js/utilsPC.js
@@ -672,71 +672,3 @@ globalThis.isPCCareerInCategory = function(category) {
 		return false;
 	}
 };
-
-/**
- * Calculate the base amount of sexual energy the PC has
- * @returns {number}
- */
-globalThis.basePCSexualEnergy = function() {
-	let energy = 4;
-	if (V.PCSlutContacts === 2) {
-		energy -= 3;
-	}
-	if (V.personalAttention.task === PersonalAttention.SEX) {
-		energy += 2;
-	}
-	if (V.PC.physicalAge >= 80) {
-		energy -= 6;
-	} else if (V.PC.physicalAge >= 72) {
-		energy -= 5;
-	} else if (V.PC.physicalAge >= 65) {
-		energy -= 4;
-	} else if (V.PC.physicalAge >= 58) {
-		energy -= 3;
-	} else if (V.PC.physicalAge >= 50) {
-		energy -= 2;
-	} else if (V.PC.physicalAge >= 42) {
-		energy -= 1;
-	} else if (V.PC.physicalAge >= 35) {
-		energy += 0;
-	} else if (V.PC.physicalAge >= 31) {
-		energy += 1;
-	} else if (V.PC.physicalAge >= 28) {
-		energy += 2;
-	} else if (V.PC.physicalAge >= 21) {
-		energy += 3;
-	} else if (V.PC.physicalAge >= 13) {
-		energy += 4;
-	} else if (V.PC.physicalAge === 12) {
-		energy += 1;
-	} else if (V.PC.physicalAge === 11) {
-		energy -= 2;
-	} else if (V.PC.physicalAge >= 0) {
-		energy -= 6;
-	}
-	if (V.PC.balls >= 10) {
-		energy += 2;
-	} else if (V.PC.balls >= 5) {
-		energy++;
-	}
-	if (V.PC.preg > 20) {
-		if (V.PC.pregMood === 2) {
-			energy += 4;
-		} else {
-			energy -= 3;
-		}
-	} else if (V.PC.preg > 0) {
-		energy -= 1;
-	} else {
-		if (V.PC.fertDrugs === 1) {
-			energy++;
-		}
-		if (V.PC.forcedFertDrugs > 0) {
-			energy += 2;
-		}
-	}
-	if (V.PC.staminaPills > 0) {
-		energy += 2;
-	}
-	return energy;
-};
diff --git a/src/player/js/PlayerState.js b/src/player/js/PlayerState.js
index 9dfbef8c869..f11ed16acd9 100644
--- a/src/player/js/PlayerState.js
+++ b/src/player/js/PlayerState.js
@@ -1448,6 +1448,10 @@ App.Entity.PlayerState = class PlayerState {
 		 * * 30: well educated
 		 */
 		this.intelligenceImplant = 30;
+		/**
+		 * how much fucking you can do in a week
+		 */
+		this.sexualEnergy = 4; // split this into the following two variables somehow
 		/**
 		 * sex drive
 		 * * 0 - 20: no sex drive
-- 
GitLab


From 2ca96123c94ad5ba1b4a6bed45ca6c6b2061161c Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 6 Dec 2021 21:00:23 -0500
Subject: [PATCH 4/5] PC fluids production is affected by health penalty, but
 health penalty doesn't do anything meaningful for the PC right now.

---
 src/js/health.js  |  9 +++++----
 src/js/storyJS.js | 18 ++++++------------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/js/health.js b/src/js/health.js
index b0f209fe490..52760134eeb 100644
--- a/src/js/health.js
+++ b/src/js/health.js
@@ -1,18 +1,19 @@
 /**
  * checks for illness and reduces the effectiveness of the slave accordingly -- 10, 25, 50, 85, 95% reduced
  * also checks for tiredness and reduces effectiveness from that as well -- 25% reduction at 90+ and 10% at 60-90
- * @param {App.Entity.SlaveState} slave
+ * @param {FC.HumanState} slave
  * @returns {number}
  */
 globalThis.healthPenalty = function(slave) {
 	const H = slave.health;
 	let penalty = 100;
-	if (slave.assignment !== Job.GLORYHOLE) {
+	const realSlave = asSlave(slave);
+	if (!realSlave || realSlave.assignment !== Job.GLORYHOLE) {
 		if (H.illness > 0) {
 			penalty *= (100 - Math.min((Math.pow(H.illness, 2) * 5 + 5), 95)) / 100;
 		}
-		// tiredness does not affect the productivity of restrained slaves
-		const tirednessPenaltyApplies = slave.fuckdoll === 0 && (slave.assignment !== Job.DAIRY || V.dairyRestraintsSetting <= 1);
+		// tiredness does not affect the productivity of restrained slaves (or the PC)
+		const tirednessPenaltyApplies = realSlave && realSlave.fuckdoll === 0 && (realSlave.assignment !== Job.DAIRY || V.dairyRestraintsSetting <= 1);
 		if (tirednessPenaltyApplies) {
 			if (H.tired > 90) {
 				penalty *= 0.75;
diff --git a/src/js/storyJS.js b/src/js/storyJS.js
index 9a729d414cf..59364fc636e 100644
--- a/src/js/storyJS.js
+++ b/src/js/storyJS.js
@@ -180,10 +180,7 @@ globalThis.milkAmount = function(slave) {
 	milk *= (1 + (slave.weight / 500));
 	milk *= (1 + (slave.lactationAdaptation / 500));
 	milk += (slave.boobsMilk / 100);
-	const realSlave = asSlave(slave); // PC milk output is unaltered by health penalties
-	if (realSlave) {
-		milk *= healthPenalty(realSlave);
-	}
+	milk *= healthPenalty(slave);
 	milk = Math.trunc(milk);
 	milk = Math.clamp(milk, 1, 1000000000000000000);
 	return milk;
@@ -226,15 +223,12 @@ globalThis.cumAmount = function(slave) {
 	} else if (slave.health.condition < -50) {
 		cum += (cum * (slave.health.condition / 50));
 	}
-	const realSlave = asSlave(slave); // PC cum output is unaltered by devotion/health penalties
-	if (realSlave) {
-		if (slave.devotion > 50) {
-			cum += (cum * (slave.devotion / 100));
-		} else if (slave.devotion < -50) {
-			cum += (cum * (slave.devotion / 100));
-		}
-		cum *= healthPenalty(realSlave);
+	if (slave.devotion > 50) {
+		cum += (cum * (slave.devotion / 100));
+	} else if (slave.devotion < -50) {
+		cum += (cum * (slave.devotion / 100));
 	}
+	cum *= healthPenalty(slave);
 	cum = Math.trunc(cum);
 	cum = Math.clamp(cum, 1, 1000000000000000000);
 	return cum;
-- 
GitLab


From eb8578e89e6668022f15c2b108f999d730cab1dd Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 6 Dec 2021 21:01:39 -0500
Subject: [PATCH 5/5] Move devotion block back to clean up the diff

---
 src/js/storyJS.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/js/storyJS.js b/src/js/storyJS.js
index 59364fc636e..d1215b564cc 100644
--- a/src/js/storyJS.js
+++ b/src/js/storyJS.js
@@ -218,16 +218,16 @@ globalThis.cumAmount = function(slave) {
 	} else if (slave.prostate === 3) {
 		cum *= 1.5;
 	}
-	if (slave.health.condition > 50) {
-		cum += (cum * (slave.health.condition / 50));
-	} else if (slave.health.condition < -50) {
-		cum += (cum * (slave.health.condition / 50));
-	}
 	if (slave.devotion > 50) {
 		cum += (cum * (slave.devotion / 100));
 	} else if (slave.devotion < -50) {
 		cum += (cum * (slave.devotion / 100));
 	}
+	if (slave.health.condition > 50) {
+		cum += (cum * (slave.health.condition / 50));
+	} else if (slave.health.condition < -50) {
+		cum += (cum * (slave.health.condition / 50));
+	}
 	cum *= healthPenalty(slave);
 	cum = Math.trunc(cum);
 	cum = Math.clamp(cum, 1, 1000000000000000000);
-- 
GitLab