From 6bcfe06380a9aef41d12242dac17fee16bf48741 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Mon, 19 Oct 2020 14:56:32 -0400
Subject: [PATCH] finally fix tankOrgans global

---
 src/facilities/incubator/incubatorInteract.js | 31 ++++++++++---------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/facilities/incubator/incubatorInteract.js b/src/facilities/incubator/incubatorInteract.js
index d2d1ca72247..af2756eb46b 100644
--- a/src/facilities/incubator/incubatorInteract.js
+++ b/src/facilities/incubator/incubatorInteract.js
@@ -12,6 +12,7 @@ App.UI.incubator = function() {
 	V.reservedChildrenNursery = FetusGlobalReserveCount("nursery");
 
 	let linkArray = [];
+	let tankOrgans = {};
 	const el = new DocumentFragment();
 	const _SL = V.slaves.length;
 	let _eligibility = 0;
@@ -961,7 +962,7 @@ App.UI.incubator = function() {
 				if ((V.incubatorUpgradeOrgans === 1) && (V.tanks[i].tankBaby !== 3)) {
 					r = [];
 					r.push(`You can extract a sample and prepare a new organ for ${him} to be implanted once ${he} exits ${his} tank.`);
-					V.tankOrgans = { // Global to survive refresh.  Can be improved
+					tankOrgans = {
 						ovaries: 0,
 						penis: 0,
 						testicles: 0,
@@ -972,22 +973,22 @@ App.UI.incubator = function() {
 					for (let _i = 0; _i < V.incubatorOrgans.length; _i++) {
 						if (V.tanks[i].ID === V.incubatorOrgans[_i].ID) {
 							if (V.incubatorOrgans[_i].type === "ovaries") {
-								V.tankOrgans.ovaries = 1;
+								tankOrgans.ovaries = 1;
 							}
 							if (V.incubatorOrgans[_i].type === "testicles") {
-								V.tankOrgans.testicles = 1;
+								tankOrgans.testicles = 1;
 							}
 							if (V.incubatorOrgans[_i].type === "penis") {
-								V.tankOrgans.penis = 1;
+								tankOrgans.penis = 1;
 							}
 							if (V.incubatorOrgans[_i].type === "rightEye") {
-								V.tankOrgans.rightEye = 1;
+								tankOrgans.rightEye = 1;
 							}
 							if (V.incubatorOrgans[_i].type === "leftEye") {
-								V.tankOrgans.leftEye = 1;
+								tankOrgans.leftEye = 1;
 							}
 							if (V.incubatorOrgans[_i].type === "voicebox") {
-								V.tankOrgans.voicebox = 1;
+								tankOrgans.voicebox = 1;
 							}
 						}
 					}
@@ -1001,7 +1002,7 @@ App.UI.incubator = function() {
 
 					linkArray = [];
 					if (V.tanks[i].ovaries === 0) {
-						if (V.tankOrgans.ovaries !== 1) {
+						if (tankOrgans.ovaries !== 1) {
 							linkArray.push(
 								makeLink(
 									"Prepare ovaries",
@@ -1016,7 +1017,7 @@ App.UI.incubator = function() {
 						}
 					}
 					if (V.tanks[i].dick === 0) {
-						if (V.tankOrgans.penis !== 1) {
+						if (tankOrgans.penis !== 1) {
 							linkArray.push(
 								makeLink("Prepare penis", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.tanks[i], "penis"); }, refresh)
 							);
@@ -1025,7 +1026,7 @@ App.UI.incubator = function() {
 						}
 					}
 					if (V.tanks[i].balls === 0) {
-						if (V.tankOrgans.testicles !== 1) {
+						if (tankOrgans.testicles !== 1) {
 							linkArray.push(makeLink("Prepare testicles", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.tanks[i], "testicles"); }, refresh));
 						} else {
 							linkArray.push(App.UI.DOM.makeElement("span", `Testicles are already prepared.`, "detail"));
@@ -1043,10 +1044,10 @@ App.UI.incubator = function() {
 						} else {
 							linkArray.push(App.UI.DOM.makeElement("span", `${He} appears to be blind in ${his} right eye:`));
 						}
-						if (vision.left === 0 && V.tankOrgans.leftEye !== 1) {
+						if (vision.left === 0 && tankOrgans.leftEye !== 1) {
 							linkArray.push(makeLink("Prepare left eye", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.tanks[i], "leftEye"); }, refresh));
 						}
-						if (vision.right === 0 && V.tankOrgans.rightEye !== 1) {
+						if (vision.right === 0 && tankOrgans.rightEye !== 1) {
 							linkArray.push(makeLink("Prepare right eye", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.tanks[i], "rightEye"); }, refresh));
 						}
 						if (vision.left === 0 && vision.right === 0 && linkArray.length === 2) {
@@ -1063,9 +1064,9 @@ App.UI.incubator = function() {
 						}
 						if (vision.left === 0 && vision.right === 0 && linkArray.length === 0) {
 							linkArray.push(App.UI.DOM.makeElement("span", `Both eyes are already prepared.`, `detail`));
-						} else if (V.tankOrgans.leftEye === 1) {
+						} else if (tankOrgans.leftEye === 1) {
 							linkArray.push(App.UI.DOM.makeElement("span", `A left eye is already prepared.`, `detail`));
-						} else if (V.tankOrgans.rightEye === 1) {
+						} else if (tankOrgans.rightEye === 1) {
 							linkArray.push(App.UI.DOM.makeElement("span", `A right eye is already prepared.`, `detail`));
 						}
 					}
@@ -1073,7 +1074,7 @@ App.UI.incubator = function() {
 					if (V.tanks[i].voice === 0) {
 						r = [];
 						r.push(`${He} appears to be mute: `);
-						if (V.tankOrgans.voicebox !== 1) {
+						if (tankOrgans.voicebox !== 1) {
 							r.push(makeLink("Prepare vocal cords", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.tanks[i], "voicebox"); }, refresh));
 						} else {
 							r.push(App.UI.DOM.makeElement("span", `Vocal cords are already prepared.`, `detail`));
-- 
GitLab