From 11c623fc9ed918db2a3e3ea651e2f376f1698b83 Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Wed, 19 Feb 2020 21:26:22 -0500 Subject: [PATCH] clothing check can return errors now --- js/003-data/miscData.js | 10 +++++----- src/js/itemAvailability.js | 7 ++++--- src/js/wardrobeUse.js | 9 ++++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/js/003-data/miscData.js b/js/003-data/miscData.js index fdead4db832..c9bbfadff91 100644 --- a/js/003-data/miscData.js +++ b/js/003-data/miscData.js @@ -2489,7 +2489,7 @@ App.Data.misc = { if (V.toysBoughtButtPlugs > 0) { if (slave) { if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { - return false; + return "Elites frown on this"; } else{ return true; } @@ -2511,7 +2511,7 @@ App.Data.misc = { if (V.toysBoughtButtPlugs > 0) { if (slave) { if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { - return false; + return "Elites frown on this"; } else { return true; } @@ -2527,7 +2527,7 @@ App.Data.misc = { unlock: function(slave) { if (slave) { if (slave.anus < 2) { - return false; // clothingOption.disabled = `Slave's anus is too small for this right now`; + return `Slave's anus is too small for this right now`; } else { return true; } @@ -2544,9 +2544,9 @@ App.Data.misc = { if (V.toysBoughtButtPlugs > 0) { if (slave) { if (slave.anus < 2) { - return false; // clothingOption.disabled = `Slave's anus is too small for this right now`; + return `Slave's anus is too small for this right now`; } else if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { - return false; // clothingOption.disabled = "Elites frown on this"; + return "Elites frown on this"; } else { return true; } diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js index 1afbb299350..ad14c362208 100644 --- a/src/js/itemAvailability.js +++ b/src/js/itemAvailability.js @@ -209,14 +209,14 @@ window.isClothingAccessible = (function() { /** * Checks whether clothing is accessible * @param {string} string Name of wearable item - * @returns {boolean} + * @returns {boolean|string} Returns true if it is accessible, and if it is not either false or a string explaining why */ function entry(string, category="clothing", slave) { if (V.cheatMode === 1) { return true; } - let niceDB; - let harshDB; + let niceDB = []; + let harshDB = []; if (["clothing", "clothes"].includes(category)) { niceDB = App.Data.misc.niceClothes; harshDB = App.Data.misc.harshClothes; @@ -238,6 +238,7 @@ window.isClothingAccessible = (function() { //} else if (category === "chastity") { // niceDB = App.Data.misc.vaginalAccessories; //this is going to be weird, they aren't in App.Data.Misc } else { + console.log(`made a category for ${category} automatically, may need to define this by hand`); niceDB = App.Data.misc[category]; } let item = niceDB.find((i) => i.value === string); diff --git a/src/js/wardrobeUse.js b/src/js/wardrobeUse.js index 25bbbdf3e42..d36e98e3058 100644 --- a/src/js/wardrobeUse.js +++ b/src/js/wardrobeUse.js @@ -485,10 +485,17 @@ App.UI.Wardrobe.generateRows = function(array, category, slave, ignoreAccessChec break; } } - if (ignoreAccessCheck === true || isClothingAccessible.entry(array[i].updateSlave[category], `${category}`, slave)) { + // Some items will never be in App.data.misc, especially "none" if it falls in between harsh and nice data sets. Trying to look it up would cause an error, which is what access check works around. + let unlocked; + if (ignoreAccessCheck === false) { + unlocked = isClothingAccessible.entry(array[i].updateSlave[category], `${category}`, slave); + } + if (ignoreAccessCheck === true || unlocked) { // is it just text? if (array[i].disabled) { link = App.UI.DOM.disabledLink(array[i].text, [array[i].disabled]); + } else if (typeof unlocked === 'string') { + link = App.UI.DOM.disabledLink(array[i].text, [unlocked]); } else { link = document.createElement('span'); -- GitLab