From 3a628a6920c73e9b94c53831e7e9f94fb00f44c9 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Fri, 21 Feb 2020 15:23:00 -0500
Subject: [PATCH] fix loops

---
 src/js/itemAvailability.js | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js
index 0c21dc77822..2a018100724 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;
 	}
-- 
GitLab