From e2355f1df214b47aea6271cf21de0ab643050a99 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@mailbox.org>
Date: Fri, 24 Feb 2023 21:06:17 +0100
Subject: [PATCH] Improve prosthetic lab passage

---
 src/interaction/prostheticLabPassage.js | 79 +++++++++++++++----------
 1 file changed, 47 insertions(+), 32 deletions(-)

diff --git a/src/interaction/prostheticLabPassage.js b/src/interaction/prostheticLabPassage.js
index c8d3aa27e4a..3c1a67b18d2 100644
--- a/src/interaction/prostheticLabPassage.js
+++ b/src/interaction/prostheticLabPassage.js
@@ -28,19 +28,20 @@ App.UI.prostheticLab = function() {
 		App.UI.DOM.appendNewElement("h3", node, "Personnel");
 
 		if (V.researchLab.aiModule === 1) {
-			App.UI.DOM.appendNewElement("div", node, App.UI.DOM.link(
-				"Buy and install research module",
-				() => {
-					cashX(forceNeg(35000 * V.upgradeMultiplierArcology), "capEx");
-					V.researchLab.aiModule = 2;
-					App.UI.reload();
-				},
-				[], '',
-				`This module enables your personal assistant to assist staff and direct menials assigned to your research facility, increasing efficiency. It costs ${cashFormat(35000 * V.upgradeMultiplierArcology)}`
-			));
+			const div = document.createElement("div");
+			div.append(App.UI.DOM.link("Buy and install research module", () => {
+				cashX(forceNeg(35000 * V.upgradeMultiplierArcology), "capEx");
+				V.researchLab.aiModule = 2;
+				App.UI.reload();
+			}));
+			App.Events.addNode(div, [` Costs ${cashFormatColor(35000 * V.upgradeMultiplierArcology)}`]);
+			node.append(div);
+			App.UI.DOM.appendNewElement("div", node,
+				`This module enables your personal assistant to assist staff and direct menials assigned to your research facility, increasing efficiency.`,
+				["note", "indent"]);
 		}
 		if ((staff) === 0) {
-			App.UI.DOM.appendNewElement("div", node, "Facility is currently unstaffed.", "note");
+			App.UI.DOM.appendNewElement("div", node, "Facility is currently unstaffed.");
 		} else {
 			r.push(`You have`);
 			if (V.researchLab.hired === 1) {
@@ -63,27 +64,24 @@ App.UI.prostheticLab = function() {
 			if (V.researchLab.aiModule > 1) {
 				r.push(`Occasionally you hear the voice of your assistant as ${heA} helps direct and organize work.`);
 			}
-			App.Events.addNode(node, r, "div", "note");
+			App.Events.addNode(node, r, "div");
 			r = [];
 		}
 
-		let div = App.UI.DOM.appendNewElement("div", node, null, "indent");
-		div.append(`Currently, this facility can employ ${V.researchLab.maxSpace} people.`);
+		App.UI.DOM.appendNewElement("div", node, `Currently, this facility can employ ${V.researchLab.maxSpace} people.`, ["indent",
+			"note"]);
 		if (V.researchLab.maxSpace >= 5) { // Exists
 			if (V.researchLab.maxSpace < 50) { // Can upgrade
 				const maxSpace = [5, 10, 20, 30, 40, 50];
 				const upgrade = maxSpace[maxSpace.indexOf(V.researchLab.maxSpace) + 1];
-				App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(
+				App.UI.DOM.appendNewElement("div", node, App.UI.DOM.link(
 					"Expand facility",
 					() => {
 						cashX(forceNeg(Math.trunc(500 * upgrade * V.upgradeMultiplierArcology)), "capEx");
 						V.researchLab.maxSpace = upgrade;
 						App.UI.reload();
-					}
-				));
-			} else {
-				App.Events.addNode(div, r, "div", "note");
-				r = [];
+					}), ["indent"]
+				);
 			}
 		}
 
@@ -106,7 +104,8 @@ App.UI.prostheticLab = function() {
 				}
 			}
 			App.Events.addNode(node, ["Hire", App.UI.DOM.generateLinksStrip(linkArray), "scientists."]);
