From ee86045986d3391f59c5b7b8e5a4c342ceff16b9 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Fri, 17 Jan 2020 11:02:45 +0100
Subject: [PATCH] fix incubator eyes

---
 src/npc/surgery/organFarm.js                |  2 +-
 src/pregmod/incubator.tw                    | 25 +++++----------------
 src/uncategorized/BackwardsCompatibility.tw | 23 +++++++++++++++++++
 3 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/src/npc/surgery/organFarm.js b/src/npc/surgery/organFarm.js
index 083b4d6b80b..66f9ae8d1fd 100644
--- a/src/npc/surgery/organFarm.js
+++ b/src/npc/surgery/organFarm.js
@@ -119,7 +119,7 @@ App.Medicine.OrganFarm.implantActions = function(slave) {
 		r += `${App.UI.link("Discard", App.Medicine.OrganFarm.removeOrgan, [slave, organ.type], "Remote Surgery")}</div></div>`;
 	}
 
-	return `The fabricator has completed ${slaveOrgans.length} organ(s):<div class="organContainer">${r}</div>`;
+	return `The fabricator has completed ${slaveOrgans.length} organ(s):<div class="grid-2columns-auto">${r}</div>`;
 };
 
 /**
diff --git a/src/pregmod/incubator.tw b/src/pregmod/incubator.tw
index 1246f3eadb1..4759cbeb4f1 100644
--- a/src/pregmod/incubator.tw
+++ b/src/pregmod/incubator.tw
@@ -523,49 +523,34 @@ Target age for release: <<textbox "$targetAge" $targetAge "Incubator">> [[Minimu
 			<br>
 			<<if $tanks[$i].ovaries == 0 && $tankOrgans.ovaries != 1>>
 				<<link "Prepare ovaries">>
-					<<run cashX(-10000, "incubator", $tanks[$i])>>
-					<<set _newOrgan = {type: "ovaries", weeksToCompletion: "10", ID: 0}>>
-					<<set _newOrgan.ID = $tanks[$i].ID>>
-					<<set $incubatorOrgans.push(_newOrgan)>>
+					<<run App.Medicine.OrganFarm.growOrgan($tanks[$i], "ovaries">>
 					<<goto "Incubator">>
 				<</link>>
 			<</if>>
 			<<if $tanks[$i].dick == 0 && $tankOrgans.penis != 1>>
 				<<link "Prepare penis">>
-					<<run cashX(-5000, "incubator", $tanks[$i])>>
-					<<set _newOrgan = {type: "penis", weeksToCompletion: "5", ID: 0}>>
-					<<set _newOrgan.ID = $tanks[$i].ID>>
-					<<set $incubatorOrgans.push(_newOrgan)>>
+					<<run App.Medicine.OrganFarm.growOrgan($tanks[$i], "penis">>
 					<<goto "Incubator">>
 				<</link>>
 			<</if>>
 			<<if $tanks[$i].balls == 0 && $tankOrgans.testicles != 1>>
 				|
 				<<link "Prepare testicles">>
-					<<run cashX(-5000, "incubator", $tanks[$i])>>
-					<<set _newOrgan = {type: "testicles", weeksToCompletion: "10", ID: 0}>>
-					<<set _newOrgan.ID = $tanks[$i].ID>>
-					<<set $incubatorOrgans.push(_newOrgan)>>
+					<<run App.Medicine.OrganFarm.growOrgan($tanks[$i], "testicles">>
 					<<goto "Incubator">>
 				<</link>>
 			<</if>>
 			<<if getBestVision($tanks[$i]) === 0 && $tankOrgans.eyes != 1>>
 				<br>$He appears to be blind:
 				<<link "Prepare eyes">>
-					<<run cashX(-10000, "incubator", $tanks[$i])>>
-					<<set _newOrgan = {type: "eyes", weeksToCompletion: "10", ID: 0}>>
-					<<set _newOrgan.ID = $tanks[$i].ID>>
-					<<set $incubatorOrgans.push(_newOrgan)>>
+					<<run App.Medicine.OrganFarm.growOrgan($tanks[$i], "rightEye"), App.Medicine.OrganFarm.growOrgan($tanks[$i], "leftEye")>>
 					<<goto "Incubator">>
 				<</link>>
 			<</if>>
 			<<if $tanks[$i].voice == 0 && $tankOrgans.voicebox != 1>>
 				<br>$He appears to be mute:
 				<<link "Prepare vocal cords">>
-					<<run cashX(-5000, "incubator", $tanks[$i])>>
-					<<set _newOrgan = {type: "voicebox", weeksToCompletion: "5", ID: 0}>>
-					<<set _newOrgan.ID = $tanks[$i].ID>>
-					<<set $incubatorOrgans.push(_newOrgan)>>
+					<<run App.Medicine.OrganFarm.growOrgan($tanks[$i], "voicebox">>
 					<<goto "Incubator">>
 				<</link>>
 			<</if>>
diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw
index 564c08cc6c5..c0163e71c7a 100644
--- a/src/uncategorized/BackwardsCompatibility.tw
+++ b/src/uncategorized/BackwardsCompatibility.tw
@@ -3699,6 +3699,29 @@ Done<br>
 	<<set $tooltipsEnabled = 0>>
 <</if>>
 
+<<set _newOrgans = []>>
+<<run $organs.forEach(o => {
+	if (o.type === "eyes") {
+		_newOrgans.push({type: "leftEye", weeksToCompletion: o.weeksToCompletion, ID: o.ID});
+		_newOrgans.push({type: "rightEye", weeksToCompletion: o.weeksToCompletion, ID: o.ID});
+	} else {
+		_newOrgans.push(o);
+	}
+})>>
+<<set $organs = _newOrgans>>
+
+<<set _newOrgans = []>>
+<<run $completedOrgans.forEach(o => {
+	if (o.type === "eyes") {
+		_newOrgans.push({type: "leftEye", ID: o.ID});
+		_newOrgans.push({type: "rightEye", ID: o.ID});
+	} else {
+		_newOrgans.push(o);
+	}
+})>>
+<<set $completedOrgans = _newOrgans>>
+
+
 /* leave this at the bottom of BC */
 <<if $releaseID < App.Version.release>>
 	<<set $releaseID = App.Version.release>>
-- 
GitLab