serveCampaign beta
Function of @v12-engine/client/campaign-worker
export declare function serveCampaign<D extends object = Record<string, unknown>>(rules: Rules, campaign: {
missions: readonly CampaignMissionCode<D>[];
}, options?: ServeCampaignOptions): void;What a campaign's worker file does (StartAppOptions.worker): plays the mission the campaign's scene asks for (its id, the progress, the difficulty: CampaignWorkerArgs) with the game's rules, runs the mission's code on its world there (its onStart, a cinematic briefing, its carry as it is won), and tells the page the mission won as plain data (MissionWin), which the page keeps. The missions are the campaign's code, by id: the list given to defineCampaign (missions), imported from a module with nothing of the page in it
// sim.worker.ts, with serveCampaign of @v12-engine/client/campaign-worker serveCampaign(game.toRules(), missions: MISSION_CODE )
A worker served this way plays the campaign's missions only: the app's other games (free play, the editor's Play here) are played in the page