37 lines
1.7 KiB
JavaScript
37 lines
1.7 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";
|
|
|
|
// 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);
|
|
}
|