diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js index a8f3d31f52db22afb3e4bfc37bc8bfda56a95980..abde2ea06e8227232781ce93aaa82746d8887b4a 100644 --- a/src/js/itemAvailability.js +++ b/src/js/itemAvailability.js @@ -205,51 +205,42 @@ window.isClothingAccessible = function(string) { return true; } - let success = 0; - - setup.clothes.forEach(item => { - if (item.value === string) { - if (!(item.hasOwnProperty("unlock")) && !(item.hasOwnProperty("fs"))) { - console.log(`${string} is free for everyone!`); - success = 1; + const item = setup.clothes.find((i) => i.value === string); + if (!item) { + console.log(`${string} is not a registered piece of clothing! Check App.Data.Misc.`); + return false; /* couldn't be found */ + } + if (!(item.hasOwnProperty("unlock")) && !(item.hasOwnProperty("fs"))) { + console.log(`${string} is free for everyone!`); + return true; + } + if (item.hasOwnProperty("fs")) { + if (V.arcologies[0][item.fs] > 0) { + console.log(`${string} is in FS!`); + return true; + } + } + if (item.hasOwnProperty("unlock")) { + let keys = Object.keys(item.unlock); + for (let key in keys) { + if (keys[key] === "continent" && V.continent === item.unlock[keys[key]]) { + console.log(`${string} is in continent!`); + return true; + } else if (V[keys[key]] > 0 ) { + console.log(`${string} because ${keys[key]} is true for us!`); return true; } - if (item.hasOwnProperty("fs")) { - if (V.arcologies[0][item.fs] > 0) { - console.log(`${string} is in FS!`); - success = 1; - return true; - } - } - if (item.hasOwnProperty("unlock")) { - let keys = Object.keys(item.unlock); - for (let key in keys) { - if (keys[key] === "continent" && V.continent === item.unlock[keys[key]]) { - console.log(`${string} is in continent!`); - success = 1; - return true; - } else if (V[keys[key]] > 0 ) { - console.log(`${string} because ${keys[key]} is true for us!`); - success = 1; - return true; - } - } - // special case where they must both be true - if (item.unlock.clothesBoughtSports && item.unlock.clothesBoughtCasual) { - if (V.clothesBoughtSports && V.clothesBoughtCasual) { - success = 1; - return true; - } - } + } + // special case where they must both be true + if (item.unlock.clothesBoughtSports && item.unlock.clothesBoughtCasual) { + if (V.clothesBoughtSports && V.clothesBoughtCasual) { + return true; } - console.log("this sucks, we couldn't get: "); - console.log(item); } - return false; - }); - if (success === 1) { - return true; } + console.log("this sucks, we couldn't get: "); + console.log(item); + return false; }; /**