From da5900a025433ee16514dfb78d438444d4e98522 Mon Sep 17 00:00:00 2001 From: lowercase-donkey <lowercasedonkey@gmail.com> Date: Sat, 19 Jan 2019 12:57:04 -0500 Subject: [PATCH] cashX no long breaks costs just because it can't categorize them --- devNotes/twine JS.txt | 54 +++++++++++++++++++++---------------------- src/js/economyJS.tw | 50 +++++++++++++++++++-------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt index ee4f7e5797d..4e5c393eac6 100644 --- a/devNotes/twine JS.txt +++ b/devNotes/twine JS.txt @@ -3116,48 +3116,48 @@ window.cashX = function(cost, what, who) { V.lastWeeksErrors += `NaN: "${cost}" at ${what}, `; } else { - + //INCOME if(cost > 0) { - if (typeof V.lastWeeksCashIncome[what] !== 'undefined') { + + //Spend the money + V.cash += cost; - //record the action + //record the action + if (typeof V.lastWeeksCashIncome[what] !== 'undefined') { V.lastWeeksCashIncome[what] += cost; - - //record the slave, if available - if (typeof who !== 'undefined'){ - who.lastWeeksCashIncome += cost; - who.lifetimeCashIncome += cost; - } - - //Spend the money - V.cash += cost; } else { V.lastWeeksErrors += `Unknown place "${what}",`; } + + //record the slave, if available + if (typeof who !== 'undefined'){ + who.lastWeeksCashIncome += cost; + who.lifetimeCashIncome += cost; + } } - + //EXPENSES else if(cost < 0) { - if (typeof V.lastWeeksCashExpenses[what] !== 'undefined') { - - //record the action - V.lastWeeksCashExpenses[what] += cost; - //record the slave, if available - if (typeof who !== 'undefined'){ - if (what === "slaveTransfer"){ - who.slaveCost = cost; - } else { - who.lifetimeCashExpenses += cost; - } - } + //Spend the money + V.cash += cost; - //Spend the money - V.cash += cost; + //record the action + if (typeof V.lastWeeksCashExpenses[what] !== 'undefined') { + V.lastWeeksCashExpenses[what] += cost; } else { V.lastWeeksErrors += `Unknown place "${what}",`; } + + //record the slave, if available + if (typeof who !== 'undefined'){ + if (what === "slaveTransfer"){ + who.slaveCost = cost; + } else { + who.lifetimeCashExpenses += cost; + } + } } else { //somebody probably tried to pass a 0, ignore it. New slaves will default to "slaveCost: 0", no need to call a costX for it. diff --git a/src/js/economyJS.tw b/src/js/economyJS.tw index 1a1d5e184ed..d54156cd24c 100644 --- a/src/js/economyJS.tw +++ b/src/js/economyJS.tw @@ -975,45 +975,45 @@ window.cashX = function(cost, what, who) { //INCOME if(cost > 0) { + + //Spend the money + V.cash += cost; + + //record the action if (typeof V.lastWeeksCashIncome[what] !== 'undefined') { - - //record the action V.lastWeeksCashIncome[what] += cost; - - //record the slave, if available - if (typeof who !== 'undefined'){ - who.lastWeeksCashIncome += cost; - who.lifetimeCashIncome += cost; - } - - //Spend the money - V.cash += cost; } else { V.lastWeeksErrors += `Unknown place "${what}",`; } + + //record the slave, if available + if (typeof who !== 'undefined'){ + who.lastWeeksCashIncome += cost; + who.lifetimeCashIncome += cost; + } } //EXPENSES else if(cost < 0) { + + //Spend the money + V.cash += cost; + + //record the action if (typeof V.lastWeeksCashExpenses[what] !== 'undefined') { - - //record the action V.lastWeeksCashExpenses[what] += cost; - - //record the slave, if available - if (typeof who !== 'undefined'){ - if (what === "slaveTransfer"){ - who.slaveCost = cost; - } else { - who.lifetimeCashExpenses += cost; - } - } - - //Spend the money - V.cash += cost; } else { V.lastWeeksErrors += `Unknown place "${what}",`; } + + //record the slave, if available + if (typeof who !== 'undefined'){ + if (what === "slaveTransfer"){ + who.slaveCost = cost; + } else { + who.lifetimeCashExpenses += cost; + } + } } else { //somebody probably tried to pass a 0, ignore it. New slaves will default to "slaveCost: 0", no need to call a costX for it. -- GitLab