From 3d04a7f11098e3aba629730637767c5b0a6116eb Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Sat, 1 May 2021 23:47:50 -0400 Subject: [PATCH] cleanup --- src/interaction/policies/policies.js | 31 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/interaction/policies/policies.js b/src/interaction/policies/policies.js index 239ab96d161..226468abe02 100644 --- a/src/interaction/policies/policies.js +++ b/src/interaction/policies/policies.js @@ -25,22 +25,21 @@ globalThis.policies = (function() { * @returns {Array} */ globalThis.policy = function(category) { - const policyArray = []; - for (let policyVariable in App.Data.Policies.Selection[category]) { - policyElement(policyVariable); + const validPolicies = []; + for (let policyString in App.Data.Policies.Selection[category]) { + policyElement(policyString); } - return policyArray; + return validPolicies; - /** @param {string} policyVariable */ - function policyElement(policyVariable) { - const policyValue = _.get(V, policyVariable); + /** @param {string} policyString */ + function policyElement(policyString) { + const policyValue = _.get(V, policyString); /** @type {PolicySelector[]} */ - const policies = App.Data.Policies.Selection[category][policyVariable]; + const policies = App.Data.Policies.Selection[category][policyString]; if (policyValue === 0) { // apply - for (let i = 0; i < policies.length; i++) { + for (const p of policies) { const el = document.createElement("p"); - const p = policies[i]; const enable = p.enable || 1; if (p.hasOwnProperty("requirements") && p.requirements === false) { continue; @@ -60,7 +59,7 @@ globalThis.policy = function(category) { if (!(p.hasOwnProperty("hide") && p.hide.button === 1)) { el.append(` `, implement(p, enable)); } - policyArray.push(el); + validPolicies.push(el); } } else if (typeof policyValue === "string" || typeof policyValue === "number") { const el = document.createElement("p"); @@ -79,9 +78,9 @@ globalThis.policy = function(category) { // link el.append(` `, repeal(p)); - policyArray.push(el); + validPolicies.push(el); } else { - throw `V.${policyVariable} not initialized properly, "${policyValue}"`; + throw `V.${policyString} not initialized properly, "${policyValue}"`; } /** @@ -98,7 +97,7 @@ globalThis.policy = function(category) { "Repeal", () => { if (V.rep >= 1000) { - _.set(V, policyVariable, 0); + _.set(V, policyString, 0); applyCost(); if (p.hasOwnProperty("onRepeal")) { p.onRepeal(); @@ -135,7 +134,7 @@ globalThis.policy = function(category) { "Implement", () => { if (V.rep >= 1000) { - _.set(V, policyVariable, enable); + _.set(V, policyString, enable); applyCost(); if (p.hasOwnProperty("onImplementation")) { p.onImplementation(); @@ -154,7 +153,7 @@ globalThis.policy = function(category) { linkArray.push(App.UI.DOM.link( "Cheat apply", () => { - _.set(V, policyVariable, enable); + _.set(V, policyString, enable); if (p.hasOwnProperty("onImplementation")) { p.onImplementation(); } -- GitLab