diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt index ee4f7e5797d66dbfbd5d95120b2df0f6f5201d8c..4e5c393eac6d5c9c57604534f8f3672e72951c41 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 1a1d5e184ed858f8124cc6e68090068b6ae98885..d54156cd24c37d403fb6a4cfa4b5d8636352ca0f 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.