mwg API
    Preparing search index...

    Class MwlRuntime

    Runtime for compiled MWL content. It never parses source text during play.

    The framework runtime owns what is game-agnostic: maps, sides, units, turn order, the schedule, objectives, events, and save/load. Game rules that need real data (pathfinding costs, combat formulas) stay in the engine adapter; this runtime's move is a bounds and occupancy check, and attack applies the amount the content asks for.

    import { compile, MwlRuntime } from '@datamoc/mw_games/mwl';

    const runtime = new MwlRuntime(compile("[{ tag: 'game', schema: 0.1 }]"), {
    resolveMap: () => 'Gg,Gg\nGg,Gg',
    });
    console.log(runtime.world.turn); // 1
    Index
    world: MwlWorld
    • Answer a pending dialogue: run the chosen choice's event and clear the pending state. Returns false when there is no such pending dialogue or choice; throws when the referenced event does not exist (content error).

      Parameters

      • dialogueId: string
      • choiceIndex: number

      Returns boolean

    • Evaluate [objectives] now and return the resulting status. A game whose own engine resolved the actions (real movement, combat) calls this after writing the results into world; run already calls it itself.

      Returns "playing" | "won" | "lost"

    • Fire one named event through the same filter, claim, and execution path as a trigger.

      Parameters

      • id: string

      Returns boolean

    • Fire the on=moveto events for a unit that has just arrived somewhere. The runtime's own [move] command calls this, and so does a game whose engine moved the unit: write the new position into world.units first, then call this with the unit id.

      An event matches when x/y (when given) are the unit's position, and unit/side (when given) are the unit's. A moveto event fires once by default; pass once=false on the event to let it fire every time.

      Parameters

      • id: string

      Returns void