From 4f62d5e8569787dcbf1c8f923dd29a90b890cf30 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Sat, 26 Dec 2020 22:48:19 -0500
Subject: [PATCH] use data for more descriptions

---
 js/003-data/slaveWearData.js                  |  9 +-
 src/art/vector/VectorArtJS.js                 |  2 +-
 src/endWeek/saClothes.js                      |  2 +-
 src/endWeek/saSmartPiercingEffects.js         |  2 +-
 src/interaction/siRules.js                    |  2 +-
 src/interaction/siWardrobe.js                 |  2 +-
 src/js/itemAvailability.js                    |  4 +-
 src/js/utilsAssessSlave.js                    | 17 +++-
 .../descriptions/crotch/vaginalAccessory.js   | 95 ++++++++-----------
 9 files changed, 73 insertions(+), 62 deletions(-)

diff --git a/js/003-data/slaveWearData.js b/js/003-data/slaveWearData.js
index b649e699b8f..526692b09d2 100644
--- a/js/003-data/slaveWearData.js
+++ b/js/003-data/slaveWearData.js
@@ -1223,6 +1223,8 @@ App.Data.buttplugs = new Map([
  * @property {boolean} [requirements]
  * @property {0|1|2|3} width
  * @property {0|1|2} length
+ * @property {boolean} [smart]
+ * @property {boolean} [vibrates]
  */
 
 /**
@@ -1240,7 +1242,8 @@ App.Data.vaginalAccessories = new Map([
 		{
 			name: "Bullet vibrator",
 			width: 0,
-			length: 1
+			length: 1,
+			vibrates: true
 		}
 	],
 	["smart bullet vibrator",
@@ -1250,7 +1253,9 @@ App.Data.vaginalAccessories = new Map([
 				return V.boughtItem.toys.smartVibes === 1;
 			},
 			width: 0,
-			length: 1
+			length: 1,
+			smart: true,
+			vibrates: true
 		}
 	],
 	["dildo",
diff --git a/src/art/vector/VectorArtJS.js b/src/art/vector/VectorArtJS.js
index 05f494ec145..d58a6ce3ed2 100644
--- a/src/art/vector/VectorArtJS.js
+++ b/src/art/vector/VectorArtJS.js
@@ -1771,7 +1771,7 @@ App.Art.vectorArtElement = (function() {
 						} else if (slave.vaginalAccessory === "long, huge dildo") {
 							svgQueue.add("Art_Vector_Dildo_Huge_Long");
 						}
-					} /* else if (slave.vaginalAccessory === "bullet vibrator" || slave.vaginalAccessory === "smart bullet vibrator") {
+					} /* else if (dildoWidth(slave) === 0) {
 						svgQueue.add("Art_Vector_Bullet_Vibrator");
 					} */
 			}
diff --git a/src/endWeek/saClothes.js b/src/endWeek/saClothes.js
index 5c8076cc91c..e2cd5e60178 100644
--- a/src/endWeek/saClothes.js
+++ b/src/endWeek/saClothes.js
@@ -71,7 +71,7 @@ App.SlaveAssignment.clothes = (function() {
 			slave.vaginalAccessory = "none";
 			slave.vaginalAttachment = "none";
 		} else {
-			if (["none", "bullet vibrator", "smart bullet vibrator"].includes(slave.vaginalAccessory)) {
+			if (dildoWidth(slave) === 0) {
 				slave.vaginalAttachment = "none";
 			}
 		}
diff --git a/src/endWeek/saSmartPiercingEffects.js b/src/endWeek/saSmartPiercingEffects.js
index 7b13bbba49b..b0c5d0fd4b7 100644
--- a/src/endWeek/saSmartPiercingEffects.js
+++ b/src/endWeek/saSmartPiercingEffects.js
@@ -409,7 +409,7 @@ App.SlaveAssignment.SmartPiercing.sadist = class extends App.SlaveAssignment.Sma
 App.SlaveAssignment.saSmartPiercingEffects = function(slave) {
 	const {he, his, His, him} = getPronouns(slave);
 	const hasBV = slave.vaginalAccessory === "bullet vibrator" || slave.dickAccessory === "bullet vibrator";
-	const hasSmartBV = slave.vaginalAccessory === "smart bullet vibrator" || slave.dickAccessory === "smart bullet vibrator";
+	const hasSmartBV = dildoSmart(slave) || slave.dickAccessory === "smart bullet vibrator";
 	const hasDildoVibe = slave.vaginalAttachment === "vibrator";
 	const hasSmartDildoVibe = slave.vaginalAttachment === "smart vibrator";
 	const hasSP = slave.clitPiercing === 3;
diff --git a/src/interaction/siRules.js b/src/interaction/siRules.js
index b5e02a19410..3fc93bf4752 100644
--- a/src/interaction/siRules.js
+++ b/src/interaction/siRules.js
@@ -374,7 +374,7 @@ App.UI.SlaveInteract.rules = function(slave) {
 
 	function smartSettings(slave) {
 		let el = document.createElement('div');
-		const smartBulletVibe = slave.vaginalAccessory === "smart bullet vibrator" || slave.dickAccessory === "smart bullet vibrator";
+		const smartBulletVibe = dildoSmart(slave) || slave.dickAccessory === "smart bullet vibrator";
 		const smartDildoVibe = slave.vaginalAttachment === "smart vibrator";
 
 		if (slave.clitPiercing === 3 || smartBulletVibe || smartDildoVibe) {
diff --git a/src/interaction/siWardrobe.js b/src/interaction/siWardrobe.js
index 511d657d698..e29e62e797b 100644
--- a/src/interaction/siWardrobe.js
+++ b/src/interaction/siWardrobe.js
@@ -617,7 +617,7 @@ App.UI.SlaveInteract.wardrobe = function(slave) {
 
 	function vaginalAttachment() {
 		let el = document.createElement('div');
-		if (["none", "bullet vibrator", "smart bullet vibrator"].includes(slave.vaginalAccessory)) {
+		if (dildoWidth(slave) === 0) {
 			return el;
 		}
 
diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js
index e2349b2a2eb..045fa9ed0ca 100644
--- a/src/js/itemAvailability.js
+++ b/src/js/itemAvailability.js
@@ -224,7 +224,9 @@ globalThis.isItemAccessible = (function() {
 					case "vibrator":
 						if (slave.vaginalAccessory === "none") {
 							return "No vaginal accessory to attach it to";
-						} else if (slave.vaginalAccessory === "bullet vibrator" || slave.vaginalAccessory === "smart bullet vibrator") {
+						} else if (dildoWidth(slave) === 0) {
+							return "Vaginal accessory is too small";
+						} else if (dildoVibrates(slave)) {
 							return "Vaginal accessory already vibrates";
 						} else {
 							return true;
diff --git a/src/js/utilsAssessSlave.js b/src/js/utilsAssessSlave.js
index 46ad2ff0418..9fcd3b5b0bb 100644
--- a/src/js/utilsAssessSlave.js
+++ b/src/js/utilsAssessSlave.js
@@ -303,5 +303,20 @@ globalThis.dildoLength = function(slave) {
 	return dildo.length || 0;
 };
 
+/**
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+globalThis.dildoSmart = function(slave) {
+	const dildo = App.Data.vaginalAccessories.get(slave.vaginalAccessory) || V.customItem.vaginalAccessories.get(slave.vaginalAccessory);
+	return dildo.smart || false;
+};
 
-
+/**
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+globalThis.dildoVibrates = function(slave) {
+	const dildo = App.Data.vaginalAccessories.get(slave.vaginalAccessory) || V.customItem.vaginalAccessories.get(slave.vaginalAccessory);
+	return dildo.vibrates || false;
+};
diff --git a/src/npc/descriptions/crotch/vaginalAccessory.js b/src/npc/descriptions/crotch/vaginalAccessory.js
index 847437102c8..735036f02d0 100644
--- a/src/npc/descriptions/crotch/vaginalAccessory.js
+++ b/src/npc/descriptions/crotch/vaginalAccessory.js
@@ -10,35 +10,25 @@ App.Desc.vaginalAccessory = function(slave) {
 	let held;
 	if (slave.chastityVagina) {
 		held = "held in place by a chastity belt";
-	} else if (slave.vaginalAccessory === "bullet vibrator" || slave.vaginalAccessory === "smart bullet vibrator") {
+	} else if (dildoWidth(slave) === 0) {
 		held = "held in place by a strap";
 	} else {
 		held = `held in place by a strap, which ${he} can remove for vaginal intercourse`;
 	}
-	switch (slave.vaginalAccessory) {
-		case "bullet vibrator":
-		case "smart bullet vibrator":	// FIXME: two different descriptions?
-			r.push(`A bullet vibrator is attached on ${his} clit, ${held}.`);	// FIXME: not super happy with this
+	const dildo = App.Data.vaginalAccessories.get(slave.vaginalAccessory) || V.customItem.vaginalAccessories.get(slave.vaginalAccessory);
+	switch (dildo.width) {
+		case 0:
+			r.push(`A ${slave.vaginalAccessory} is attached on ${his} clit, ${held}.`);	// FIXME: not super happy with this
 			break;
-		case "dildo":
-			/* TODO: these may need to be updated for slaves with gaping+ vaginas */
-			r.push(`${His} pussy is filled by a dildo ${held}.`);
-			break;
-		case "long dildo":
-			r.push(`${His} pussy is filled by a very long dildo ${held}. It noticeably bulges ${his} stomach.`);
-			break;
-		case "large dildo":
-			r.push(`${His} pussy is`);
-			if (slave.vagina < 2) {
-				r.push(`painfully stretched`);
-			} else if (slave.vagina < 3) {
-				r.push(`uncomfortably filled`);
+		case 1:
+			if (dildo.length === 1) {
+				/* TODO: these may need to be updated for slaves with gaping+ vaginas */
+				r.push(`${His} pussy is filled by a dildo ${held}.`);
 			} else {
-				r.push(`comfortably filled`);
+				r.push(`${His} pussy is filled by a very long dildo ${held}. It noticeably bulges ${his} stomach.`);
 			}
-			r.push(`by a large dildo ${held}.`);
 			break;
-		case "long, large dildo":
+		case 2:
 			r.push(`${His} pussy is`);
 			if (slave.vagina < 2) {
 				r.push(`painfully stretched`);
@@ -47,33 +37,35 @@ App.Desc.vaginalAccessory = function(slave) {
 			} else {
 				r.push(`comfortably filled`);
 			}
-			r.push(`by a very long and large dildo ${held}. It noticeably bulges ${his} stomach.`);
-			break;
-		case "huge dildo":
-			if (slave.vagina < 4) {
-				r.push(`${His} pussy is filled to the breaking point by an enormous dildo.`);
-				if (slave.fetish === "masochist" && slave.fetishKnown === 1 && slave.fetishStrength > 60) {
-					r.push(`${He} can barely move with the discomfort, but ${he} frequently climaxes with agony.`);
-				} else {
-					r.push(`${He} can barely move with the discomfort, and ${he} sometimes breaks down in tears at having ${his} cunt permanently stretched.`);
-				}
+			if (dildo.length === 1) {
+				r.push(`by a large dildo ${held}.`);
 			} else {
-				r.push(`${His} cavernous pussy is comfortably filled by a huge dildo.`);
-			}
-			if (slave.chastityVagina) {
-				r.push(`A chastity belt locks it securely in place.`);
+				r.push(`by a very long and large dildo ${held}. It noticeably bulges ${his} stomach.`);
 			}
 			break;
-		case "long, huge dildo":
-			if (slave.vagina < 4) {
-				r.push(`${His} pussy is filled to the breaking point by an enormously wide and long dildo. It noticeably bulges ${his} stomach.`);
-				if (slave.fetish === "masochist" && slave.fetishKnown === 1 && slave.fetishStrength > 60) {
-					r.push(`${He} can barely move with the discomfort, but ${he} frequently climaxes with agony.`);
+		case 3:
+			if (dildo.length === 1) {
+				if (slave.vagina < 4) {
+					r.push(`${His} pussy is filled to the breaking point by an enormous dildo.`);
+					if (slave.fetish === "masochist" && slave.fetishKnown === 1 && slave.fetishStrength > 60) {
+						r.push(`${He} can barely move with the discomfort, but ${he} frequently climaxes with agony.`);
+					} else {
+						r.push(`${He} can barely move with the discomfort, and ${he} sometimes breaks down in tears at having ${his} cunt permanently stretched.`);
+					}
 				} else {
-					r.push(`${He} can barely move with the discomfort, and ${he} sometimes breaks down in tears at having ${his} cunt permanently stretched.`);
+					r.push(`${His} cavernous pussy is comfortably filled by a huge dildo.`);
 				}
 			} else {
-				r.push(`${His} cavernous pussy is comfortably filled by an enormously wide and long dildo. It noticeably bulges ${his} stomach.`);
+				if (slave.vagina < 4) {
+					r.push(`${His} pussy is filled to the breaking point by an enormously wide and long dildo. It noticeably bulges ${his} stomach.`);
+					if (slave.fetish === "masochist" && slave.fetishKnown === 1 && slave.fetishStrength > 60) {
+						r.push(`${He} can barely move with the discomfort, but ${he} frequently climaxes with agony.`);
+					} else {
+						r.push(`${He} can barely move with the discomfort, and ${he} sometimes breaks down in tears at having ${his} cunt permanently stretched.`);
+					}
+				} else {
+					r.push(`${His} cavernous pussy is comfortably filled by an enormously wide and long dildo. It noticeably bulges ${his} stomach.`);
+				}
 			}
 			if (slave.chastityVagina) {
 				r.push(`A chastity belt locks it securely in place.`);
@@ -107,27 +99,24 @@ App.Desc.vaginalAttachment = function(slave) {
 	const {
 		his, He, His
 	} = getPronouns(slave);
-	switch (slave.vaginalAttachment) {
-		case "vibrator":
+	if (dildoVibrates(slave)) {
+		if (dildoSmart(slave)) {
 			// TODO: not sure about this description
-			r.push(`${He} looks distinctly uncomfortable as ${his} dildo buzzes every so often.`);
+			r.push(`${His} dildo buzzes every so often, when prompted by the arcology's systems to train ${his} sexuality.`);
 			if (slave.chastityVagina) {
 				r.push(`The chastity belt locking it in place means there is no escape.`);
 			}
 			// TODO: add descriptions for slaves with gaping+ vaginas
-			break;
-		case "smart vibrator":
+		} else {
 			// TODO: not sure about this description
-			r.push(`${His} dildo buzzes every so often, when prompted by the arcology's systems to train ${his} sexuality.`);
+			r.push(`${He} looks distinctly uncomfortable as ${his} dildo buzzes every so often.`);
 			if (slave.chastityVagina) {
 				r.push(`The chastity belt locking it in place means there is no escape.`);
 			}
 			// TODO: add descriptions for slaves with gaping+ vaginas
-			break;
-		default:
-			if (!(["none", "bullet vibrator", "smart bullet vibrator"].includes(slave.vaginalAccessory))) {
-				r.push(`${His} current accessory is silent.`);
-			}
+		}
+	} else {
+		r.push(`${His} current accessory is silent.`);
 	}
 	return r.join(" ");
 };
-- 
GitLab