diff --git a/js/003-data/policiesData.js b/js/003-data/policiesData.js index 7c6f834959e535136148a377a6a731c164b775ef..31178c68597edb6bc8258699fe06e81bc388e188 100644 --- a/js/003-data/policiesData.js +++ b/js/003-data/policiesData.js @@ -292,14 +292,14 @@ App.Data.Policies.Selection = { text: "you will offer citizen immigrants a generous promotion.", activatedText: "you are offering citizen immigrants a generous promotion", policy: "policies.immmigrationCash", - note: [`Will cost`, `weekly to maintain, and increase the citizen population`] + get note() { return `Will cost ${cashFormat(policies.cost())} weekly to maintain, and increase the citizen population`; } }, { title: "Immigrant Information Brokerage", text: "you will covertly sell information on troubled potential immigrants to your arcology to their old world enemies.", activatedText: "you are covertly selling information on troubled potential immigrants to your arcology.", policy: "policies.immmigrationCash", - note: [`Will produce`, `weekly, and slow growth of the citizen population`] + get note() { return `Will produce ${cashFormat(policies.cost())} weekly, and slow growth of the citizen population`; } } ], [ @@ -324,14 +324,14 @@ App.Data.Policies.Selection = { text: "you will take kickbacks in return for turning a blind eye to enslavement of poor citizens.", activatedText: "you are taking kickbacks in return for turning a blind eye to enslavement of poor citizens.", policy: "policies.enslavementCash", - note: [`Will produce`, `weekly, and reduce the population of citizens`] + get note() { return `Will produce ${cashFormat(policies.cost())} weekly, and reduce the population of citizens`; } }, { title: "Poor Citizen Relief", text: "you will offer limited emergency assistance to poor citizens in danger of being enslaved.", activatedText: "you are offering limited emergency assistance to poor citizens in danger of being enslaved.", policy: "policies.enslavementCash", - note: [`Will cost`, `weekly to maintain, and slow population movement from citizens to slaves`] + get note() { return `Will cost ${cashFormat(policies.cost())} weekly to maintain, and slow population movement from citizens to slaves`; } } ], [ @@ -357,7 +357,7 @@ App.Data.Policies.Selection = { title: "Economic Growth Subsidy", text: "offer promising new businesses generous subsidies, driving arcology prosperity.", policy: "policies.alwaysSubsidizeGrowth", - note: [`Will cost`, `weekly to maintain, and improve arcology prosperity`] + get note() { return `Will cost ${cashFormat(policies.cost())} weekly to maintain, and improve arcology prosperity`; } } ], [ @@ -365,7 +365,7 @@ App.Data.Policies.Selection = { title: "Self-Promotion Program", text: "communicate your good side to the public via subtle paid advertising. This will also ease any potential rumors.", policy: "policies.alwaysSubsidizeRep", - note: [`Will cost`, `weekly to maintain, and improve your reputation`] + get note() { return `Will cost ${cashFormat(policies.cost())} weekly to maintain, and improve your reputation`; } } ], [ @@ -374,14 +374,14 @@ App.Data.Policies.Selection = { text: "you will do your best to help your citizens, even when it disadvantages you personally.", activatedText: "you are doing your best to help your citizens, even when it disadvantages you personally.", policy: "policies.cashForRep", - note: [`Will cost`, ` weekly, and improve your reputation`] + get note() { return `Will cost ${cashFormat(policies.cost())} weekly, and improve your reputation`; } }, { title: "Business Selfishness", text: "you will leverage your position as arcology owner for money, even when it disadvantages citizens.", activatedText: "you are leveraging your position as arcology owner for money, even when it disadvantages citizens.", policy: "policies.cashForRep", - note: [`Will produce`, `weekly, and cost some reputation`] + get note() { return `Will produce ${cashFormat(policies.cost())} weekly, and cost some reputation`; } }, ], [ @@ -399,8 +399,7 @@ App.Data.Policies.Selection = { text: "positive rumors will be spread throughout the arcology regarding you.", activatedText: "positive rumors are being spread about you.", policy: "policies.goodImageCampaign", - note: [`Will cost`, `weekly to maintain, and lessen any potential rumors about you while giving a small boost to your reputation`], - activatedNote: `` + get note() { return `Will cost ${cashFormat(policies.cost())} weekly to maintain, and lessen any potential rumors about you while giving a small boost to your reputation`; } } ], [ @@ -409,17 +408,29 @@ App.Data.Policies.Selection = { text: "you will host regular parties for prominent citizens, an expected social duty of an arcology owner.", activatedText: "you are hosting regular parties for prominent citizens, an expected social duty of an arcology owner.", policy: "policies.regularParties", - note: [`start entertainments`, ``], - activatedNote: [`activated entertainments`, ``] + get note() { + if (V.rep > 18000) { + return `Will damage your reputation`; + } else { + return ``; + } + }, + get activatedNote() { + let text = `Will cost weekly`; + if (V.rep > 18000) { + text += `, and prevent damage to your reputation`; + } + return text; + } } ], [ { title: "Public Personal Assistant", - text: {get text() { return `${V.assistant.name} is part of your public image.`; }}, - activatedText: {get activatedText() { return `${V.assistant.name} is part of your public image.`; }}, + get text() { return `${V.assistant.name} is part of your public image.`; }, + get activatedText() { return `${V.assistant.name} is part of your public image.`; }, policy: "policies.publicPA", - note: {get note() { return `May improve cultural development if ${V.assistant.name}'s appearance is fashionable`; }} + get note() { return `May improve cultural development if ${V.assistant.name}'s appearance is fashionable`; } } ], ] diff --git a/src/interaction/policies/policies.js b/src/interaction/policies/policies.js index a29ff30a283d17739e305559af432378cfd8997b..d230ae989d9f9bbc7c711b784f082be4cf33668c 100644 --- a/src/interaction/policies/policies.js +++ b/src/interaction/policies/policies.js @@ -202,13 +202,13 @@ globalThis.policy = function(category) { return el; function testArray(p) { - if (!p.hasOwnProperty("title") || (typeof p.title !== "string") || p.title === "") { + if (!p.hasOwnProperty("title") || p.title === "") { throw "Title not set up properly for a policy"; } - if (!p.hasOwnProperty("text") || (typeof p.text !== "string") || p.text === "") { + if (!p.hasOwnProperty("text") || p.text === "") { throw `Description not set up properly for policy ${p.text}`; } - if (!p.hasOwnProperty("policy") || (typeof p.policy !== "string") || p.policy === "") { + if (!p.hasOwnProperty("policy") || p.policy === "") { throw `Variable not set up properly for policy ${p.text}`; } } @@ -231,28 +231,8 @@ globalThis.policy = function(category) { link.style.color = "red"; } div.append(link); - if (p.hasOwnProperty("note")) { - if (typeof p.activatedNote === "string") { - div.append(App.UI.DOM.makeElement("div", p.activatedNote, ["note", "indent"])); - } else if (Array.isArray(p.activatedNote)) { - let text = ``; - switch (p.activatedNote[0]) { - case "start entertainments": { - if (V.rep > 18000) { - text = `Will damage your reputation`; - } - break; - } - case "activated entertainments": { - text = `Will cost weekly`; - if (V.rep > 18000) { - text += `, and prevent damage to your reputation`; - } - break; - } - } - div.append(App.UI.DOM.makeElement("div", text, ["note", "indent"])); - } + if (p.hasOwnProperty("activatedNote")) { + div.append(App.UI.DOM.makeElement("div", p.activatedNote, ["note", "indent"])); } el.append(div); } @@ -301,12 +281,6 @@ globalThis.policy = function(category) { } break; } - case "Will cost": - case "Will produce": - { - text = p.note[0] + " " + cashFormat(policies.cost()) + " "; - break; - } } text += p.note[1]; div.append(App.UI.DOM.makeElement("div", text, ["note", "indent"]));