Expand description
Per-fingerer modifier system.
A Modifier is a composable buff or debuff attached to a single
fingerer’s crate::game::state::FingererState. Each modifier carries
a stable ModifierSource id, zero or more ModifierEffects, and
an optional duration in ticks. Modifiers stack freely — multiple of
the same source on the same fingerer is fine and additive.
§Stacking semantics
ModifierEffect::FlatFpsvalues across modifiers sum, applied before any percent.ModifierEffect::AddPercentvalues across modifiers sum (two +10% Green Coins = +20%, not +21%).ModifierEffect::MulFactorvalues across modifiers multiply (two x2 buffs = x4).
Final fingerer output:
((base * count + flat_fps) * (1 + add_percent) * mul_factor) * upgrades_mult§Aggregate cache
Hot-path reads (FPS calc, sidebar render) MUST go through
FingererAggregate, never iterate the Vec<Modifier> directly. The
aggregate is rebuilt in three situations only:
- A modifier is added or removed via the public API.
- The per-tick walk drops an expired
ModifierDuration::Ticksentry whose count just hit zero. - The save loader reconstructs it (the field is
#[serde(skip)]).
§Adding a new buff/debuff source
Add a variant to ModifierSource and map it in ModifierSource::id.
No tick-loop changes needed — the existing per-tick walk already
decrements timed modifiers and rebuilds aggregates on expiry. The id
string is load-bearing forever; treat it like a fingerer or upgrade id.
Structs§
- Fingerer
Aggregate - Pre-computed sum/product of every effect across every modifier on a fingerer. Read on every FPS calc — the tick path rebuilds this when modifiers are added, removed, or expire, so reads are O(1).
- Modifier
- A single buff or debuff attached to a fingerer. Composable: a fingerer may carry an unbounded number of these. See module docs for the stacking rules and aggregate-cache contract.
Enums§
- Modifier
Duration - Lifetime of a modifier. Permanent modifiers stick for the rest of the
run (cleared only by
prestige_reset). Timed modifiers decrement once perstate.tick()and drop when they hit zero. - Modifier
Effect - One contribution from a modifier. A single
Modifiermay carry multiple effects — e.g. a future debuff could combine[FlatFps(-10.0), MulFactor(0.5)]. - Modifier
Source - Stable identifier for the kind of buff or debuff a modifier represents. Used for de-duping in the UI (“3× Green Coin” instead of three identical chips), for save serialization, and for future per-source rules.