mwg API
    Preparing search index...

    Class ActionJournal<Action, Event>

    A serializable, append-only action log for replay, undo checkpoints, synchronization and debugging. It does not interpret actions or events: the game decides how to reapply an action, while the journal preserves the exact order and resulting event batch.

    import { ActionJournal } from '@datamoc/mw_games/core';

    const journal = new ActionJournal<string, { type: string }>();
    journal.append('open-door', [{ type: 'door-opened' }]);
    const checkpoint = journal.mark();
    // An undo system can restore its state and replay journal.since(checkpoint).

    Type Parameters

    • Action
    • Event
    Index
    • Returns a sequence number that can be used as an undo or sync checkpoint.

      Returns number

    • Drops entries at and after a checkpoint, as an undo operation would.

      Parameters

      • sequence: number

      Returns void