From 158fc3c9b481a81a51c5f2b24cae6054e6cc18af Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Sun, 29 Nov 2020 15:36:11 -0500
Subject: [PATCH] dedupe and compress

---
 src/cheats/PCCheatMenu.tw         | 13 ++++-----
 src/events/intro/introSummary.js  | 45 ++-----------------------------
 src/events/intro/pcAppearance.js  | 19 +++++++++++++
 src/events/intro/pcBodyIntro.js   | 29 +-------------------
 src/gui/options/optionsPassage.js |  2 +-
 5 files changed, 28 insertions(+), 80 deletions(-)

diff --git a/src/cheats/PCCheatMenu.tw b/src/cheats/PCCheatMenu.tw
index c1257c0f608..2080a5037f9 100644
--- a/src/cheats/PCCheatMenu.tw
+++ b/src/cheats/PCCheatMenu.tw
@@ -47,14 +47,11 @@ Sex: ''$tempSlave.genes''
 <br><<radiobutton "$tempSlave.refreshment" "cigar">> Cigar
 	<<radiobutton "$tempSlave.refreshment" "whiskey">> Whiskey
 
-<br>Preferred method of consumption: <<if $tempSlave.refreshmentType == 0>>Smoked<<elseif $tempSlave.refreshmentType == 1>>Drank<<elseif $tempSlave.refreshmentType == 2>>Eaten<<elseif $tempSlave.refreshmentType == 3>>Snorted<<elseif $tempSlave.refreshmentType == 4>>Injected<<elseif $tempSlave.refreshmentType == 5>>Popped<<else>>Orally Dissolved<</if>>
-<br><<radiobutton "$tempSlave.refreshmentType" 0>> Smoked
-	<<radiobutton "$tempSlave.refreshmentType" 1>> Drank
-	<<radiobutton "$tempSlave.refreshmentType" 2>> Eaten
-	<<radiobutton "$tempSlave.refreshmentType" 3>> Snorted
-	<<radiobutton "$tempSlave.refreshmentType" 4>> Injected
-	<<radiobutton "$tempSlave.refreshmentType" 5>> Popped
-	<<radiobutton "$tempSlave.refreshmentType" 6>> Orally Dissolved
+<br>Preferred method of consumption: <<print App.Data.player.refreshmentType[$tempSlave.refreshmentType]>>
+<br>
+<<for _i = 0; _i < App.Data.player.refreshmentType.length; _i++>>
+	<<radiobutton "$tempSlave.refreshmentType" _i>> <<print App.Data.player.refreshmentType[_i]>>
+<</for>>
 <br>
 
 <br>''Skin'': <<textbox "$tempSlave.skin" $tempSlave.skin>>
diff --git a/src/events/intro/introSummary.js b/src/events/intro/introSummary.js
index 494b7edb30f..cc7962813c9 100644
--- a/src/events/intro/introSummary.js
+++ b/src/events/intro/introSummary.js
@@ -664,28 +664,7 @@ App.Intro.summary = function() {
 					["Exotic", "exotic"]
 				]);
 
-			options.addOption("Your preferred refreshment is", "refreshment", V.PC).showTextBox()
-				.addValue("Cigars", "cigar", () => { V.PC.refreshmentType = 0; })
-				.addValue("Whiskey", "whiskey", () => { V.PC.refreshmentType = 1; });
-
-			option = options.addOption("Which you", "refreshmentType", V.PC)
-				.addValueList([
-					["Smoke", 0],
-					["Drink", 1],
-					["Eat", 2],
-					["Snort", 3],
-					["Inject", 4],
-					["Pop", 5],
-					["Orally dissolve", 6]
-				]);
-
-			if (V.PC.refreshmentType === 0) {
-				option.addComment(`"Smoked" must fit into the following sentence: "I smoked a ${V.PC.refreshment}" to fit events properly.`);
-			} else if (V.PC.refreshmentType === 5) {
-				option.addComment(`"Popped" must fit into the following sentence: "I shook the bottle of ${V.PC.refreshment}" to fit events properly.`);
-			} else if (V.PC.refreshmentType === 6) {
-				option.addComment(`"Orally Dissolved" must fit into the following sentence: "I placed a tab of ${V.PC.refreshment} under my tongue" to fit events properly.`);
-			}
+			App.Intro.refreshmentChoice(options);
 
 			option = options.addOption("Before you came to the Free Cities, you were a", "career", V.PC);
 			if (V.PC.career === "arcology owner") {
@@ -896,28 +875,8 @@ App.Intro.summary = function() {
 					.addValue("Set custom title", "Master", () => V.PC.customTitleLisp = 'Mather');
 			}
 
-			options.addOption("Your preferred refreshment is", "refreshment", V.PC).showTextBox()
-				.addValue("Cigars", "cigar", () => { V.PC.refreshmentType = 0; })
-				.addValue("Whiskey", "whiskey", () => { V.PC.refreshmentType = 1; });
+			App.Intro.refreshmentChoice(options);
 
-			option = options.addOption("Which you", "refreshmentType", V.PC)
-				.addValueList([
-					["Smoke", 0],
-					["Drink", 1],
-					["Eat", 2],
-					["Snort", 3],
-					["Inject", 4],
-					["Pop", 5],
-					["Orally dissolve", 6]
-				]);
-
-			if (V.PC.refreshmentType === 0) {
-				option.addComment(`"Smoked" must fit into the following sentence: "I smoked a ${V.PC.refreshment}" to fit events properly.`);
-			} else if (V.PC.refreshmentType === 5) {
-				option.addComment(`"Popped" must fit into the following sentence: "I shook the bottle of ${V.PC.refreshment}" to fit events properly.`);
-			} else if (V.PC.refreshmentType === 6) {
-				option.addComment(`"Orally Dissolved" must fit into the following sentence: "I placed a tab of ${V.PC.refreshment} under my tongue" to fit events properly.`);
-			}
 			el.append(options.render());
 
 			r = [];
diff --git a/src/events/intro/pcAppearance.js b/src/events/intro/pcAppearance.js
index e413c771cb6..a0a821ec0fd 100644
--- a/src/events/intro/pcAppearance.js
+++ b/src/events/intro/pcAppearance.js
@@ -22,3 +22,22 @@ App.Intro.pcAppearance = function(options) {
 		return Array.from(iterable, (k => [capFirstChar(k), k]));
 	}
 };
