diff --git a/gorge.js b/gorge.js index 8efdec0..3984394 100644 --- a/gorge.js +++ b/gorge.js @@ -73,11 +73,9 @@ function applyGlobalProdBonus(cost) { for (let effect of effects["prod-all"]) { if (ownedUpgrades[effect.parent]) { - cost = effect.apply(cost); + effect.apply(cost); } } - - return cost; } function calculateProductivity() { @@ -99,44 +97,42 @@ function applyProductivityMultipliers(type, cost) { for (let effect of effects["prod"]) { if (ownedUpgrades[effect.parent] && effect.target == type) { - cost = effect.apply(cost); + effect.apply(cost); } } for (let effect of effects["helper"]) { if (ownedUpgrades[effect.parent] && effect.helped == type) { - cost = effect.apply(cost, belongings[effect.helper].count); + effect.apply(cost, belongings[effect.helper].count); } } - - return cost; } function productivityOf(type) { let baseProd = makeCost(buildings[type].prod); - baseProd = applyProductivityMultipliers(type, baseProd); + applyProductivityMultipliers(type, baseProd); - baseProd = applyGlobalProdBonus(baseProd); + applyGlobalProdBonus(baseProd); - baseProd = scaleCost(baseProd, belongings[type].count); + scaleCost(baseProd, belongings[type].count); return baseProd; } function makeCost(source) { const empty = mapObject(resourceTypes, () => 0); - return deepFreeze({...empty, ...source}); + return {...empty, ...source}; } function addCost(cost1, cost2) { - return deepFreeze(Object.keys(resourceTypes).reduce((o, k) => ({ ...o, [k]: cost1[k] + cost2[k]}), {})); + return Object.keys(resourceTypes).reduce((o, k) => {o[k] += cost2[k]; return o;}, cost1); } function scaleCost(cost, scale) { if (typeof(scale) != "number") console.log(scale) - return deepFreeze(Object.keys(resourceTypes).reduce((o, k) => ({ ...o, [k]: cost[k] * scale}), {})); + return Object.keys(resourceTypes).reduce((o, k) => {o[k] *= scale; return o;}, cost); } function costOfBuilding(type, count = 1) {