feat(offline): wire the local game source into the game screen (Phase B3.2) #194
Reference in New Issue
Block a user
Delete Branch "feature/offline-game-seam-wire"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase B3.2 of PWA offline mode, on top of #193. The game screen now drives a local vs_ai game through the offline engine, dispatched by game id — completing the playable local game. Online play is unchanged.
gamesource.ts:gameSource(id)returns the local source for alocal:id, else the gateway (same game-loop interface). The offline engine stays OUT of the app entry bundle — dynamically imported on first use (a separate ~8KB gzip chunk), so online-only users never pay for it (app entry 111.2/112 KB, still within budget).localgame/id.ts: the tiny id helper (no engine imports) the dispatcher branches on.Game.svelte: the game-loop calls (state/history/submit/pass/exchange/resign/hint/evaluate/draft) go throughgameSource(id)instead of the gateway directly; a local game's robot-reply events route through the same app event hub the network stream feeds, so the screen reacts to opponent_moved / game_over identically.Behaviour-preserving for network games (
gameSourcereturns the gateway for them). Local verify green: check + test:unit + build + bundle-size gate + e2e (196 passed). (A local-game e2e needs offline creation + a mock dawg — that lands with Phase C, the offline UX.)