mwg API
    Preparing search index...

    Interface UndoHistoryOptions

    A bounded, generic back/forward step through recent turns - a mode a game opts into (useless in a permadeath roguelike, useful elsewhere), agnostic about what "a turn's state" actually contains the same way SaveSystem is agnostic about what "the save" contains: a game serializes its own turn-scoped state (a Level, a BoardGrid, whatever it has) and this only ever stores and replays snapshots of it, never interprets them.

    Distinct from Recorder/Player (item 42), which replay a whole Input.onAction log deterministically for testing, not a bounded, player-facing "undo my last move".

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

    interface TurnState { x: number; y: number }

    const history = new UndoHistory<TurnState>({ limit: 20 });
    history.push({ x: 0, y: 0 });
    history.push({ x: 1, y: 0 });

    if (history.canUndo) {
    const previous = history.undo();
    }
    interface UndoHistoryOptions {
        limit?: number;
    }

    Hierarchy (View Summary)

    Index
    limit?: number

    states retained before the oldest is dropped; defaults to 50