20 lines
700 B
JavaScript
20 lines
700 B
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.
|
|
|
|
export const EFFECT_GDP = "gdp";
|
|
export const EFFECT_RESEARCH = "research";
|
|
export const EFFECT_CULTURE = "culture";
|
|
export const EFFECT_BUDGET_INCOME = "budget_income";
|
|
|
|
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);
|
|
}
|