Skip to main content

run_event_checked

Function run_event_checked 

Source
pub fn run_event_checked<P: EffectProvider + ?Sized>(
    ctx: &mut BattleCtx<'_, P>,
    hs: Vec<CollectedHandler<P>>,
    relay: RelayVar,
    fast_exit: bool,
) -> RelayVar
Expand description

The dispatch fold with the §2.3 per-step liveness re-check — the multi-source variant.

Identical to run_event (same sort, same tie-break draw, same fast_exit fold) except that before each handler fires it re-checks that the handler’s target is still alive — because a multi-source fold can collect handlers from several effects, and an earlier handler (e.g. a weather chip, or a contact-ability) can KO the target an later handler was about to act on. The re-check is a pure read between calls while the loop holds the sole &mut, so it never aliases the snapshot.

Source-effect removal mid-fold (a handler removing another live volatile) is left to each game handler’s own post-mutation guard, matching the existing slice contract (driver.rs: “each game handler is responsible for its own post-faint guard”) — CollectedHandler carries no arena borrow, so a removed source effect simply means ctx.effect(source_effect) returns None, which the handler reads defensively.

run_event is kept separate and unchanged so the 88 Gen-1 slices’ fold is byte-identical; this variant is for the broadened multi-source path.