Skip to main content

Module modifier

Module modifier 

Source
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

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:

  1. A modifier is added or removed via the public API.
  2. The per-tick walk drops an expired ModifierDuration::Ticks entry whose count just hit zero.
  3. 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§

FingererAggregate
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§

ModifierDuration
Lifetime of a modifier. Permanent modifiers stick for the rest of the run (cleared only by prestige_reset). Timed modifiers decrement once per state.tick() and drop when they hit zero.
ModifierEffect
One contribution from a modifier. A single Modifier may carry multiple effects — e.g. a future debuff could combine [FlatFps(-10.0), MulFactor(0.5)].
ModifierSource
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.