From 40aafc7ac12e81c859a3d388eec38243ad016965 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Tue, 30 Jun 2020 14:59:28 -0700 Subject: [PATCH] Policy fixes --- js/003-data/policiesData.js | 58 +++++++++++++++------------- src/interaction/policies/policies.js | 11 +++--- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/js/003-data/policiesData.js b/js/003-data/policiesData.js index 8519cf69a3d..b578029b88d 100644 --- a/js/003-data/policiesData.js +++ b/js/003-data/policiesData.js @@ -1,25 +1,29 @@ +/** + * @typedef {object} PolicySelector + * @property {string} title The title of the policy as displayed in the UI, "Health Inspection SMR" + * @property {string} [titleClass] The class to apply to the title: "lime" + * @property {string} [activatedTitle] The title of the policy if the policy is active. Param "title" is used as a fallback. + * @property {string} text Text that describes the policy in detail. No initial cap, ends with punctuation. + * @property {string} [activatedText] Text that describes an active policy in detail. Uses param "text" as a fallback. + * @property {function(void):boolean} [requirements] Function to determine if a policy can be enabled. + * @property {function(void):void} [onImplementation] Beyond applying the policy itself and billing the player, are there other values to change? This allows a shortstack FS policy to revoke some generic tall policies, for example. + * @property {function(void):void} [onRepeal] same as onImplementation, but fires when a policy is repealed. + * @property {number|string} [enable] Value to enable a policy. Defaults to 1 if not defined. + * @property {object} [hide] Object controlling special hide settings that can hide parts of the policy if needed. + * @property {number} [hide.button] Hides the appeal/repeal button if 1 + * @property {number} [hide.ifActivated] Hides the entire policy if the policy is applied. 1 to enable. + * @property {string} [note] Note that appears at the end of the policy display in italics to present further information. Starts with cap, no punctuation at end. + * @property {string} [activatedNote] Note that appears if policy is activated. Please note that unlike the other "activated" categories, "note" is only displayed on deactivated policies. There is no fallback. + */ +/** + * @typedef {Object<string, PolicySelector[]>} PolicySelectorGroup + * Key names represent a piece of the variable. "policies.SMR.basicSMR" will be checked against "V.policies.SMR.basicSMR". "arcologies[0].FSEgyptianRevivalistIncestPolicy" will be checked against "V.arcologies[0].FSEgyptianRevivalistIncestPolicy". + */ + +/** @type {Object<string, PolicySelectorGroup>} */ App.Data.Policies.Selection = { SMR: { - /** - * @param {string} // The policy value as a piece of the variable. "policies.SMR.basicSMR" will be checked against "V.policies.SMR.basicSMR". "arcologies[0].FSEgyptianRevivalistIncestPolicy" will be checked against "V.arcologies[0].FSEgyptianRevivalistIncestPolicy". - */ "policies.SMR.basicSMR": [ - /** - * @param {string} title The title of the policy as displayed in the UI, "Health Inspection SMR" - * @param {string} [titleClass] The class to apply to the title: "lime" - * @param {string} [activatedTitle] The title of the policy if the policy is active. Param "title" is used as a fallback. - * @param {string} text Text that describes the policy in detail. No initial cap, ends with punctuation. - * @param {string} [activatedText] Text that describes an active policy in detail. Uses param "text" as a fallback. - * @param {Function} [requirements] Function to determine if a policy can be enabled. Returns boolean. - * @param {Function} [onImplementation] Beyond applying the policy itself and billing the player, are there other values to change? This allows a shortstack FS policy to revoke some generic tall policies, for example. No return expected. - * @param {Function} [onRepeal] same as onImplementation, but fires when a policy is repealed. - * @param {number|string} [enable] Value to enable a policy. Defaults to 1 if not defined. - * @param {object} [hide] Object controlling special hide settings that can hide parts of the policy if needed. - * @param {number} [hide.button] Hides the appeal/repeal button if 1 - * @param {number} [hide.ifActivated] Hides the entire policy if the policy is applied. 1 to enable. - * @param {string} [note] Note that appears at the end of the policy display in italics to present further information. Starts with cap, no punctuation at end. - * @param {string} [activatedNote] Note that appears if policy is activated. Please note that unlike the other "activated" categories, "note" is only displayed on deactivated policies. There is no fallback. - */ { title: "Basic SMR", text: "the slave market is subject to very basic regulations designed to offer buyers some confidence.", @@ -678,7 +682,7 @@ App.Data.Policies.Selection = { ); return el; }, - get activatedText() { return `you have set your arcology's standard retirement age for sex slaves at ${retirementAge}.`; }, + get activatedText() { return `you have set your arcology's standard retirement age for sex slaves at ${V.retirementAge}.`; }, onRepeal: function() { V.retirementAge = 45; } } @@ -705,7 +709,7 @@ App.Data.Policies.Selection = { ); return el; }, - get activatedText() { return `you have set your arcology's standard retirement age for sex slaves at ${retirementAge}.`; }, + get activatedText() { return `you have set your arcology's standard retirement age for sex slaves at ${V.retirementAge}.`; }, onRepeal: function() { V.retirementAge = 45; } } ], @@ -721,7 +725,7 @@ App.Data.Policies.Selection = { return text; }, get activatedText() { - `once reaching mandatory retirement age, slaves are converted for full-time milk`; + let text = `once reaching mandatory retirement age, slaves are converted for full-time milk`; if (V.seeDicks === 1) { text += `, vaginal secretion, and semen`; } @@ -1386,6 +1390,7 @@ App.Data.Policies.Selection = { title: "Lifting SMR", titleClass: "lime", get text() { + let t = ''; t = `in order to be sold in the arcology, slaves will have to be `; if (V.arcologies[0].FSPhysicalIdealistLaw) { t += ` toned.`; @@ -1395,6 +1400,7 @@ App.Data.Policies.Selection = { return t; }, get activatedText() { + let t = ''; t = `in order to be sold in the arcology, slaves must be `; if (V.arcologies[0].FSPhysicalIdealistLaw) { t += ` toned.`; @@ -1513,7 +1519,7 @@ App.Data.Policies.Selection = { title: "Chattel Religionist Creed", titleClass: "lime", get text() { - let t = `Chattel Religionism in your arcology will subscribe to the creed established by the ${nicaeaName}, which honors`; + let t = `Chattel Religionism in your arcology will subscribe to the creed established by the ${V.nicaeaName}, which honors`; if (V.nicaeaFocus === "slaves") { t += ` slaves,`; } else { @@ -1544,7 +1550,7 @@ App.Data.Policies.Selection = { return t; }, get activatedText() { - let t = `Chattel Religionism in your arcology subscribes to the creed established by the ${nicaeaName}, which honors`; + let t = `Chattel Religionism in your arcology subscribes to the creed established by the ${V.nicaeaName}, which honors`; if (V.nicaeaFocus === "slaves") { t += ` slaves,`; } else { @@ -1766,7 +1772,7 @@ App.Data.Policies.Selection = { titleClass: "lime", text: "in order to be sold in the arcology, subhumans with dicks will have to have their balls removed to prevent racial pollution.", activatedText: "in order to be sold in the arcology, subhumans with dicks must have their balls removed to prevent racial pollution.", - requirements: function() { if (V.seeDicks !== 0 && arcologies[0].FSSubjugationist >= 40) { return true; } else { return false; } }, + requirements: function() { if (V.seeDicks !== 0 && V.arcologies[0].FSSubjugationist >= 40) { return true; } else { return false; } }, note: `Will help advance racial Subjugation` } ], @@ -1778,7 +1784,7 @@ App.Data.Policies.Selection = { get activatedText() { return `by law, all ${V.arcologies[0].FSSubjugationistRace} subhumans in your arcology are slaves`; }, requirements: function() { if (V.arcologies[0].FSSubjugationist >= 90) { return true; } else { return false; } }, onImplementation: function() { - if (FSSubLawTrigger === 0) { + if (V.FSSubLawTrigger === 0) { V.FSSubLawTrigger = 1; } }, diff --git a/src/interaction/policies/policies.js b/src/interaction/policies/policies.js index 1992f6fb8b0..8aae8af3ed7 100644 --- a/src/interaction/policies/policies.js +++ b/src/interaction/policies/policies.js @@ -118,7 +118,7 @@ globalThis.policy = function(category) { return jQuery(`#${category}`).empty().append(frag); /** * @param {string} policyVariable - * @returns {node} el + * @returns {Node} el */ function policyElement(policyVariable) { let el = document.createElement("p"); @@ -126,6 +126,7 @@ globalThis.policy = function(category) { let span; let link; const policyValue = _.get(V, policyVariable); + /** @type {PolicySelector[]} */ const policyObject = App.Data.Policies.Selection[category][policyVariable]; if (policyValue === 0) { // apply @@ -217,8 +218,8 @@ globalThis.policy = function(category) { return el; /** - * @param {*} p The data object that describes the policy being considered. - * @returns {node} Link to repeal. + * @param {PolicySelector} p The data object that describes the policy being considered. + * @returns {Node} Link to repeal. */ function repeal(p) { const frag = new DocumentFragment; @@ -250,9 +251,9 @@ globalThis.policy = function(category) { return frag; } /** - * @param {*} p The data object that describes the policy being considered. + * @param {PolicySelector} p The data object that describes the policy being considered. * @param {number|string} enable value to set the policy to in order to switch it on. - * @returns {node} Link to implement. + * @returns {Node} Link to implement. */ function implement(p, enable) { let check = canAfford(); -- GitLab