feat(offline): local game persistence + replay (Phase B2) #192
Reference in New Issue
Block a user
Delete Branch "feature/offline-localgame-store"
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 B2 of PWA offline mode, on top of #191. Store an offline game durably and reconstruct it — the offline counterpart of the server's replay rehydration. Not wired into the UI yet (B3).
serialize.ts: aLocalGameRecord(seed + rules + seat metadata + the alphabet-index move journal) +replayGame()— reconstruct a liveLocalGameby seeding a fresh engine identically and replaying the journal. Board/bag/racks are NOT stored; they are deterministic from the seed + the replayed ops, so the record stays small. The journal is dictionary-independent (index space, stable per variant).store.ts: an IndexedDB store for local games (save/get/list/delete), mirroringlib/dict/store.ts— own DB, best-effort, guarded when IndexedDB is absent.engine.ts: record the swapped tiles on an exchange (needed for exact replay) + expose the rule config.serialize.test.ts: a round-trip — reconstruct a mid-game and a finished game by replay and assert the state (board/racks/bag/scores/turn/log) is identical.Pure additive library code; no runtime behavior change (bundle unchanged). Local verify green: UI check (611 files) + test:unit (453 passed) + build.