diff --git a/src/js/rulesAssistant.js b/src/js/rulesAssistant.js index 9a3d5fc2088be7cdb1593a848d65e360201436e1..bc36817d16043a5a5d7a614f7aba2836366f1d7d 100644 --- a/src/js/rulesAssistant.js +++ b/src/js/rulesAssistant.js @@ -1,31 +1,57 @@ -/** @param {App.Entity.SlaveState} slave */ +/** + * @param {App.Entity.SlaveState} slave + * @param {Object} rules + * @returns {boolean} +*/ window.hasSurgeryRule = function (slave, rules) { return rules.some( rule => ruleApplied(slave, rule) && rule.set.autoSurgery > 0); }; -/** @param {App.Entity.SlaveState} slave */ +/** + * @param {App.Entity.SlaveState} slave + * @param {Object} rules + * @param {string} what + * @returns {boolean} +*/ window.hasRuleFor = function(slave, rules, what) { return rules.some( rule => ruleApplied(slave, rule) && rule[what] !== "no default setting"); }; -/** @param {App.Entity.SlaveState} slave */ +/** + * @param {App.Entity.SlaveState} slave + * @param {Object} rules + * @returns {boolean} +*/ window.hasHColorRule = function(slave, rules) { return hasRuleFor(slave, rules, "hColor"); }; -/** @param {App.Entity.SlaveState} slave */ +/** + * @param {App.Entity.SlaveState} slave + * @param {Object} rules + * @returns {boolean} + * */ window.hasHStyleRule = function(slave, rules) { return hasRuleFor(slave, rules, "hStyle"); }; -/** @param {App.Entity.SlaveState} slave */ +/** + * @param {App.Entity.SlaveState} slave + * @param {Object} rules + * @returns {boolean} + * */ window.hasEyeColorRule = function(slave, rules) { return hasRuleFor(slave, rules, "eyeColor"); }; -/** @param {App.Entity.SlaveState} slave */ +/** + * return if a rule is applied on a slave + * @param {App.Entity.SlaveState} slave + * @param {Object} rules + * @returns {boolean} +*/ window.lastPregRule = function(slave, rules) { return rules.some(rule => ruleApplied(slave, rule) && rule.set.preg === -1); @@ -49,14 +75,22 @@ window.mergeRules = function mergeRules(rules) { return combinedRule; }; -// return if a rule is applied on a slave -/** @param {App.Entity.SlaveState} slave */ +/** + * return if a rule is applied on a slave + * @param {App.Entity.SlaveState} slave + * @param {Object} rule + * @returns {string} +*/ window.ruleApplied = function(slave, rule) { return slave.currentRules.includes(rule.ID); }; -// remove slave from the facility described by the rule -/** @param {App.Entity.SlaveState} slave */ +/** + * remove slave from the facility described by the rule + * @param {App.Entity.SlaveState} slave + * @param {Object} rule + * @returns {string} +*/ window.RAFacilityRemove = function RAFacilityRemove(slave, rule) { const V = State.variables; let r = ""; @@ -155,8 +189,11 @@ window.RAFacilityRemove = function RAFacilityRemove(slave, rule) { } }; -// return whether the rule applies to the slave -/** @param {App.Entity.SlaveState} slave */ +/** + * return whether the rule applies to the slave + * @param {Object} cond + * @param {App.Entity.SlaveState} slave + * @returns {boolean} flag */ window.ruleAppliesP = function ruleAppliesP(cond, slave) { let flag;