diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js index 0c21dc77822b70a2822ba408311d59f2be806905..2a0181007243be36f08d6f934fe29e0c330a32bb 100644 --- a/src/js/itemAvailability.js +++ b/src/js/itemAvailability.js @@ -293,17 +293,11 @@ window.isClothingAccessible = (function() { } if (item.hasOwnProperty("rs")) { if (typeof item.rs === 'object' && item.rs !== null) { - // Scan rs requirments one by one if they are an object - item.rs.forEach((requirement) => { + Object.keys(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) { + let eitherCheck = Object.keys(item.rs.either).find((nestedRequirement) => { V[nestedRequirement] === item.rs.either[nestedRequirement]; }); + if (typeof eitherCheck === 'undefined') { return false; } } else { @@ -312,7 +306,6 @@ window.isClothingAccessible = (function() { } } }); - } else { if (V[item.rs] < 1) { return false; @@ -325,9 +318,7 @@ window.isClothingAccessible = (function() { } } if (slave) { - let test = isAvailableForSlave(item, category, slave); - //console.log(test); - return test; + return isAvailableForSlave(item, category, slave); } return false; }