diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js index cbb74415ff525e0c98f7cb7e6d5b72f850708267..0c21dc77822b70a2822ba408311d59f2be806905 100644 --- a/src/js/itemAvailability.js +++ b/src/js/itemAvailability.js @@ -292,8 +292,31 @@ window.isClothingAccessible = (function() { return true; } if (item.hasOwnProperty("rs")) { - if (V[item.rs] > 0) { - return true; + if (typeof item.rs === 'object' && item.rs !== null) { + + // Scan rs requirments one by one if they are an object + item.rs.forEach((requirement) => { + if (requirement === "either") { // If we find the "either" nested object, we need to see if just one of the conditions in it are true. + let eitherCheck = 0; + item.rs.either.forEach((nestedRequirement) => { + if (V[nestedRequirement] === item.rs.either[nestedRequirement]){ + eitherCheck++; + } + }); + if (eitherCheck === 0) { + return false; + } + } else { + if (V[requirement] !== item.rs[requirement]) { + return false; + } + } + }); + + } else { + if (V[item.rs] < 1) { + return false; + } } } if (item.hasOwnProperty("fs")) { @@ -302,11 +325,14 @@ window.isClothingAccessible = (function() { } } if (slave) { - return isAvailableForSlave(item, slave); + let test = isAvailableForSlave(item, category, slave); + //console.log(test); + return test; } return false; } - function isAvailableForSlave(item, slave) { + function isAvailableForSlave(item, category, slave) { + //console.log("isAvailableForSlave ran!", item, category, slave); switch (category) { case "clothing": case "clothes": @@ -459,6 +485,7 @@ window.isClothingAccessible = (function() { console.log(`made a category for ${category} automatically, may need to define this by hand`); break; } + return true; } })();