Skip to content
Snippets Groups Projects
Commit 3f7f180b authored by lowercasedonkey's avatar lowercasedonkey
Browse files

improve isClothingAvailable search HT svorn

parent eb51432d
No related branches found
No related tags found
1 merge request!6135Use setup for wardrobe
...@@ -205,51 +205,42 @@ window.isClothingAccessible = function(string) { ...@@ -205,51 +205,42 @@ window.isClothingAccessible = function(string) {
return true; return true;
} }
let success = 0; const item = setup.clothes.find((i) => i.value === string);
if (!item) {
setup.clothes.forEach(item => { console.log(`${string} is not a registered piece of clothing! Check App.Data.Misc.`);
if (item.value === string) { return false; /* couldn't be found */
if (!(item.hasOwnProperty("unlock")) && !(item.hasOwnProperty("fs"))) { }
console.log(`${string} is free for everyone!`); if (!(item.hasOwnProperty("unlock")) && !(item.hasOwnProperty("fs"))) {
success = 1; 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; return true;
} }
if (item.hasOwnProperty("fs")) { }
if (V.arcologies[0][item.fs] > 0) { // special case where they must both be true
console.log(`${string} is in FS!`); if (item.unlock.clothesBoughtSports && item.unlock.clothesBoughtCasual) {
success = 1; if (V.clothesBoughtSports && V.clothesBoughtCasual) {
return true; 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;
}
}
} }
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;
}; };
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment