From cc72a4e3fc7949443963fea07db708a5c1c3f6f6 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Fri, 25 Dec 2020 10:09:58 -0500
Subject: [PATCH] move buttplug checks to data

---
 devTools/types/FC/RA.d.ts                |  1 -
 src/endWeek/saClothes.js                 | 13 +++++++------
 src/endWeek/saLongTermMentalEffects.js   |  2 +-
 src/endWeek/saLongTermPhysicalEffects.js |  2 +-
 src/interaction/main/walkPast.js         |  8 ++++----
 src/js/eventSelectionJS.js               |  4 ++--
 src/js/utilsAssessSlave.js               | 18 ++++++++++++++++++
 src/npc/interaction/fFeelings.tw         |  6 +++---
 src/uncategorized/reShelterInspection.tw |  4 ++--
 9 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/devTools/types/FC/RA.d.ts b/devTools/types/FC/RA.d.ts
index a7dbfbbdaf7..c68f19732dd 100644
--- a/devTools/types/FC/RA.d.ts
+++ b/devTools/types/FC/RA.d.ts
@@ -92,7 +92,6 @@ declare namespace FC {
 			dickAccessory: string;
 			bellyAccessory: string;
 			aVirginButtplug: string;
-			buttplug: string;
 			vaginalAttachment: string;
 			buttplugAttachment: string;
 			iris: string;
diff --git a/src/endWeek/saClothes.js b/src/endWeek/saClothes.js
index 0abf5f1e2b9..30075c19d63 100644
--- a/src/endWeek/saClothes.js
+++ b/src/endWeek/saClothes.js
@@ -1127,7 +1127,8 @@ App.SlaveAssignment.clothes = (function() {
 	 *
 	 */
 	function analAccessories(slave) {
-		if (slave.buttplug === "plug" || slave.buttplug === "long plug") {
+		const plugDiameter = plugWidth(slave);
+		if (plugDiameter === 1) {
 			if (["cat tail", "cow tail", "fox tail", "tail"].includes(slave.buttplugAttachment)) {
 				if (slave.fuckdoll === 0 && slave.fetish !== "mindbroken") {
 					if (slave.anus < 1) {
@@ -1142,7 +1143,7 @@ App.SlaveAssignment.clothes = (function() {
 						r.push(`It <span class="green">gets ${him} habituated to having ${his} asshole filled.</span>`);
 						slave.sexualFlaw = "none";
 					}
-					if (slave.sexualQuirk === "size queen" && slave.buttplug === "long plug") {
+					if (slave.sexualQuirk === "size queen" && plugLength(slave) > 1) {
 						r.push(`The overly long plug delving the depths of ${his} rear <span class="hotpink">gets ${him} off,</span> since ${he}'s a size queen.`);
 						slave.devotion += 2;
 					}
@@ -1159,13 +1160,13 @@ App.SlaveAssignment.clothes = (function() {
 						r.push(`It <span class="green">gets ${him} habituated to having ${his} asshole filled.</span>`);
 						slave.sexualFlaw = "none";
 					}
-					if (slave.sexualQuirk === "size queen" && slave.buttplug === "long plug") {
+					if (slave.sexualQuirk === "size queen" && plugLength(slave) > 1) {
 						r.push(`The overly long plug delving the depths of ${his} rear <span class="hotpink">gets ${him} off,</span> since ${he}'s a size queen.`);
 						slave.devotion += 2;
 					}
 				}
 			}
-		} else if (slave.buttplug === "large plug" || slave.buttplug === "long, large plug") {
+		} else if (plugDiameter === 2) {
 			if (["cat tail", "cow tail", "fox tail", "tail"].includes(slave.buttplugAttachment)) {
 				if (slave.fuckdoll === 0 && slave.fetish !== "mindbroken") {
 					if (slave.anus < 2) {
@@ -1233,7 +1234,7 @@ App.SlaveAssignment.clothes = (function() {
 					}
 				}
 			}
-		} else if (slave.buttplug === "huge plug" || slave.buttplug === "long, huge plug") {
+		} else if (plugDiameter === 3) {
 			if (["cat tail", "cow tail", "fox tail", "tail"].includes(slave.buttplugAttachment)) {
 				if (slave.anus < 4) {
 					if (slave.fuckdoll === 0 && slave.fetish !== "mindbroken") {
@@ -1308,7 +1309,7 @@ App.SlaveAssignment.clothes = (function() {
 						slave.fetishStrength = 10;
 					}
 				}
-			} else if (slave.buttplug === "plug" || slave.buttplug === "large plug" || slave.buttplug === "long, large plug" || slave.buttplug === "long plug") {
+			} else if (plugWidth(slave) > 0) {
 				if (slave.fetish === "buttslut" && slave.fetishKnown === 0) {
 					r.push(`${He} shows a surprising lack of resistance to the routine of getting the plug up ${his} butt in the morning; ${he} seems to <span class="lightcoral">naturally enjoy anal stimulation.</span>`);
 					slave.fetishKnown = 1;
diff --git a/src/endWeek/saLongTermMentalEffects.js b/src/endWeek/saLongTermMentalEffects.js
index ef0b21b9407..cc3ceb57302 100644
--- a/src/endWeek/saLongTermMentalEffects.js
+++ b/src/endWeek/saLongTermMentalEffects.js
@@ -1337,7 +1337,7 @@ App.SlaveAssignment.longTermMentalEffects = (function() {
 				} else if (V.suppository !== 0) {
 					r.push(`${His} paraphilia is satisfied by the way ${he} gets to take medication.`);
 					App.EndWeek.saVars.paraphiliaSatisfied = 1;
-				} else if (slave.buttplug === "huge plug" || slave.buttplug === "long, huge plug") {
+				} else if (plugWidth(slave) > 2) {
 					r.push(`${His} paraphilia is satisfied by the enormous plug ${he} wears in ${his} ass.`);
 					App.EndWeek.saVars.paraphiliaSatisfied = 1;
 				} else if (slave.assignment === "work in the dairy" && V.dairyStimulatorsSetting > 0) {
diff --git a/src/endWeek/saLongTermPhysicalEffects.js b/src/endWeek/saLongTermPhysicalEffects.js
index 65fbc8197b8..b900d14cad3 100644
--- a/src/endWeek/saLongTermPhysicalEffects.js
+++ b/src/endWeek/saLongTermPhysicalEffects.js
@@ -236,7 +236,7 @@ App.SlaveAssignment.longTermPhysicalEffects = (function() {
 						if (slave.vagina >= 3 && !["huge dildo", "large dildo", "long, huge dildo", "long, large dildo"].includes(slave.vaginalAccessory)) {
 							r.push(`With a rest from strenuous use, <span class="improvement">${his} loose vagina recovers a little.</span>`);
 							slave.vagina -= 1;
-						} else if (slave.anus >= 3 && !["huge plug", "large plug", "long, huge plug", "long, large plug"].includes(slave.buttplug)) {
+						} else if (slave.anus >= 3 && plugWidth(slave) < 2) {
 							r.push(`With a rest from continual sodomy, <span class="improvement">${his} gaping anus recovers a little.</span>`);
 							slave.anus -= 1;
 						}
diff --git a/src/interaction/main/walkPast.js b/src/interaction/main/walkPast.js
index 512c0f0950b..516e06e3e8e 100644
--- a/src/interaction/main/walkPast.js
+++ b/src/interaction/main/walkPast.js
@@ -8376,10 +8376,10 @@ globalThis.walkPast = (function() {
 		}
 		if ((slave.vaginalAccessory === "long dildo") || (slave.vaginalAccessory === "long, large dildo") || (slave.vaginalAccessory === "long, huge dildo")) {
 			t += `With every motion ${he} makes, ${his} dildo shifts, bulging out ${his} stomach.`;
-			if ((slave.buttplug === "long plug") || (slave.buttplug === "long, large plug") || (slave.buttplug === "long, huge plug")) {
+			if (plugLength(slave) > 1) {
 				t += `Beside it, a second bulge caused by ${his} extra long buttplug.`;
 			}
-		} else if ((slave.buttplug === "long plug") || (slave.buttplug === "long, large plug") || (slave.buttplug === "long, huge plug")) {
+		} else if (plugLength(slave) > 1) {
 			t += `With every motion ${he} makes, ${his} buttplug shifts, bulging out ${his} stomach.`;
 		}
 
@@ -8966,10 +8966,10 @@ globalThis.walkPast = (function() {
 		}
 		if ((slave.vaginalAccessory === "long dildo") || (slave.vaginalAccessory === "long, large dildo") || (slave.vaginalAccessory === "long, huge dildo")) {
 			t += `With every motion ${he} makes, ${his} dildo shifts, bulging out ${his} stomach.`;
-			if ((slave.buttplug === "long plug") || (slave.buttplug === "long, large plug") || (slave.buttplug === "long, huge plug")) {
+			if (plugLength(slave) > 1) {
 				t += `Beside it, a second bulge caused by ${his} extra long buttplug.`;
 			}
-		} else if ((slave.buttplug === "long plug") || (slave.buttplug === "long, large plug") || (slave.buttplug === "long, huge plug")) {
+		} else if (plugLength(slave) > 1) {
 			t += `With every motion ${he} makes, ${his} buttplug shifts, bulging out ${his} stomach.`;
 		}
 
diff --git a/src/js/eventSelectionJS.js b/src/js/eventSelectionJS.js
index 69d25cc39e3..de1809507cc 100644
--- a/src/js/eventSelectionJS.js
+++ b/src/js/eventSelectionJS.js
@@ -991,7 +991,7 @@ globalThis.generateRandomEventPoolStandard = function(eventSlave) {
 				}
 			}
 
-			if (["huge plug", "large plug", "long, huge plug", "long, large plug"].includes(eventSlave.buttplug)) {
+			if (plugWidth(eventSlave) > 1) {
 				if (eventSlave.assignment !== Job.CONFINEMENT && isSlaveAvailable(eventSlave)) {
 					if (eventSlave.devotion <= 20) {
 						if (eventSlave.trust >= -50) {
@@ -2049,7 +2049,7 @@ globalThis.generateRandomEventPoolServant = function(eventSlave) {
 				}
 			}
 
-			if (["huge plug", "large plug", "long, huge plug", "long, large plug"].includes(eventSlave.buttplug)) {
+			if (plugWidth(eventSlave) > 1) {
 				if (isSlaveAvailable(eventSlave)) {
 					if (eventSlave.devotion <= 20) {
 						if (eventSlave.trust >= -50) {
diff --git a/src/js/utilsAssessSlave.js b/src/js/utilsAssessSlave.js
index 7120c7da44d..5dfda9f4537 100644
--- a/src/js/utilsAssessSlave.js
+++ b/src/js/utilsAssessSlave.js
@@ -269,3 +269,21 @@ globalThis.shoeHeight = function(slave) {
 	return heelHeight + platformHeight;
 };
 
+/**
+ * @param {App.Entity.SlaveState} slave
+ * @returns {0|1|2|3}
+ */
+globalThis.plugWidth = function(slave) {
+	return App.Data.buttplugs.get(slave.buttplug) ? App.Data.buttplugs.get(slave.buttplug).width : 0;
+};
+
+/**
+ * @param {App.Entity.SlaveState} slave
+ * @returns {0|1|2|3}
+ */
+globalThis.plugLength = function(slave) {
+	return App.Data.buttplugs.get(slave.buttplug) ? App.Data.buttplugs.get(slave.buttplug).length : 0;
+};
+
+
+
diff --git a/src/npc/interaction/fFeelings.tw b/src/npc/interaction/fFeelings.tw
index dafa73b5991..7aab4a8cbaf 100644
--- a/src/npc/interaction/fFeelings.tw
+++ b/src/npc/interaction/fFeelings.tw
@@ -569,11 +569,11 @@ My favorite part of my body i<<s>>
 					I'm <<s>>o horny, <<Master>>. I can't <<s>>top <<s>>taring at <<if $PC.dick != 0>>cock<<s>> and imagining them down my throat, cumming and cumming<<else>>pu<<ss>>ie<<s>> and imagining how their jui<<c>>e<<s>> <<if canTaste(getSlave($AS))>>ta<<s>>te<<else>>feel on my <<s>>kin<</if>><</if>>.
 				<<case "buttslut">>
 					I'm <<s>>o horny, <<Master>>.
-					<<if (["long plug", "plug"].includes(getSlave($AS).buttplug) && getSlave($AS).anus > 2) >>
+					<<if (plugWidth(getSlave($AS)) == 1) && getSlave($AS).anus > 2) >>
 						I wear the buttplug you gave me, but it i<<s>> <<s>>o <<s>>mall... It remind<<s>> me of being fucked in the a<<ss>>, but I can barely feel it. It drive<<s>> me crazy.
-					<<elseif (["long plug", "plug"].includes(getSlave($AS).buttplug) && getSlave($AS).anus < 3) || (["large plug", "long, large plug"].includes(getSlave($AS).buttplug) && getSlave($AS).anus == 3) || (["huge plug", "long, huge plug"].includes(getSlave($AS).buttplug) && getSlave($AS).anus >= 4) >>
+					<<elseif (plugWidth(getSlave($AS)) == 1 && getSlave($AS).anus < 3) || plugWidth(getSlave($AS)) == 2 && getSlave($AS).anus == 3) || plugWidth(getSlave($AS)) == 3 && getSlave($AS).anus >= 4) >>
 						Thank you for the buttplug. It i<<s>> really fun to have my a<<ss>> filled all day long.
-					<<elseif (["large plug", "long, large plug"].includes(getSlave($AS).buttplug) && getSlave($AS).anus < 3) || (["huge plug", "long, huge plug"].includes(getSlave($AS).buttplug) && getSlave($AS).anus < 4) >>
+					<<elseif (plugWidth(getSlave($AS)) == 2 && getSlave($AS).anus < 3) || plugWidth(getSlave($AS)) > 2 && getSlave($AS).anus < 4) >>
 						I like it up the a<<ss>>, but the plug you make me wear i<<s>> too big. It really hurt<<s>>. Not in the good way.
 					<<else>>
 						My anu<<s>> i<<s>> killing me, all I want to do i<<s>> touch it and ma<<ss>>age it and fill it.
diff --git a/src/uncategorized/reShelterInspection.tw b/src/uncategorized/reShelterInspection.tw
index 7fdff1f7b98..95f4f032618 100644
--- a/src/uncategorized/reShelterInspection.tw
+++ b/src/uncategorized/reShelterInspection.tw
@@ -425,7 +425,7 @@ Not waiting to be greeted, the inspector looks up at the nearest camera and dema
 			<br><br>
 			<<run Enunciate(_Inspectee)>>
 			<<if (_Inspectee.devotion < 10)>>
-				<<if (_Inspectee.buttplug == "large plug") || (_Inspectee.buttplug == "huge plug") || (_Inspectee.buttplug == "long, large plug") || (_Inspectee.buttplug == "long, huge plug")>>
+				<<if (plugWidth(_slave) > 1)>>
 					"W-well," $he says, "I wear a buttplug." The inspector frowns.
 					<<run Enunciate(_slave)>>
 					"A buttplug <<sh>>ouldn't do that!"
@@ -447,7 +447,7 @@ Not waiting to be greeted, the inspector looks up at the nearest camera and dema
 					The slave looks worried and replies, "I-it'<<s>> a hole, right? I get fucked in all my hole<<s>>." The inspector is not amused. _He2 offers you a few choice words, makes notes on _his2 tablet, and storms out.
 				<</if>>
 			<<else>>
-				<<if (_Inspectee.buttplug == "large plug") || (_Inspectee.buttplug == "huge plug") || (_Inspectee.buttplug == "long, large plug") || (_Inspectee.buttplug == "long, huge plug")>>
+				<<if (plugWidth(_slave) > 1)>>
 					"I wear a buttplug!" $he says confidently. The inspector frowns.
 					<<run Enunciate(_slave)>>
 					"A buttplug <<sh>>ouldn't do that!"
-- 
GitLab