diff --git a/devNotes/limb functions.md b/devNotes/limb functions.md index fcfe49a8c728ca9166d5e46f2dd9b0f358d5aca7..9d0029e31e4708438d4eadc80bba7a323c83dc40 100644 --- a/devNotes/limb functions.md +++ b/devNotes/limb functions.md @@ -67,6 +67,30 @@ Most functions can be used like this, though some are more specialized. `hasAllNaturalLimbs(slave)`: True if slave has all limbs and all are natural. +`hasLeftArm(slave)`: + True if slave has a left arm. + +`hasRightArm(slave)`: + True if slave has a right arm. + +`hasLeftLeg(slave)`: + True if slave has a left leg. + +`hasRightLeg(slave)`: + True if slave has a right leg. + +`getLeftArmID(slave)`: + Returns limb ID of the left arm. + +`getRightArmID(slave)`: + Returns limb ID of the right arm. + +`getLeftLegID(slave)`: + Returns limb ID of the left leg. + +`getRightLegID(slave)`: + Returns limb ID of the right leg. + `idToDescription(id)`: Returns a very short description of the specified limb ID. 0: "amputated"; @@ -79,11 +103,3 @@ Most functions can be used like this, though some are more specialized. `getLimbCount(slave, id)`: Returns count of specified limb ID. - -`hasLimb(slave, limb)`: - True if slave has specified limb. - Allowed values for limb: "left arm", "right arm", "left leg", "right leg". - -`getLimbID(slave, limb)`: - Returns limb ID of the specified limb. - Allowed values for limb: "left arm", "right arm", "left leg", "right leg". 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 1cf9a1e5b857cf2c7a70702495d5d1c7d22907f3..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,49 +1025,111 @@ 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. + * + * @param {App.Entity.SlaveState} slave + * @returns {number} + */ +window.getLeftArmID = function(slave) { + if (slave.amp < 0) { + return (slave.amp * -1) +1; + } + + if (hasLeftArm(slave)) { + return 1; + } else { + return 0; } }; +/** + * Returns limb ID of the right arm. Uses new IDs. + * + * @param {App.Entity.SlaveState} slave + * @returns {number} + */ +window.getRightArmID = function(slave) { + if (slave.amp < 0) { + return (slave.amp * -1) +1; + } + + if (hasRightArm(slave)) { + return 1; + } else { + return 0; + } +}; /** - * Returns limb ID of the specified limb. Uses new IDs. - * 0: no limb - * 1: natural - * 2: basic - * 3: sex - * 4: beauty - * 5: combat - * 6: cybernetic + * Returns limb ID of the left leg. Uses new IDs. + * + * @param {App.Entity.SlaveState} slave + * @returns {number} + */ +window.getLeftLegID = function(slave) { + if (slave.amp < 0) { + return (slave.amp * -1) +1; + } + + if (hasLeftLeg(slave)) { + return 1; + } else { + return 0; + } +}; + +/** + * Returns limb ID of the right leg. Uses new IDs. * * @param {App.Entity.SlaveState} slave - * @param {String} limb * @returns {number} */ -window.getLimbID = function(slave, limb) { +window.getRightLegID = function(slave) { if (slave.amp < 0) { return (slave.amp * -1) +1; } - if (hasLimb(slave, limb)) { + if (hasRightLeg(slave)) { return 1; } else { return 0; diff --git a/src/uncategorized/remoteSurgery.tw b/src/uncategorized/remoteSurgery.tw index dba2a5b22e19475e640a4d1a71b0be09f5541839..bd18eac9d1bae8e95c571709e928c5cac712d217 100644 --- a/src/uncategorized/remoteSurgery.tw +++ b/src/uncategorized/remoteSurgery.tw @@ -1695,10 +1695,10 @@ I have a nice version, but it depends on the new limb system, so we have to do w <br> <<if !isAmputee($activeSlave)>> Limbs: //This is a temporary solution while limb mechanics are being reworked.//<br> - Left arm: <<print idToDescription(getLimbID($activeSlave, "left arm"))>><br> - Right arm: <<print idToDescription(getLimbID($activeSlave, "right arm"))>><br> - Left leg: <<print idToDescription(getLimbID($activeSlave, "left leg"))>><br> - Right leg: <<print idToDescription(getLimbID($activeSlave, "right leg"))>> + Left arm: <<print idToDescription(getLeftArmID($activeSlave))>><br> + Right arm: <<print idToDescription(getRightArmID($activeSlave)>><br> + Left leg: <<print idToDescription(getLeftLegID($activeSlave))>><br> + Right leg: <<print idToDescription(getRightLegID($activeSlave))>> <<else>> $He is a quadruple amputee <<if $activeSlave.PLimb == 1>>