diff --git a/devNotes/limb functions.md b/devNotes/limb functions.md index 9d0029e31e4708438d4eadc80bba7a323c83dc40..94bf3478a9bd3078e391821ecb566abb28fb62d3 100644 --- a/devNotes/limb functions.md +++ b/devNotes/limb functions.md @@ -44,7 +44,13 @@ Most functions can be used like this, though some are more specialized. True if slave has at least one arm. `hasAnyNaturalLegs(slave)`: - True if slave has at least one leg and all are natural. + True if slave has at least one leg that is natural + +`hasAnyNaturalArms(slave)`: + True if slave has at least one arm that is natural + +`hasAnyProstheticArms(slave)`: + True if slave has at least one arm that is prosthetic `hasBothLegs(slave)`: True if slave has both legs. @@ -58,9 +64,6 @@ Most functions can be used like this, though some are more specialized. `hasBothNaturalArms(slave)`: True if slave has both arms and they are natural. -`hasLegAndArm(slave)`: - True if slave has at least one leg and at least one arm. - `hasAllLimbs(slave)`: True if slave has all limbs. @@ -103,3 +106,26 @@ Most functions can be used like this, though some are more specialized. `getLimbCount(slave, id)`: Returns count of specified limb ID. + Can also be used to check for groups: + 101: any limbs that are not amputated + 102: prosthetic limbs off all kind + 103: sex-prosthetic + 104: beauty-prosthetic + 105: combat-prosthetic + +103-105 mean the sum of 3-5 and 6 respectfully. + +`getLegCount(slave, id)`: + Returns count of legs with specified limb ID. + +`getArmCount(slave, id)`: + Returns count of arms with specified limb ID. + +`armsAndLegs(slave, arms, arm, legs, leg)`: + Returns a string depending on the limbs a slave has. By default this is a + variation of `arms and legs`, but this can be changed via parameters. + +Examples: +`armsAndLegs(slave, "hands", "hand", "feet", foot)` returns `hands and feet` for a slave with all limbs, `hand and foot` for a slave with one limb each and `feet` for a slave with two legs, but no arms. + +Expects the slave to have at least one limb. Only the first parameter is mandatory, the rest defaults to the equivalent of `armsAndLegs(slave, "arms", "arm", "legs", "leg")` diff --git a/src/js/slaveStatsChecker.js b/src/js/slaveStatsChecker.js index 0daca5186bb0fad83a1e1878bad2097e3b1435b9..6627b2b99635b016f9b9ef267e0f51b319247745 100644 --- a/src/js/slaveStatsChecker.js +++ b/src/js/slaveStatsChecker.js @@ -832,7 +832,7 @@ window.isAmputee = function(slave) { }; /** - * True if slave has any natural limbs + * True if slave has at least one natural limb * * @param {App.Entity.SlaveState} slave * @returns {boolean} @@ -843,7 +843,7 @@ window.hasAnyNaturalLimbs = function(slave) { /** - * True if slave has any prosthetic limbs + * True if slave has at least one prosthetic limb * * @param {App.Entity.SlaveState} slave * @returns {boolean} @@ -883,23 +883,23 @@ window.hasAnyNaturalLegs = function(slave) { }; /** - * True if slave has at least one arm that is prosthetic + * True if slave has at least one arm that is natural * * @param {App.Entity.SlaveState} slave * @returns {boolean} */ -window.hasAnyProstheticArms = function(slave) { - return slave.amp < 0; +window.hasAnyNaturalArms = function(slave) { + return slave.amp === 0 && slave.missingArms < 3; }; /** - * True if slave has at least one arm that is natural + * True if slave has at least one arm that is prosthetic * * @param {App.Entity.SlaveState} slave * @returns {boolean} */ -window.hasAnyNaturalArms = function(slave) { - return slave.amp === 0 && slave.missingArms < 3; +window.hasAnyProstheticArms = function(slave) { + return slave.amp < 0; }; /** @@ -934,7 +934,7 @@ window.hasBothNaturalLegs = function(slave) { }; /** - * True if slave has arms legs and they are natural + * True if slave has both arms and they are natural * * @param {App.Entity.SlaveState} slave * @returns {boolean} @@ -944,33 +944,135 @@ window.hasBothNaturalArms = function(slave) { }; /** - * True if slave has at least one leg and at least one arm. + * True if slave has all limbs * * @param {App.Entity.SlaveState} slave * @returns {boolean} */ -window.hasLegAndArm = function(slave) { - return hasAnyLegs(slave) && hasAnyArms(slave); +window.hasAllLimbs = function(slave) { + return hasBothLegs(slave) && hasBothArms(slave); }; /** - * True if slave has all limbs + * True if slave has all limbs and all are natural * * @param {App.Entity.SlaveState} slave * @returns {boolean} */ -window.hasAllLimbs = function(slave) { - return hasBothLegs(slave) && hasBothArms(slave); +window.hasAllNaturalLimbs = function(slave) { + return hasBothNaturalLegs(slave) && hasBothNaturalArms(slave); }; /** - * True if slave has all limbs and all are natural + * True if slave has left arm * * @param {App.Entity.SlaveState} slave * @returns {boolean} */ -window.hasAllNaturalLimbs = function(slave) { - return hasBothNaturalLegs(slave) && hasBothNaturalArms(slave); +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 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 + * @returns {number} + */ +window.getRightLegID = function(slave) { + if (slave.amp < 0) { + return (slave.amp * -1) +1; + } + + if (hasRightLeg(slave)) { + return 1; + } else { + return 0; + } }; /** @@ -1000,7 +1102,6 @@ window.idToDescription = function(id) { } }; - /** * Returns count of specified limb type. Uses new limb IDs: * 0: no limb @@ -1020,7 +1121,7 @@ window.idToDescription = function(id) { * * 103-105 mean the sum of 3-5 and 6 respectfully. * - * No ID means all limbs + * No ID means all limbs = 101 * * @param {App.Entity.SlaveState} slave * @param {number} [id] @@ -1073,15 +1174,14 @@ window.getLimbCount = function(slave, id = 101) { return n; }; - /** - * Returns count of specified arm type. Uses new limb IDs. + * Returns count of specified leg type. Uses new limb IDs. * * @param {App.Entity.SlaveState} slave * @param {number} id * @returns {number} */ -window.getArmCount = function(slave, id) { +window.getLegCount = function(slave, id) { let oldID = (id - 1) * -1; if (oldID < 0) { @@ -1093,10 +1193,10 @@ window.getArmCount = function(slave, id) { } let n = 0; - if (hasLeftArm(slave)) { + if (hasLeftLeg(slave)) { n++; } - if (hasRightArm(slave)) { + if (hasRightLeg(slave)) { n++; } @@ -1108,13 +1208,13 @@ window.getArmCount = function(slave, id) { }; /** - * Returns count of specified leg type. Uses new limb IDs. + * Returns count of specified arm type. Uses new limb IDs. * * @param {App.Entity.SlaveState} slave * @param {number} id * @returns {number} */ -window.getLegCount = function(slave, id) { +window.getArmCount = function(slave, id) { let oldID = (id - 1) * -1; if (oldID < 0) { @@ -1126,10 +1226,10 @@ window.getLegCount = function(slave, id) { } let n = 0; - if (hasLeftLeg(slave)) { + if (hasLeftArm(slave)) { n++; } - if (hasRightLeg(slave)) { + if (hasRightArm(slave)) { n++; } @@ -1140,119 +1240,6 @@ window.getLegCount = function(slave, id) { return n; }; - -/** - * True if slave has left arm - * - * @param {App.Entity.SlaveState} slave - * @returns {boolean} - */ -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 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 - * @returns {number} - */ -window.getRightLegID = function(slave) { - if (slave.amp < 0) { - return (slave.amp * -1) +1; - } - - if (hasRightLeg(slave)) { - return 1; - } else { - return 0; - } -}; - /** * Returns a string depending on the limbs a slave has. * By default a variation of "arms and legs", but this can be changed via parameters.