27 lines
1.1 KiB
JavaScript
27 lines
1.1 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_CONSTRUCTION_SPEED = "construction_speed";
|
|
export const EFFECT_RAIL_SPEED = "rail_speed";
|
|
|
|
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);
|
|
}
|