Expand description
Timed chains reward continued accepted actions. Hosts own event deduplication.
Call an award method only after the game’s action is accepted. Inspection
never accepts an action, changes state, or refreshes the simulation timer.
ScoreChain::award_with_receipt preserves legacy saturation; ScoreChain::try_award
instead rejects either counter overflow atomically. Display total_change,
not nominal_points, as the amount added to this helper’s total.
use ferravex_play::gameplay::combo::{ChainAdvance, ChainReset, ScoreChain};
let mut score = ScoreChain::new(2.0, 2, 3).unwrap();
let preview = score.preview_award(100).unwrap();
assert_eq!(score.remaining_life(), None);
let receipt = score.try_award(100).unwrap().unwrap();
assert_eq!(receipt, preview);
assert_eq!((receipt.base, receipt.tier, receipt.multiplier), (100, 1, 1));
assert_eq!((receipt.nominal_points, receipt.total_change), (100, 100));
assert!(!receipt.chain_saturated && !receipt.total_saturated);
assert_eq!((receipt.chain, receipt.total_before, receipt.total_after), (1, 0, 100));
assert_eq!(score.award_with_receipt(0), None);
assert_eq!(score.remaining_life(), Some(2.0));
assert_eq!(score.advance_with_outcome(1.0).unwrap(), ChainAdvance::Active);
assert_eq!(score.advance_with_outcome(1.0).unwrap(), ChainAdvance::Expired { chain: 1 });
assert_eq!(score.advance_with_outcome(0.0).unwrap(), ChainAdvance::Idle);
score.reset(ChainReset::Run); // Clear run score, retain best chain.
assert_eq!((score.chain(), score.total(), score.best()), (0, 0, 1));
score.reset(ChainReset::All);
assert_eq!(score.best(), 0);
score.award(25);
score.reset(ChainReset::ChainOnly);
assert_eq!((score.chain(), score.total(), score.best()), (0, 25, 1));Structs§
- Score
Award - An accepted award, or a forecast returned by
ScoreChain::preview_award. A forecast is not feedback evidence; see the module example for acceptance. - Score
Chain - Allocation-free scoring with an authored simulation-time chain window.
Expiry occurs on advancement at the inclusive
remaining <= 1e-9boundary, including a zero-delta advance. A newly awarded sub-epsilon window remains active until advancement. See the module example for receipts and resets. - Score
Overflow - Counters that would overflow in an atomically rejected
ScoreChain::try_award. Both flags can be true. The rejection changes no field, including timing/best.
Enums§
- Chain
Advance - Result of advancing simulation time; an expiry is reported exactly once. See the module example. Inspection alone never triggers expiry.
- Chain
Reset - Explicit reset policy. Every mode retains window, actions per tier and cap. See the module example for resetting alongside a host’s session lifecycle.