mwg API
    Preparing search index...

    Class CampaignSave<CampaignState, Result, World, TurnState>

    One save slot for a whole campaign, over core.SaveSystem. SaveSystem deliberately owns one state value and mwl's persistence owns one world, so neither saves a campaign's level sequence, its world and its turn together; this is the composition, not a second save format. Versioning, migrations, previews, the storage fallback and slot listing are all SaveSystem's, unchanged.

    Capturing takes each piece's own snapshot(), so the pieces stay responsible for what resuming them means: Campaign.restore and SimulationRuntime.restore read their halves back, and the game reads its own world.

    import { CampaignSave } from '@datamoc/mw_games/simulation';

    const saves = new CampaignSave<{ gold: number }, never, unknown, { hp: number }>({
    namespace: 'my-campaign',
    version: 1,
    });

    declare const campaign: { snapshot(): never };
    declare const simulation: { snapshot(): never };
    saves.save('slot1', { campaign, world: { terrain: '...' }, simulation }, 'Chapter 2');

    const loaded = saves.load('slot1');
    // loaded.campaign -> Campaign.restore(...); loaded.world -> the game's own; loaded.simulation -> SimulationRuntime.restore(...)

    Type Parameters

    Index