+
+App.Intro.refreshmentChoice = function(options) {
+	options.addOption("Your preferred refreshment is", "refreshment", V.PC).showTextBox()
+		.addValue("Cigars", "cigar", () => { V.PC.refreshmentType = 0; })
+		.addValue("Whiskey", "whiskey", () => { V.PC.refreshmentType = 1; });
+
+	const option = options.addOption("Which you", "refreshmentType", V.PC)
+		.addValueList(Array.from(App.Data.player.refreshmentType, (v, i) => [v, i]));
+
+	let comment = `Flavor only; no mechanical effect. If entering a custom refreshment, please assign proper usage.`;
+	if (V.PC.refreshmentType === 0) {
+		comment += ` "Smoked" must fit into the following sentence: "I smoked a ${V.PC.refreshment}" to fit events properly.`;
+	} else if (V.PC.refreshmentType === 5) {
+		comment += ` "Popped" must fit into the following sentence: "I shook the bottle of ${V.PC.refreshment}" to fit events properly.`;
+	} else if (V.PC.refreshmentType === 6) {
+		comment += ` "Orally Dissolved" must fit into the following sentence: "I placed a tab of ${V.PC.refreshment} under my tongue" to fit events properly.`;
+	}
+	option.addComment(comment);
+};
diff --git a/src/events/intro/pcBodyIntro.js b/src/events/intro/pcBodyIntro.js
index efb896259cf..3037e70ebac 100644
--- a/src/events/intro/pcBodyIntro.js
+++ b/src/events/intro/pcBodyIntro.js
@@ -164,36 +164,9 @@ App.Intro.PCBodyIntro = function() {
 					"PC Body Intro"
 				);
 		}
-		options.addOption(`Preferred refreshment:`, "refreshment", V.PC).showTextBox()
-			.customButton(
-				"Cigars",
-				() => {
-					V.PC.refreshment = "cigar";
-					V.PC.refreshmentType = 0;
-				},
-				"PC Body Intro"
-			)
-			.customButton(
-				"Whiskey",
-				() => {
-					V.PC.refreshment = "whiskey";
-					V.PC.refreshmentType = 1;
-				},
-				"PC Body Intro"
-			);
-
-		options.addOption(`Preferred method of consumption:`, "refreshmentType", V.PC)
-			.addValueList(Array.from(App.Data.player.refreshmentType, (v, i) => [v, i]))
-			.addComment(`Flavor only; no mechanical effect. If entering a custom refreshment, please assign proper usage.`);
+		App.Intro.refreshmentChoice(options);
 
 		el.append(options.render());
-		if (V.PC.refreshmentType === 0) {
-			App.UI.DOM.appendNewElement("div", el, `"Smoke" must fit into the following sentence: "I smoked a ${V.PC.refreshment}" to fit events properly`);
-		} else if (V.PC.refreshmentType === 5) {
-			App.UI.DOM.appendNewElement("div", el, `"Popped" must fit into the following sentence: "I shook the bottle of ${V.PC.refreshment}" to fit events properly`);
-		} else if (V.PC.refreshmentType === 6) {
-			App.UI.DOM.appendNewElement("div", el, `"Orally Dissolved" must fit into the following sentence: "I placed a tab of ${V.PC.refreshment} under my tongue" to fit events properly`);
-		}
 
 		return el;
 	}
diff --git a/src/gui/options/optionsPassage.js b/src/gui/options/optionsPassage.js
index 4807dce4c2f..7c215b4159d 100644
--- a/src/gui/options/optionsPassage.js
+++ b/src/gui/options/optionsPassage.js
@@ -1064,4 +1064,4 @@ App.UI.artOptions = function() {
 	}
 	el.append(options.render());
 	return el;
-}
+};
-- 
GitLab