pub struct ScoreChain { /* private fields */ }Expand description
Allocation-free scoring with an authored simulation-time chain window.
Expiry occurs on advancement at the inclusive remaining <= 1e-9 boundary,
including a zero-delta advance. A newly awarded sub-epsilon window remains
active until advancement. See the module example for receipts and resets.
Implementations§
Source§impl ScoreChain
impl ScoreChain
pub fn new( window: f32, per_tier: u32, maximum: u32, ) -> Result<ScoreChain, LoopError>
pub fn advance(&mut self, dt: f32) -> Result<(), LoopError>
Sourcepub fn advance_with_outcome(
&mut self,
dt: f32,
) -> Result<ChainAdvance, LoopError>
pub fn advance_with_outcome( &mut self, dt: f32, ) -> Result<ChainAdvance, LoopError>
Advance once per executed simulation tick, reporting expiry once.
Invalid dt (non-finite, negative, or above 3600 seconds) returns
LoopError::Invalid with every field unchanged, even if idle.
Total and best survive expiry. See the module example.
Sourcepub fn award(&mut self, base: u32) -> u64
pub fn award(&mut self, base: u32) -> u64
Legacy saturating award, returning nominal points even at total saturation.
Zero is a no-op. Use Self::award_with_receipt for actual total changes.
Sourcepub fn preview_award(&self, base: u32) -> Option<ScoreAward>
pub fn preview_award(&self, base: u32) -> Option<ScoreAward>
Forecast the legacy saturating policy without mutating or refreshing time.
Zero returns None without changes. Tier is one-based and uncapped;
multiplier is capped. Overflow flags describe lost increments, rather
than a counter merely reaching its maximum. See the module example.
Sourcepub fn award_with_receipt(&mut self, base: u32) -> Option<ScoreAward>
pub fn award_with_receipt(&mut self, base: u32) -> Option<ScoreAward>
Accept with explicit saturation, sharing the exact policy of Self::award.
A nonzero base always increments/saturates the chain, updates best and
refreshes the window, even if total cannot increase. Receipt flags expose
each overflow independently. Zero returns None and changes nothing.
Emit feedback only from this accepted result, never from a preview.
See the module example; total changes concern this helper only, not any
separate narrower counter maintained by a consumer.
Sourcepub fn try_award(
&mut self,
base: u32,
) -> Result<Option<ScoreAward>, ScoreOverflow>
pub fn try_award( &mut self, base: u32, ) -> Result<Option<ScoreAward>, ScoreOverflow>
Accept only if both chain increment and nominal total addition fit.
Either overflow returns ScoreOverflow before any mutation.
Zero returns Ok(None) even at counter bounds. Successful receipts have
both saturation flags false. Games that already committed an action and
require legacy saturation should use Self::award_with_receipt instead;
rejection here does not roll back another system’s accepted action.
See the module example for usage.
pub fn multiplier(&self) -> u32
pub fn chain(&self) -> u32
pub fn best(&self) -> u32
pub fn total(&self) -> u64
Sourcepub fn remaining_life(&self) -> Option<f64>
pub fn remaining_life(&self) -> Option<f64>
Remaining simulation seconds for an active chain, at internal precision.
Never advances or expires the chain, even at/below epsilon. None means
no active chain. See the module example.
Sourcepub fn reset(&mut self, mode: ChainReset)
pub fn reset(&mut self, mode: ChainReset)
Apply the explicit clearing/retention policy, retaining authoring settings.
See ChainReset and the module example for each mode’s fields.
Sourcepub fn break_chain(&mut self)
pub fn break_chain(&mut self)
Legacy break: clear chain and remaining time, retain total, best and settings.
Trait Implementations§
Source§impl Clone for ScoreChain
impl Clone for ScoreChain
Source§fn clone(&self) -> ScoreChain
fn clone(&self) -> ScoreChain
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more