|
|
|
@@ -116,27 +116,26 @@ function productivityMultiplierOf(type) { |
|
|
|
function productivityOf(type) { |
|
|
|
let baseProd = makeCost(buildings[type].prod); |
|
|
|
|
|
|
|
baseProd.food *= productivityMultiplierOf(type); |
|
|
|
baseProd = scaleCost(baseProd, productivityMultiplierOf(type)); |
|
|
|
|
|
|
|
baseProd.food *= getGlobalProdBonus(); |
|
|
|
baseProd = scaleCost(baseProd, productivityMultiplierOf(type)); |
|
|
|
|
|
|
|
baseProd.food *= belongings[type].count; |
|
|
|
baseProd = scaleCost(baseProd, belongings[type].count); |
|
|
|
|
|
|
|
return baseProd; |
|
|
|
} |
|
|
|
|
|
|
|
function makeCost(source) { |
|
|
|
const empty = mapObject(resourceTypes, () => 0); |
|
|
|
Object.preventExtensions(empty); |
|
|
|
return {...empty, ...source}; |
|
|
|
return deepFreeze({...empty, ...source}); |
|
|
|
} |
|
|
|
|
|
|
|
function addCost(cost1, cost2) { |
|
|
|
return Object.keys(resourceTypes).reduce((o, k) => ({ ...o, [k]: cost1[k] + cost2[k]}), {}); |
|
|
|
return deepFreeze(Object.keys(resourceTypes).reduce((o, k) => ({ ...o, [k]: cost1[k] + cost2[k]}), {})); |
|
|
|
} |
|
|
|
|
|
|
|
function scaleCost(cost, scale) { |
|
|
|
return Object.keys(resourceTypes).reduce((o, k) => ({ ...o, [k]: cost[k] * scale}), {}); |
|
|
|
return deepFreeze(Object.keys(resourceTypes).reduce((o, k) => ({ ...o, [k]: cost[k] * scale}), {})); |
|
|
|
} |
|
|
|
|
|
|
|
function costOfBuilding(type, count = 1) { |
|
|
|
@@ -144,7 +143,7 @@ function costOfBuilding(type, count = 1) { |
|
|
|
|
|
|
|
while (count > 0) { |
|
|
|
let baseCost = makeCost(buildings[type].cost); |
|
|
|
baseCost.food *= Math.pow(1.15, belongings[type].count + count - 1); |
|
|
|
baseCost = scaleCost(baseCost, Math.pow(1.15, belongings[type].count + count - 1)); |
|
|
|
total = addCost(total, baseCost); |
|
|
|
count--; |
|
|
|
} |
|
|
|
|