The simple economy is now the default and the old simulation is frozen as the hard model, selectable per game. A nation keeps one resource pool available in every region, fed by public production works rather than private per-region stores, and construction and training begin at once, paced by the region's spare power instead of gathering materials over days. Money is euro only: a per-inhabitant daily tax funds a treasury spent in a global market, where buy and sell lots trade against the world stock and move its price. The hard economy keeps its per-nation currencies, central banks and exchange rates. Simple games skip the price-settling warmup and economic migration; the snapshot carries the economy model, the market and the pool figures the client draws. Added the matching test suites and the design briefs under docs/simple_economy.
41 lines
1.9 KiB
JavaScript
41 lines
1.9 KiB
JavaScript
// Stat effects shared by every data-driven entry (buildings, governments,
|
|
// technologies). An effect scales with a level so a building's benefit grows
|
|
// with each upgrade.
|
|
|
|
// Every stat that modifies a tile's or a nation's production, in display order.
|
|
export const EFFECT_PRODUCTION = "production";
|
|
export const EFFECT_RESEARCH = "research";
|
|
export const EFFECT_CULTURE = "culture";
|
|
// Repeatable technology effects. Each is a fraction that stacks with every
|
|
// further level researched.
|
|
export const EFFECT_INFANTRY_ATTACK = "infantry_attack";
|
|
export const EFFECT_INFANTRY_DEFENSE = "infantry_defense";
|
|
export const EFFECT_ARTILLERY_ATTACK = "artillery_attack";
|
|
export const EFFECT_MISSILE_ATTACK = "missile_attack";
|
|
export const EFFECT_CONSTRUCTION_SPEED = "construction_speed";
|
|
export const EFFECT_RAIL_SPEED = "rail_speed";
|
|
// Scales the simple economy's per-inhabitant daily tax. No government, building
|
|
// or technology grants one yet, so the factor is 1; it exists so the tax formula
|
|
// has a single hook a later policy can move.
|
|
export const EFFECT_TAX_INCOME = "tax_income";
|
|
|
|
// Resource efficiency: the national bonus to a commodity's output per unit of
|
|
// energy input. One technology per commodity raises its own stat, and the
|
|
// simulation divides that commodity's energy draw by `1 + bonus`.
|
|
export const EFFECT_ENERGY_EFFICIENCY = "energy_efficiency";
|
|
export const EFFECT_STEEL_EFFICIENCY = "steel_efficiency";
|
|
export const EFFECT_FOOD_EFFICIENCY = "food_efficiency";
|
|
export const EFFECT_LUXURY_EFFICIENCY = "luxury_efficiency";
|
|
export const EFFECT_HIGHTECH_EFFICIENCY = "hightech_efficiency";
|
|
|
|
export function effect(stat, baseValue, exponent = 1.0) {
|
|
return { stat, baseValue, exponent };
|
|
}
|
|
|
|
// The value of an effect at `level`. A level of zero or less contributes
|
|
// nothing, so an unbuilt building never has an effect.
|
|
export function effectValue(e, level) {
|
|
if (level <= 0) return 0;
|
|
return e.baseValue * Math.pow(level, e.exponent);
|
|
}
|