From 61c00e52df4e292270281d895bcedbe2d06cf864 Mon Sep 17 00:00:00 2001 From: torbjornhub <13432-torbjornhub@users.noreply.gitgud.io> Date: Sat, 14 Dec 2019 17:42:22 -0800 Subject: [PATCH] Replace DefaultRules.js --- src/js/DefaultRules.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index f0458e3b859..4ca41ecf7c4 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -18,10 +18,9 @@ window.DefaultRules = (function() { ({he, him, his} = getPronouns(slave)); const slaveReadOnly = createReadonlyProxy(slave); const {rule, ruleIds} = runWithReadonlyProxy(()=>ProcessSlaveRules(slaveReadOnly)); - if (ruleIds.length === 0) { return r; } // no rules apply slave.currentRules = ruleIds; + if (ruleIds.length === 0) { return r; } // no rules apply - AssignJobToSlave(slave, rule); if (slave.fuckdoll === 0) { ProcessClothing(slave, rule); @@ -88,8 +87,7 @@ window.DefaultRules = (function() { /** @type {App.RA.Rule[]} */ const rules = V.defaultRules.filter((x) => ruleAppliesP(x.condition, slave)); const ruleIds = [], assignments = []; - for(const rule of rules) - { + for(const rule of rules) { ruleIds.push(rule.ID); assignments.push(ProcessAssignments(slave, Object.assign({}, rule.set))); } @@ -1336,12 +1334,12 @@ window.DefaultRules = (function() { } break; - case "psychostimulants": + case "psychostimulants": { let origIntel = V.genePool.find(s => s.ID === slave.ID).intelligence; if (!((slave.intelligence < 100) && (slave.intelligence < origIntel + 15))) { flag = false; } - break; + } break; case "breast injections": if (slave.boobs >= 48000) { @@ -1522,7 +1520,8 @@ window.DefaultRules = (function() { * @param {App.Entity.SlaveState} slave * @param {App.RA.RuleSetters} rule */ - function ProcessPit(slave,rule){ + + function ProcessPit(slave,rule){ if (rule.pitRules !== undefined && rule.pitRules !== null){ if (V.pit > 0){ if (rule.pitRules===0){ @@ -1535,7 +1534,7 @@ window.DefaultRules = (function() { } } } - + function ProcessDiet(slave, rule) { // Diet Setting if ((rule.diet !== undefined && rule.diet !== null) || rule.weight !== null) { @@ -2920,19 +2919,19 @@ window.DefaultRules = (function() { * @param {App.RA.RuleSetters} rule */ function ProcessLabel(slave, rule) { - //mass removal of old tags, variant from '*' mask. + // mass removal of old tags, variant from '*' mask. if (rule.removeLabel !== null && rule.removeLabel !== '' && rule.removeLabel === '*') { slave.custom.label = slave.custom.label.replace(/(?:\[.+\])+/, ""); r += `<br>All ${slave.slaveName}'s tags is removed.`; } - //mass removal of old tags, variant from GUI swith. + // mass removal of old tags, variant from GUI swith. if (rule.labelTagsClear === true) { slave.custom.label = slave.custom.label.replace(/(?:\[.+\])+/, ""); r += `<br>All ${slave.slaveName}'s tags is removed.`; } - //removing tags selected for removal. + // removing tags selected for removal. let tags = [], i; if (rule.removeLabel != null && rule.removeLabel !== '') { tags = rule.removeLabel.split("|"); @@ -2945,7 +2944,7 @@ window.DefaultRules = (function() { } } - //finally adding new tags. + // finally adding new tags. tags = []; if (rule.label != null && rule.label !== '') { tags = rule.label.split("|"); @@ -2962,14 +2961,13 @@ window.DefaultRules = (function() { const rxCheckEqual = /[^!=<>]=[^=<>]/gi; const compileCheck = function(code) { try { - //TODO: This should use a cached Function, which should be the same as below. + // TODO: This should use a cached Function, which should be the same as below. new Function(`return ${code}`); - } - catch(e) { + } catch(e) { return false; } return true; - } + }; window.RuleHasError = (rule) => rule.condition.function === "custom" &&(rule.condition.data.match(rxCheckEqual) || !compileCheck(rule.condition.data)); -- GitLab