diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index a9ea412c1350a322ea78a534724943870f3d878c..f18f957a3cb83961b6c689adae3c362fb622bcc5 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -2906,15 +2906,15 @@ window.DefaultRules = (function() { // Check for amputations: if (["upper arms", "lower arms", "wrists", "hands"].includes(rule.brandTarget)) { // Arms - if (!hasLimb(slave, "left arm") && !hasLimb(slave, "right arm")) { + if (!hasAnyArms(slave)) { brandPlace = ""; - } else if (!hasLimb(slave, "left arm")) { + } else if (!hasLeftArm(slave)) { if (brandPlace === "both") { brandPlace = "right"; } if (brandPlace === "left") { brandPlace = ""; } - } else if (!hasLimb(slave, "right arm")) { + } else if (!hasRightArm(slave)) { if (brandPlace === "both") { brandPlace = "left"; } if (brandPlace === "right") { @@ -2923,15 +2923,15 @@ window.DefaultRules = (function() { } } else if (["thighs", "calves", "ankles", "feet"].includes(rule.brandTarget)) { // Legs - if (!hasLimb(slave, "left leg") && !hasLimb(slave, "right leg")) { + if (!hasAnyLegs(slave)) { brandPlace = ""; - } else if (!hasLimb(slave, "left leg")) { + } else if (!hasLeftLeg(slave)) { if (brandPlace === "both") { brandPlace = "right"; } if (brandPlace === "left") { brandPlace = ""; } - } else if (!hasLimb(slave, "right leg")) { + } else if (!hasRightLeg(slave)) { if (brandPlace === "both") { brandPlace = "left"; } if (brandPlace === "right") { @@ -2943,10 +2943,10 @@ window.DefaultRules = (function() { // Brand location does NOT need to be split into a left and right, (and may or may not contain left OR right already.) } else if (slave.brand[rule.brandTarget] !== rule.brandDesign) { if ( - (!hasLimb(slave, "left arm") && ["left upper arm", "left lower arm", "left wrist", "left hand"].includes(rule.brandTarget)) || - (!hasLimb(slave, "right arm") && ["right upper arm", "right lower arm", "right wrist", "right hand"].includes(rule.brandTarget)) || - (!hasLimb(slave, "left leg") && ["left thigh", "left calf", "left ankle", "left foot"].includes(rule.brandTarget)) || - (!hasLimb(slave, "right leg") && ["right thigh", "right calf", "right ankle", "rightfoot"].includes(rule.brandTarget)) + (!hasLeftArm(slave) && ["left upper arm", "left lower arm", "left wrist", "left hand"].includes(rule.brandTarget)) || + (!hasRightArm(slave) && ["right upper arm", "right lower arm", "right wrist", "right hand"].includes(rule.brandTarget)) || + (!hasLeftLeg(slave) && ["left thigh", "left calf", "left ankle", "left foot"].includes(rule.brandTarget)) || + (!hasRightLeg(slave) && ["right thigh", "right calf", "right ankle", "rightfoot"].includes(rule.brandTarget)) ) { brandPlace = ""; } else { diff --git a/src/js/slaveStatsChecker.js b/src/js/slaveStatsChecker.js index 1ee618fa66c58f32a455fe2bcc6a52490fc2a6a3..2987ddb8ce8dd88e24306a0b86219fb5c0785f66 100644 --- a/src/js/slaveStatsChecker.js +++ b/src/js/slaveStatsChecker.js @@ -1007,16 +1007,16 @@ window.getLimbCount = function(slave, id) { } let n = 0; - if (hasLimb(slave, "left arm")) { + if (hasLeftArm(slave)) { n++; } - if (hasLimb(slave, "right arm")) { + if (hasRightArm(slave)) { n++; } - if (hasLimb(slave, "left leg")) { + if (hasLeftLeg(slave)) { n++; } - if (hasLimb(slave, "right leg")) { + if (hasRightLeg(slave)) { n++; } @@ -1025,28 +1025,44 @@ window.getLimbCount = function(slave, id) { /** - * True if slave has specified limb + * True if slave has left arm * * @param {App.Entity.SlaveState} slave - * @param {String} limb * @returns {boolean} */ -window.hasLimb = function(slave, limb) { - switch (limb) { - case "left arm": - return slave.missingArms !== 1 && slave.missingArms !== 3; - case "right arm": - return slave.missingArms < 2; - case "left leg": - return slave.missingLegs !== 1 && slave.missingLegs !== 3; - case "right leg": - return slave.missingLegs < 2; - default: - // eslint-disable-next-line no-console - console.error(`Unknown limb` + limb); - } +window.hasLeftArm = function(slave) { + return slave.missingArms !== 1 && slave.missingArms !== 3; +}; + +/** + * True if slave has right arm + * + * @param {App.Entity.SlaveState} slave + * @returns {boolean} + */ +window.hasRightArm = function(slave) { + return slave.missingArms < 2; +}; + +/** + * True if slave has left leg + * + * @param {App.Entity.SlaveState} slave + * @returns {boolean} + */ +window.hasLeftLeg = function(slave) { + return slave.missingLegs !== 1 && slave.missingLegs !== 3; }; +/** + * True if slave has right leg + * + * @param {App.Entity.SlaveState} slave + * @returns {boolean} + */ +window.hasRightLeg = function(slave) { + return slave.missingLegs < 2; +}; /** * Returns limb ID of the left arm. Uses new IDs. @@ -1059,7 +1075,7 @@ window.getLeftArmID = function(slave) { return (slave.amp * -1) +1; } - if (hasLimb(slave, "left arm")) { + if (hasLeftArm(slave)) { return 1; } else { return 0; @@ -1077,7 +1093,7 @@ window.getRightArmID = function(slave) { return (slave.amp * -1) +1; } - if (hasLimb(slave, "right arm")) { + if (hasRightArm(slave)) { return 1; } else { return 0; @@ -1095,7 +1111,7 @@ window.getLeftLegID = function(slave) { return (slave.amp * -1) +1; } - if (hasLimb(slave, "left leg")) { + if (hasLeftLeg(slave)) { return 1; } else { return 0; @@ -1113,7 +1129,7 @@ window.getRightLegID = function(slave) { return (slave.amp * -1) +1; } - if (hasLimb(slave, "right leg")) { + if (hasRightLeg(slave)) { return 1; } else { return 0;