-			App.UI.DOM.appendNewElement("div", node, `Each scientist will require an initial fee of ${cashFormat(2000)} and incur ${cashFormat(300)} weekly.`, ["indent", "note"]);
+			App.Events.addNode(node, [`Each scientist will require an initial fee of ${cashFormatColor(2000)} and incur ${cashFormatColor(300)} weekly.`], "div", ["indent",
+				"note"]);
 
 			if (V.menials > 0) {
 				const space = (V.researchLab.maxSpace - (staff));
@@ -129,7 +128,8 @@ App.UI.prostheticLab = function() {
 			} else {
 				App.UI.DOM.appendNewElement("div", node, `You do not own any unassigned menial slaves.`);
 			}
-			App.UI.DOM.appendNewElement("div", node, `Using menial slaves is much cheaper than hiring scientists, but they are less effective. ${cashFormat(100)} per slave each week.`, ["indent", "note"]);
+			App.Events.addNode(node, [`Using menial slaves is much cheaper than hiring scientists, but they are less effective. Costs ${cashFormatColor(100)} per slave each week.`],
+				"div", ["indent", "note"]);
 		} else {
 			App.UI.DOM.appendNewElement("div", node, "Facility is fully staffed.", ["indent", "note"]);
 		}
@@ -180,8 +180,11 @@ App.UI.prostheticLab = function() {
 				App.UI.DOM.appendNewElement("div", node, `You have projects planned but without researchers you won't be able to work on them:`);
 			}
 
+			const taskDiv = document.createElement("div");
+			taskDiv.classList.add("grid-3columns-auto");
+
 			for (let i = 0; i < V.researchLab.tasks.length; i++) {
-				const r = [];
+				let r = [];
 				switch (V.researchLab.tasks[i].type) {
 					case "research":
 						r.push(`You`);
@@ -212,9 +215,13 @@ App.UI.prostheticLab = function() {
 				}
 				j += V.researchLab.tasks[i].workLeft;
 				r.push(`<span class="noteworthy">${capFirstChar(App.Data.prosthetics[V.researchLab.tasks[i].id].name)}.</span>`);
+				App.Events.addNode(taskDiv, r, "div", "indent");
+				r = [];
 				if (V.researchLab.speed > 0) {
 					r.push(`Finished in approximately ${(Math.floor(j / V.researchLab.speed) + 1)} week(s).`);
 				}
+				App.Events.addNode(taskDiv, r, "div");
+				r = [];
 
 				r.push(App.UI.DOM.link(
 					(V.researchLab.tasks[i].type === "research") ? "Cancel: Will not return investments." : "Cancel",
@@ -226,8 +233,10 @@ App.UI.prostheticLab = function() {
 						App.UI.reload();
 					}
 				));
-				App.Events.addNode(node, r, "div", "indent");
+				App.Events.addNode(taskDiv, r, "div");
 			}
+
+			node.append(taskDiv);
 		} else {
 			App.UI.DOM.appendNewElement("div", node, `Currently the research lab has no tasks planned.`, "note");
 		}
@@ -235,25 +244,31 @@ App.UI.prostheticLab = function() {
 		App.UI.DOM.appendNewElement("h3", node, "Research");
 
 		App.UI.DOM.appendNewElement("div", node, `Available research projects:`);
+		const researchDiv = document.createElement("div");
+		researchDiv.classList.add("grid-2columns-auto");
 		for (let p of App.Data.prostheticIDs) {
 			if (V.prosthetics[p].research === 0) {
-				// <div class="indent">
 				if (App.Data.prosthetics[p].level <= V.prostheticsUpgrade) {
-					App.UI.DOM.appendNewElement("div", node, App.UI.DOM.link(
-						`Reverse engineer ${addA(App.Data.prosthetics[p].name)}`,
+					App.UI.DOM.appendNewElement("div", researchDiv, App.UI.DOM.link(`Reverse engineer ${addA(App.Data.prosthetics[p].name)}`,
 						() => {
 							cashX(forceNeg(App.Data.prosthetics[p].costs), "labResearch");
 							V.prosthetics[p].research = -1;
-							V.researchLab.tasks.push({type: "research", id: p, workLeft: App.Data.prosthetics[p].research});
+							V.researchLab.tasks.push({
+								type: "research",
+								id: p,
+								workLeft: App.Data.prosthetics[p].research
+							});
 							App.UI.reload();
-						}, [], "",
-						`Costs ${cashFormat(App.Data.prosthetics[p].costs)} of initial investment.`
-					), "indent");
+						}
+					), ["indent"]);
+					App.Events.addNode(researchDiv, [` Costs ${cashFormatColor(App.Data.prosthetics[p].costs)} of initial investment.`], "div");
 				} else {
-					App.UI.DOM.appendNewElement("div", node, `You need better contracts to get the required research material for reverse engineering ${addA(App.Data.prosthetics[p].name)}.`, "note");
+					App.UI.DOM.appendNewElement("div", researchDiv, `You need better contracts to get the required research material for reverse engineering ${addA(App.Data.prosthetics[p].name)}.`, ["note",
+						"grid-all-columns"]);
 				}
 			}
 		}
+		node.append(researchDiv);
 
 		App.UI.DOM.appendNewElement("h3", node, "Manufacture");
 
-- 
GitLab