Skip to main content

speed_sort_tiebreak

Function speed_sort_tiebreak 

Source
pub fn speed_sort_tiebreak<P: EffectProvider + ?Sized>(
    hs: &mut [CollectedHandler<P>],
    rng: &mut dyn BattleRng,
)
Expand description

Permute only the tied runs (compare == Equal) by drawing one byte from the rng per tie — the single source of true handler-order randomness (design §1.3, mirroring pokered’s order coin-flip, bug #22).

hs must already be sorted by compare. Within each maximal run of equal entries, adjacent pairs are conditionally swapped on a byte < 128 flip — the same comparison shape as turn_order.rs:41.