Files
Battle-for-Tismo/shared/data/economy.js
T

36 lines
1.0 KiB
JavaScript

// National economy constants and the pure formulas the server and the browser
// both use to derive production, training time, budget income and population
// growth.
export const ECONOMY = {
baseGdpPerCapita: 10_000,
basePopulation: 100_000,
cityTileGdpMultiplier: 2.0,
capitalTileGdpMultiplier: 2.5,
citySurroundingGdpBonus: 0.3,
gdpPerProductionPoint: 100_000,
budgetGdpRate: 0.001,
startingBudget: 1_000_000_000,
basePopulationGrowthRate: 0.005,
productionCapacity(gdp) {
if (this.gdpPerProductionPoint <= 0) return 0;
return gdp / this.gdpPerProductionPoint;
},
trainingHours(gdp, cost) {
const capacity = this.productionCapacity(gdp);
if (capacity <= 0) return 0;
return cost / capacity;
},
budgetIncome(gdp, hours = 1) {
return gdp * this.budgetGdpRate * hours;
},
populationGrowthFactor(hoursPerYear, hours = 1) {
if (this.basePopulationGrowthRate <= 0 || hoursPerYear <= 0 || hours <= 0) return 0;
return Math.pow(1 + this.basePopulationGrowthRate, hours / hoursPerYear) - 1;
},
};