diff --git a/devTools/types/FC/gameState.d.ts b/devTools/types/FC/gameState.d.ts index 1615f94cbd8d124d2a7c5d7fe240fff567e91d51..7a58b556a3bd82288278990c3e6c6df34a715aea 100644 --- a/devTools/types/FC/gameState.d.ts +++ b/devTools/types/FC/gameState.d.ts @@ -131,7 +131,7 @@ declare namespace FC { brothelSlavesGettingHelp?: number; clubSlavesGettingHelp?: number; - lastWeeksRepErrors?: string; + lastWeeksRepErrors: Array<string>; lastWeeksCashErrors: Array<string>; arcadeDemandDegResult?: 1 | 2 | 3 | 4 | 5; diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index 4a3bb1a7c1e111de02284b30010034ee4bf76aaa..213c0aecb50c06542b43dc4e828f03ddcc65acdf 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -436,6 +436,7 @@ App.Data.resetOnNGPlus = { lastWeeksRepExpenses: {}, showAllEntries: {costsBudget: 0, repBudget: 0}, lastWeeksCashErrors: [], + lastWeeksRepErrors: [], localEcon: 0, econRate: 0, diff --git a/src/005-passages/budgetPassages.js b/src/005-passages/budgetPassages.js index 09ea968153bcecc581274d826e77e7ea39cf8ce7..d595a4fab90b7b3ba8dbfc7f40bd061e17514690 100644 --- a/src/005-passages/budgetPassages.js +++ b/src/005-passages/budgetPassages.js @@ -5,3 +5,11 @@ new App.DomPassage("Costs Budget", return App.Budget.costs(); }, ["jump-to-safe", "jump-from-safe"] ); + +new App.DomPassage("Rep Budget", + () => { + V.nextButton = "Back"; + V.nextLink = "Main"; + return App.Budget.rep(); + }, ["jump-to-safe", "jump-from-safe"] +); diff --git a/src/budget/repBudget.js b/src/budget/repBudget.js new file mode 100644 index 0000000000000000000000000000000000000000..c46216dbd4f686cc1e1aecd4249661a9d966e285 --- /dev/null +++ b/src/budget/repBudget.js @@ -0,0 +1,57 @@ +/** + * Reputation budget passage + * @returns {DocumentFragment} + */ +App.Budget.rep = function() { + const f = new DocumentFragment(); + + f.append(intro()); + f.append(settings()); + // Table of Totals + if (!V.lastWeeksRepIncome) { + App.UI.DOM.appendNewElement("p", f, "Reputation data currently unavailable."); + } else { + App.UI.DOM.appendNewElement("p", f, App.Budget.table("rep")); + } + + errors(f); + return f; + + /** + * @returns {HTMLParagraphElement} + */ + function intro() { + return App.UI.DOM.makeElement("p", `Reputation is a difficult thing to quantify, ${properTitle()}. Here you see an overview of topics that interest people in the arcology, and in turn, reflect on your own reputation. The more symbols you see in a category, the more impact that category is having on your reputation lately.`, "scene-intro"); + } + + /** + * @returns {HTMLParagraphElement} + */ + function settings() { + const p = document.createElement("p"); + App.UI.DOM.appendNewElement("div", p, "Your weekly reputation changes are as follows:", "detail"); + + let _options = new App.UI.OptionsGroup(); + _options.addOption("", "repBudget", V.showAllEntries) + .addValue("Normal", 0).on().addValue("Show Empty Entries", 1); + p.append(_options.render()); + + return p; + } + + /** + * @param {DocumentFragment} container + */ + function errors(container) { + if (V.lastWeeksRepErrors.length > 0) { + const p = document.createElement("p"); + p.append(App.UI.DOM.passageLink("Reset", "Rep Budget", + () => { V.lastWeeksRepErrors = []; })); + App.UI.DOM.appendNewElement("div", p, "Errors:", "error"); + for (const error of V.lastWeeksRepErrors) { + App.UI.DOM.appendNewElement("div", p, error, "error"); + } + container.append(p); + } + } +}; diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js index 0eb51c3bffdd8d64c88c130617e138a466338c9f..fe01a262591927a83cc3c745e71640c788ec7883 100644 --- a/src/data/backwardsCompatibility/backwardsCompatibility.js +++ b/src/data/backwardsCompatibility/backwardsCompatibility.js @@ -1318,6 +1318,13 @@ App.Update.globalVariables = function(node) { V.lastWeeksCashErrors = [V.lastWeeksCashErrors]; } } + if (typeof V.lastWeeksRepErrors === "string") { + if (V.lastWeeksRepErrors === "Errors: ") { + V.lastWeeksRepErrors = []; + } else { + V.lastWeeksRepErrors = [V.lastWeeksRepErrors]; + } + } node.append(`Done!`); }; diff --git a/src/js/economyJS.js b/src/js/economyJS.js index 70ad99e44a1fb176baa9fe52bb2ff33bb290a6cf..f9f482ea26f6f1f9acd590a2ad819fc5b826e663 100644 --- a/src/js/economyJS.js +++ b/src/js/economyJS.js @@ -2287,7 +2287,7 @@ globalThis.cashX = function(cost, what, who) { */ globalThis.repX = function(rep, what, who) { if (!Number.isFinite(rep)) { - V.lastWeeksRepErrors += `Expected a finite number for ${what}, but got ${rep}<br>`; + V.lastWeeksRepErrors.push(`Expected a finite number for ${what}, but got ${rep}`); return 0; } @@ -2311,14 +2311,14 @@ globalThis.repX = function(rep, what, who) { rep = Math.round(Math.pow(1000 * rep + Math.pow(V.rep, 2), 0.5) - V.rep); V.lastWeeksRepIncome[what] += rep; } else { - V.lastWeeksRepErrors += `Unknown place "${what}" gained you ${rep}<br>`; + V.lastWeeksRepErrors.push(`Unknown place "${what}" gained you ${rep}`); } } else if (rep < 0) { // EXPENSES // record the action if (typeof V.lastWeeksRepExpenses[what] !== 'undefined') { V.lastWeeksRepExpenses[what] += rep; } else { - V.lastWeeksRepErrors += `Unknown place "${what}" cost you ${rep}<br>`; + V.lastWeeksRepErrors.push(`Unknown place "${what}" cost you ${rep}`); } // record the slave, if available @@ -2557,5 +2557,5 @@ globalThis.setupLastWeeksCash = function() { globalThis.setupLastWeeksRep = function() { V.lastWeeksRepIncome = new App.Data.Records.LastWeeksRep(); V.lastWeeksRepExpenses = new App.Data.Records.LastWeeksRep(); - V.lastWeeksRepErrors = "Errors: "; + V.lastWeeksRepErrors = []; }; diff --git a/src/uncategorized/repBudget.tw b/src/uncategorized/repBudget.tw deleted file mode 100644 index 40aa3cde368cd4d14085840c2cae647bec0a6ebe..0000000000000000000000000000000000000000 --- a/src/uncategorized/repBudget.tw +++ /dev/null @@ -1,41 +0,0 @@ -:: Rep Budget [nobr jump-to-safe jump-from-safe] - -<<set $nextButton = "Back to Main", $nextLink = "Main", _arcologyCosts = 0>> - -<<set $lastWeeksRepIncome.Total = 0>> -<<set $lastWeeksRepExpenses.Total = 0>> -<<set $lastWeeksRepIncome.Total = hashSum($lastWeeksRepIncome)>> -<<set $lastWeeksRepExpenses.Total = hashSum($lastWeeksRepExpenses)>> - -<<if ndef $showAllEntries>> - <<set $showAllEntries = {costsBudget: 0, repBudget: 0}>> -<</if>> - -<br> -//Reputation is a difficult thing to quantify, <<= properTitle()>>. Here you see an overview of topics that interest people in the arcology, and in turn, reflect on your own reputation. The more symbols you see in a category, the more impact that category is having on your reputation lately.// - -<br style="clear:both"><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>> -<br> -//Your weekly reputation changes are as follows:// -<<set _options = new App.UI.OptionsGroup()>> -<<run _options.addOption("", "repBudget", $showAllEntries) -.addValue("Normal", 0).on().addValue("Show Empty Entries", 1)>> -<<includeDOM _options.render()>> - -/* Table of Totals */ -<<if ndef $lastWeeksRepIncome>> - Financial data currently unavailable. -<<else>> - <<includeDOM App.Budget.table("rep")>> -<</if>> - -<<if ndef $lastWeeksRepErrors>> - <<set $lastWeeksRepErrors = "Errors: ">> -<</if>> - -<<if $lastWeeksRepErrors !== "Errors: ">> - <<link "Reset">> - <<set $lastWeeksRepErrors = "Errors: ">> - <</link>><br> - @@.red;<<print $lastWeeksRepErrors>>@@ -<</if>>