From bc1fada8a9be26409564867eb05fa424a20a6537 Mon Sep 17 00:00:00 2001
From: Frankly George <54015-franklygeorge@users.noreply.gitgud.io>
Date: Fri, 19 Apr 2024 04:09:37 +0000
Subject: [PATCH] Patches

---
 js/003-data/gameVariableData.js               |  5 +--
 src/002-config/fc-version.js                  |  2 +-
 .../backwardsCompatibility.js                 | 32 +++++++++----------
 .../backwardsCompatibility/datatypeCleanup.js |  8 ++---
 src/js/states/HumanState.js                   | 10 ++++++
 src/js/states/PlayerState.js                  |  1 +
 src/js/states/SlaveState.js                   | 10 ------
 src/player/managePersonalAffairs.js           |  4 ++-
 8 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js
index 148f25f4681..8028ff2e30c 100644
--- a/js/003-data/gameVariableData.js
+++ b/js/003-data/gameVariableData.js
@@ -614,13 +614,13 @@ App.Data.resetOnNGPlus = {
 	burstIDs: [],
 	birthIDs: [],
 	induceIDs: [],
-	/** @type {FC.SlaveStateOrZero} */
+	/** @type {FC.Zeroable<App.Entity.SlaveState>} */
 	activeSlave: 0,
 	activeChild: 0,
 	/** @type {Array<FC.ReminderEntry>} */
 	reminders: [],
 
-	/** @type {FC.SlaveStateOrZero} */
+	/** @type {FC.Zeroable<App.Entity.SlaveState>} */
 	boomerangSlave: 0,
 	boomerangWeeks: 0,
 	/** @type {FC.Zeroable<string>} */
@@ -715,6 +715,7 @@ App.Data.resetOnNGPlus = {
 	incubator: {
 		// Everything in here is overwritten by App.Facilities.Incubator.init()
 		capacity: 0,
+		/** @type {App.Entity.SlaveState[]} */
 		tanks: [],
 		maleSetting: {
 			imprint: "trust",
diff --git a/src/002-config/fc-version.js b/src/002-config/fc-version.js
index 8efb2886c1e..32190c048e1 100644
--- a/src/002-config/fc-version.js
+++ b/src/002-config/fc-version.js
@@ -2,5 +2,5 @@ App.Version = {
 	base: "0.10.7.1", // The vanilla version the mod is based off of, this should never be changed.
 	pmod: "4.0.0-alpha.31",
 	commitHash: null,
-	release: 1242, // When getting close to 2000, please remove the check located within the onLoad() function defined at line five of src/js/eventHandlers.js.
+	release: 1243, // When getting close to 2000, please remove the check located within the onLoad() function defined at line five of src/js/eventHandlers.js.
 };
diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js
index 40abd0c6db6..da4121d8a96 100644
--- a/src/data/backwardsCompatibility/backwardsCompatibility.js
+++ b/src/data/backwardsCompatibility/backwardsCompatibility.js
@@ -75,9 +75,7 @@ App.Update.moveProperties = function(target, source, props, overwrite = true, al
  */
 App.Update.deleteProperties = function(obj, props) {
 	for (const p of props) {
-		if (p in obj) {
-			delete obj[p];
-		}
+		delete obj[p];
 	}
 };
 
@@ -1768,7 +1766,7 @@ App.Update.logIssue = (primaryMessage, secondaryMessage=undefined, node=undefine
 /**
  * Updates a HumanState object
  * @param {FC.HumanState} actor
- * @param {"normal"|"PC"|"detached"|"hero"} slaveType
+ * @param {"normal"|"PC"|"detached"|"hero"|"incubator"} slaveType
  * @param {Node} [node=undefined]
  * @returns {FC.HumanState} this should be assigned to the original variable, with the exception of hero slave templates
  * @example V.PC = App.Update.human(V.PC, "PC");
@@ -1790,6 +1788,8 @@ App.Update.human = (actor, slaveType, node=undefined) => {
 		}
 	} else if (slaveType === "hero") {
 		slaveLoc = `App.Data.HeroSlaves "${actor.slaveName} ${actor.slaveSurname}" template`;
+	} else if (slaveType === "incubator") {
+		slaveLoc = "V.incubator.tanks";
 	}
 
 	console.log(`Starting property migration on HumanState with ID: ${actor.ID}`);
@@ -1820,20 +1820,14 @@ App.Update.human = (actor, slaveType, node=undefined) => {
 		]);
 	}
 
-	// traitor and boomerang slaves have a `missingParentTag` property, but other slaves shouldn't have it
-	if ("missingParentTag" in actor && !["V.boomerangSlave", "V.traitor"].includes(slaveLoc)) {
-		App.Update.deleteProperties(actor, "missingParentTag");
-	}
-
 	// Incubator tank slaves keep `incubatorSettings` after release
-	// TODO:@franklygeorge handle this when you rework the incubator and nursery. Probably just want to redo ChildState so that it extends SlaveState, and then filter back to a pure SlaveState when they join the main slave group
-	// TODO:@franklygeorge if you do rework ChildState to inherit SlaveState, be sure to run it through this BC code
-	App.Update.deleteProperties(actor, [
-		"incubatorSettings", "incubatorPregAdaptationPower", "incubatorPregAdaptationInWeek"
-	]);
+	if (slaveType !== "incubator") {
+		App.Update.deleteProperties(actor, [
+			"incubatorSettings", "incubatorPregAdaptationPower", "incubatorPregAdaptationInWeek"
+		]);
+	}
 
 	// Nursery leaves variables after release
-	// TODO:@franklygeorge same as for the incubator
 	App.Update.deleteProperties(actor, ["growTime"]);
 
 	// ----------------------------------- automated beyond this point -----------------------------------
@@ -1855,8 +1849,9 @@ App.Update.human = (actor, slaveType, node=undefined) => {
 			if (key === "inappropriateLactation") { return; } // TODO:@franklygeorge same and same
 			if (key === "fetishChanged") { return; } // TODO:@franklygeorge same
 			if (key === "napkin") { return; } // TODO:@franklygeorge filter this until the way napkin gifts work is changed. Maybe make it more dynamic? Adding other gifts to `src/events/RESS/review/aGift.js`?
-			// traitor and boomerang slaves have a `missingParentTag` property
-			if (key === "missingParentTag" && ["V.boomerangSlave", "V.traitor"].includes(slaveLoc)) { return; }
+			// traitor and boomerang slaves (and a few others?) have a `missingParentTag` property
+			if (key === "missingParentTag") { return; }
+			if (["incubatorSettings", "incubatorPregAdaptationPower", "incubatorPregAdaptationInWeek"].includes(key)) { return; }
 
 			App.Update.logIssue(
 				`${slaveLoc} with ID "${actor.ID}" has an unhandled property "${key}" with the value of "${actor[key]}".`,
@@ -1909,6 +1904,9 @@ App.Update.humanRecords = (node) => {
 	V.traitor = (V.traitor) ? App.Update.human(V.traitor, "detached", node) : V.traitor;
 	V.shelterSlave = (V.shelterSlave) ? App.Update.human(V.shelterSlave, "detached", node) : V.shelterSlave;
 
+	// incubator slaves
+	V.incubator.tanks.forEach((slave, index) => V.incubator.tanks[index] = App.Update.human(slave, "incubator", node));
+
 	// PC
 	V.PC = App.Update.human(V.PC, "PC", node);
 
diff --git a/src/data/backwardsCompatibility/datatypeCleanup.js b/src/data/backwardsCompatibility/datatypeCleanup.js
index ceacaf966a7..df1ed8ce883 100644
--- a/src/data/backwardsCompatibility/datatypeCleanup.js
+++ b/src/data/backwardsCompatibility/datatypeCleanup.js
@@ -510,7 +510,7 @@ globalThis.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 		if (typeof slave.origRace !== "string") {
 			slave.origRace = slave.race;
 		}
-		if (V.releaseID < 1240 && "override_Race" in slave) {
+		if (V.releaseID < 1243 && "override_Race" in slave) {
 			// @ts-expect-error
 			slave.overrideRace = slave.override_Race;
 			delete slave.override_Race;
@@ -524,7 +524,7 @@ globalThis.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 		if (typeof slave.minorInjury !== "string") {
 			slave.minorInjury = 0;
 		}
-		if (V.releaseID < 1240 && "override_Skin" in slave) {
+		if (V.releaseID < 1243 && "override_Skin" in slave) {
 			// @ts-expect-error
 			slave.overrideSkin = slave.override_Skin;
 			delete slave.override_Skin;
@@ -556,7 +556,7 @@ globalThis.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 		if (slave.lips !== 0) {
 			slave.lips = Math.clamp(+slave.lips, 0, 100) || 15;
 		}
-		if (V.releaseID < 1240 && "override_Eye_Color" in slave) {
+		if (V.releaseID < 1243 && "override_Eye_Color" in slave) {
 			// @ts-expect-error
 			slave.overrideEyeColor = slave.override_Eye_Color;
 			delete slave.override_Eye_Color;
@@ -602,7 +602,7 @@ globalThis.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 		if (typeof slave.eyebrowFullness !== "string") {
 			slave.eyebrowFullness = "natural";
 		}
-		if (V.releaseID < 1240) {
+		if (V.releaseID < 1243) {
 			if ("override_H_Color" in slave) {
 				// @ts-expect-error
 				slave.overrideHColor = slave.override_H_Color;
diff --git a/src/js/states/HumanState.js b/src/js/states/HumanState.js
index 65af589967a..e4205c1c842 100644
--- a/src/js/states/HumanState.js
+++ b/src/js/states/HumanState.js
@@ -1767,6 +1767,16 @@ App.Entity.HumanState = class HumanState {
 		 * * 10+: dependent
 		 */
 		this.addict = 0;
+		/**
+		 * slave 's devotion
+		 * * -96 - : hate-filled
+		 * * -95 - -51: hateful
+		 * * -50 - -21: reluctant
+		 * * -20 - 20: careful
+		 * * 21 - 50: accepting
+		 * * 51 - 95: devoted
+		 * * 96+: worshipful */
+		this.devotion = 0;
 		/**
 		 * may accept strings, use at own risk
 		 *
diff --git a/src/js/states/PlayerState.js b/src/js/states/PlayerState.js
index 072c2c7a081..bfb942d7143 100644
--- a/src/js/states/PlayerState.js
+++ b/src/js/states/PlayerState.js
@@ -276,6 +276,7 @@ App.Entity.PlayerState = class PlayerState extends App.Entity.HumanState {
 		this.intelligence = 100;
 		this.intelligenceImplant = 30;
 		this.energy = 65;
+		this.devotion = 100; // used in some functions like `milkAmount()`, `cumAmount()`, and probably others
 		/**
 		 * A list of IDs of anyone the PC has ever slept with.
 		 *
diff --git a/src/js/states/SlaveState.js b/src/js/states/SlaveState.js
index f7e16afbce1..12fd23a2fe1 100644
--- a/src/js/states/SlaveState.js
+++ b/src/js/states/SlaveState.js
@@ -262,16 +262,6 @@ App.Entity.SlaveState = class SlaveState extends App.Entity.HumanState {
 		this.trust = 0;
 		/** used to calculate trust loss/gain */
 		this.oldTrust = 0;
-		/**
-		 * slave 's devotion
-		 * * -96 - : hate-filled
-		 * * -95 - -51: hateful
-		 * * -50 - -21: reluctant
-		 * * -20 - 20: careful
-		 * * 21 - 50: accepting
-		 * * 51 - 95: devoted
-		 * * 96+: worshipful */
-		this.devotion = 0;
 		/** used to calculate devotion loss/gain */
 		this.oldDevotion = 0;
 		/**
diff --git a/src/player/managePersonalAffairs.js b/src/player/managePersonalAffairs.js
index e79427e3683..1f4f0c9f5b2 100644
--- a/src/player/managePersonalAffairs.js
+++ b/src/player/managePersonalAffairs.js
@@ -28,7 +28,9 @@ App.UI.managePersonalAffairs = function() {
 
 	App.UI.DOM.appendNewElement("h1", frag, `Personal Affairs`);
 
-	App.UI.DOM.drawOneSlaveRight(frag, V.PC);
+	const artPC = clone(V.PC);
+	artPC.clothes = "no clothing";
+	App.UI.DOM.drawOneSlaveRight(frag, artPC);
 
 	frag.append(
 		appearance(),
-- 
GitLab