From f393b16fbf5ff2b76a196272d37585c681f3d184 Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Fri, 21 Feb 2020 15:10:57 -0500 Subject: [PATCH] more --- src/js/itemAvailability.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js index cbb74415ff5..0c21dc77822 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; } })(); -- GitLab