mwg API
    Preparing search index...

    Interface Actor

    Whose turn it is.

    Not "everyone moves once per turn": each actor has a speed, and an action costs time scaled by it. A hasted creature gets two moves to your one, a heavy weapon costs more than a dagger, and a slowed one loses turns, all of which fall out of one number rather than needing special cases.

    The queue is ordered by the time at which each actor next acts. now only ever moves forward, so effects that expire can be timestamped against it.

    import { Scheduler, type Actor } from '@datamoc/mw_games/roguelike';

    interface Monster extends Actor { name: string }

    const scheduler = new Scheduler<Monster>();
    scheduler.add({ name: 'hero', speed: 1 });
    scheduler.add({ name: 'fast rat', speed: 2 }); // acts twice as often

    const acting = scheduler.peek(); // whoever's turn it is
    scheduler.spend(1); // charge them for a normal-speed action, hand the turn on
    interface Actor {
        priority?: number;
        speed?: number;
    }
    Index
    priority?: number

    higher-priority actors resolve first when their scheduled times tie

    speed?: number

    actions per unit of time; 2 acts twice as often as 1