mwg API
    Preparing search index...

    Class CanonicalState<State>

    A single JSON-safe source of truth for a game's logical state. The root value belongs to the game, while framework or game subsystems register independent versioned extensions beside it. Reads and writes clone values, so a renderer cannot mutate authoritative state accidentally.

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

    const state = new CanonicalState({ turn: 1, gold: 10 });
    state.update((current) => ({ ...current, gold: current.gold - 3 }));
    const save = state.snapshot();
    state.restore(save);

    Type Parameters

    Index
    extensions: StateRegistry