diff --git a/js/003-data/miscData.js b/js/003-data/miscData.js index 0c336abdf84effeb125fad245d046d915da634cb..73d33a01798ac205e8b1e16b641e5c9fb8676a05 100644 --- a/js/003-data/miscData.js +++ b/js/003-data/miscData.js @@ -2081,7 +2081,9 @@ App.Data.misc = { rs: { either: { clothesBoughtCareer: 1, - "PC.career": "servant" //TODO: this shit right? + PC: { + career: "servant" + } } } }, diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js index 2a0181007243be36f08d6f934fe29e0c330a32bb..f9303c3303f7a67101b1ee57f21467ad0723e3e4 100644 --- a/src/js/itemAvailability.js +++ b/src/js/itemAvailability.js @@ -162,7 +162,7 @@ window.isItemAccessible = function(string) { case "cat tail": case "fox tail": return (V.toysBoughtButtPlugTails === 1); - // "Normal" things: + // "Normal" things: case "an apron": case "slutty jewelry": case "clubslut netting": @@ -213,7 +213,7 @@ window.isClothingAccessible = (function() { * @param {App.Entity.SlaveState} slave * @returns {boolean|string} Returns true if item is accessible, and false if it is not. If the slave param is set, it may sometimes return a string instead of false, explaining why the item can't be used with that slave. */ - function entry(string, category="clothing", slave) { + function entry(string, category = "clothing", slave) { if (V.cheatMode === 1) { return true; } @@ -286,6 +286,7 @@ window.isClothingAccessible = (function() { }); return array; } + function isAvailable(item, category, slave) { if (!(item.hasOwnProperty("fs")) && !(item.hasOwnProperty("rs"))) { // No restriction, this clothing item is available to everyone @@ -293,35 +294,70 @@ window.isClothingAccessible = (function() { } if (item.hasOwnProperty("rs")) { if (typeof item.rs === 'object' && item.rs !== null) { + let fail = false; // Scan rs requirments one by one if they are an object + console.log(item.rs); 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 = Object.keys(item.rs.either).find((nestedRequirement) => { V[nestedRequirement] === item.rs.either[nestedRequirement]; }); - if (typeof eitherCheck === 'undefined') { - return false; + if (typeof item.rs === 'object' && item.rs !== null) { + 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; + Object.keys(item.rs.either).forEach((nestedRequirement) => { + if (typeof item.rs.either[nestedRequirement] === 'object' && item.rs.either[nestedRequirement] !== null) { // And yes sometimes even in either we have a nested object, to check V.PC mostly, so check for it. + let insideEitherCheck = 0; + Object.keys(item.rs.either[nestedRequirement]).forEach((insideNestedRequirement) => { + if (V[nestedRequirement][insideNestedRequirement] === item.rs.either[nestedRequirement][insideNestedRequirement]) { + insideEitherCheck++; + } + console.log(V[nestedRequirement][insideNestedRequirement]); + console.log(item.rs.either[nestedRequirement][insideNestedRequirement]); + }); + console.log(insideEitherCheck); + if (insideEitherCheck > 0) { + eitherCheck++; + } + if (V[nestedRequirement] === item.rs.either[nestedRequirement]) { + eitherCheck++; + } + } + console.log("Either", eitherCheck); + if (eitherCheck === 0) { + fail = true; + } + }); + } else { + Object.keys(item.rs.either).forEach((nestedRequirement) => { // Otherwise we are probably recording a nested V variable to be checked. + if (V[requirement][nestedRequirement] !== item.rs[requirement][nestedRequirement]) { + return false; + } + }); } } else { if (V[requirement] !== item.rs[requirement]) { - return false; + fail = true; } } }); - } else { + console.log("fail", fail); + if (fail) { + return false; + } + } else { // string if (V[item.rs] < 1) { return false; } } } if (item.hasOwnProperty("fs")) { - if (V.arcologies[0][item.fs] > 0) { - return true; + if (V.arcologies[0][item.fs] === 0) { + return false; } } if (slave) { return isAvailableForSlave(item, category, slave); } - return false; + return true; } + function isAvailableForSlave(item, category, slave) { //console.log("isAvailableForSlave ran!", item, category, slave); switch (category) { @@ -338,17 +374,17 @@ window.isClothingAccessible = (function() { } else { return `Slave belly too small for this`; } - case "a small empathy belly": - case "a medium empathy belly": - case "a large empathy belly": - case "a huge empathy belly": - if (slave.belly < 1500 && slave.weight < 130) { - return true; - } else { - return `Slave belly too big for this`; - } - default: - return true; + case "a small empathy belly": + case "a medium empathy belly": + case "a large empathy belly": + case "a huge empathy belly": + if (slave.belly < 1500 && slave.weight < 130) { + return true; + } else { + return `Slave belly too big for this`; + } + default: + return true; } } case "buttplug": { @@ -359,23 +395,23 @@ window.isClothingAccessible = (function() { } else { return true; } - case "long plug": - case "long, large plug": - if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { - return "Elites frown on this"; - } else { - return true; - } - case "long, huge plug": - if (slave.anus < 2) { - return `Slave's anus is too small for this right now`; - } else if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { - return "Elites frown on this"; - } else { - return true; - } - default: - return true; + case "long plug": + case "long, large plug": + if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { + return "Elites frown on this"; + } else { + return true; + } + case "long, huge plug": + if (slave.anus < 2) { + return `Slave's anus is too small for this right now`; + } else if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { + return "Elites frown on this"; + } else { + return true; + } + default: + return true; } } case "buttplugAttachment": @@ -391,23 +427,23 @@ window.isClothingAccessible = (function() { } else { return true; } - case "long dildo": - case "long, large dildo": - if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { - return "Elites frown on this"; - } else { - return true; - } - case "long, huge dildo": - if (slave.vagina < 2) { - return `Slave's vagina is too small for this right now`; - } else if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { - return "Elites frown on this"; - } else { - return true; - } - default: - return true; + case "long dildo": + case "long, large dildo": + if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { + return "Elites frown on this"; + } else { + return true; + } + case "long, huge dildo": + if (slave.vagina < 2) { + return `Slave's vagina is too small for this right now`; + } else if (!(slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) { + return "Elites frown on this"; + } else { + return true; + } + default: + return true; } } case "vaginalAttachment": { @@ -442,34 +478,34 @@ window.isClothingAccessible = (function() { } else { return false; } - case "chastity cage": - case "combined chastity cage": - if (slave.dick > 0) { - return true; - } else { - return false; - } - case "genital chastity": - case "full chastity": - if (slave.vagina > -1 && slave.dick > 0) { - return true; - } else { - return false; - } - case "choose own chastity": - if (slave.choosesOwnChastity !== 1) { - return true; - } else { - return false; - } - case "revoke choosing own chastity": - if (slave.choosesOwnChastity > 0) { - return true; - } else { - return false; - } - default: - return true; + case "chastity cage": + case "combined chastity cage": + if (slave.dick > 0) { + return true; + } else { + return false; + } + case "genital chastity": + case "full chastity": + if (slave.vagina > -1 && slave.dick > 0) { + return true; + } else { + return false; + } + case "choose own chastity": + if (slave.choosesOwnChastity !== 1) { + return true; + } else { + return false; + } + case "revoke choosing own chastity": + if (slave.choosesOwnChastity > 0) { + return true; + } else { + return false; + } + default: + return true; } } default: @@ -499,8 +535,8 @@ window.addProsthetic = function(slave, prosthetic) { if (limb > 0) { let p = { id: prosthetic, - arm: {left: new App.Entity.LimbState(), right: new App.Entity.LimbState()}, - leg: {left: new App.Entity.LimbState(), right: new App.Entity.LimbState()} + arm: { left: new App.Entity.LimbState(), right: new App.Entity.LimbState() }, + leg: { left: new App.Entity.LimbState(), right: new App.Entity.LimbState() } }; p.arm.left.type = limb; p.arm.right.type = limb; @@ -508,7 +544,7 @@ window.addProsthetic = function(slave, prosthetic) { p.leg.right.type = limb; slave.readyProsthetics.push(p); } else { - slave.readyProsthetics.push({id: prosthetic}); + slave.readyProsthetics.push({ id: prosthetic }); } } };