mwg API
    Preparing search index...

    Interface HookWorld

    What a hook may read: a snapshot of the world, never engine internals.

    interface HookWorld {
        random: HookRandom;
        sides: Readonly<Record<string, { gold: number; income: number }>>;
        turn: number;
        units: Readonly<
            Record<
                string,
                {
                    alive: boolean;
                    hp: number;
                    side?: string;
                    type?: string;
                    x: number;
                    y: number;
                },
            >,
        >;
        variables: Readonly<Record<string, MwlValue>>;
        variableAt(path: string): MwlValue | undefined;
    }
    Index
    random: HookRandom

    A deterministic draw from the runtime's own seeded stream (core.Generator), so a generator/ai/domain hook that needs randomness never reaches for Math.random() and breaks save/replay determinism. Every draw advances the same stream the runtime persists.

    sides: Readonly<Record<string, { gold: number; income: number }>>
    turn: number
    units: Readonly<
        Record<
            string,
            {
                alive: boolean;
                hp: number;
                side?: string;
                type?: string;
                x: number;
                y: number;
            },
        >,
    >
    variables: Readonly<Record<string, MwlValue>>
    • One variable by path, resolved by the same walker [variable] name= reads through, so a hook asks for stored_naga.hitpoints and gets what a scenario asking for stored_naga.hitpoints gets. Read here, write through emit.setVariable: both take a path, and neither is a flat dotted key.

      Parameters

      • path: string

      Returns MwlValue | undefined