feat(offline): local game source (Phase B3.1) #193

Merged
developer merged 1 commits from feature/offline-game-seam into development 2026-07-06 07:13:27 +00:00
Owner

Phase B3.1 of PWA offline mode, on top of #192. A GatewayClient-shaped facade over the offline engine, so the same game screen can drive a local vs_ai game with no backend. Wiring into Game.svelte is B3.2 (next PR).

  • source.ts: LocalSource implements the game-loop subset (GameLoopSource) for a local game id — gameState/gameHistory via replay; submitPlay/pass/exchange/resign apply the human move then run the robot (decide(generateMoves)) synchronously, persist both, and deliver the robot move via a per-game event emitter (no live stream); hint gated to >30 min since the robot last moved; evaluate/checkWord local. Glyph⇄index via the static letters.
  • ruleset.ts: static per-variant letters table (glyphs), pinned to the Go alphabet — offline now fully self-contained.
  • engine.ts: submitPlay (infers direction), evaluatePlay + dictionaryHas, and record the main-word coord + words on a play.
  • source.test.ts: create → human pass → synchronous robot reply via the event, the hint gate, decoded history, a whole game to completion.

Pure additive library code; no runtime behavior change (bundle unchanged). Local verify green: backend build/vet/gofmt; UI check + test:unit (459) + build.

Phase B3.1 of PWA offline mode, on top of #192. A `GatewayClient`-shaped facade over the offline engine, so the same game screen can drive a local vs_ai game with no backend. Wiring into `Game.svelte` is B3.2 (next PR). - `source.ts`: `LocalSource` implements the game-loop subset (`GameLoopSource`) for a local game id — `gameState`/`gameHistory` via replay; `submitPlay`/`pass`/`exchange`/`resign` apply the human move then run the robot (`decide(generateMoves)`) synchronously, persist both, and deliver the robot move via a per-game event emitter (no live stream); `hint` gated to >30 min since the robot last moved; `evaluate`/`checkWord` local. Glyph⇄index via the static letters. - `ruleset.ts`: static per-variant letters table (glyphs), pinned to the Go alphabet — offline now fully self-contained. - `engine.ts`: `submitPlay` (infers direction), `evaluatePlay` + `dictionaryHas`, and record the main-word coord + words on a play. - `source.test.ts`: create → human pass → synchronous robot reply via the event, the hint gate, decoded history, a whole game to completion. Pure additive library code; no runtime behavior change (bundle unchanged). Local verify green: backend build/vet/gofmt; UI check + test:unit (459) + build.
developer added 1 commit 2026-07-06 07:07:59 +00:00
feat(offline): local game source (Phase B3.1)
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 17s
CI / ui (pull_request) Successful in 1m9s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m39s
32298595f2
A GatewayClient-shaped facade over the offline engine, so the same game screen can drive
a local vs_ai game with no backend (the wiring into Game.svelte is B3.2).

- source.ts: LocalSource implements the game-loop subset (GameLoopSource) for a local game
  id — gameState/gameHistory via replay, submitPlay/pass/exchange/resign apply the human
  move then run the robot (decide(generateMoves)) synchronously, persisting both and
  delivering the robot's move through a per-game event emitter (no live stream). hint is
  gated to >30 min since the robot's last move; evaluate/checkWord are local. It translates
  the UI's glyph space to the engine's index space with the static letters table.
- ruleset.ts: add the static per-variant letters (glyphs), pinned to the Go alphabet —
  offline is now fully self-contained (no reliance on a warm server alphabet cache).
- engine.ts: submitPlay (infers the direction like the server SubmitPlay), evaluatePlay +
  dictionaryHas for the move preview / word check, and record the main-word coordinate +
  the words on a play (for the history MoveRecord).
- source.test.ts: create -> human pass -> synchronous robot reply via the event, the hint
  gate, decoded history, and a whole game driven to completion.

Pure additive library code; no runtime behavior change (bundle unchanged).
owner approved these changes 2026-07-06 07:11:00 +00:00
developer merged commit 9ecbe480db into development 2026-07-06 07:13:27 +00:00
developer deleted branch feature/offline-game-seam 2026-07-06 07:13:27 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: developer/scrabble-game#193