Summary
Add a replay system that can load a recorded game log, play it back through the existing UI, and support scrubbing/jumping to any point in the game timeline.
Problem Statement
We need a way to review completed games without live user input driving the game. The current client/server architecture is close to replay-ready, but input handling and replay control need explicit support.
Current Behavior
- Game state is produced by the in-memory server and pushed to the client.
- UI renders from
ClientGameState via context and Pixi/React components.
- User interactions (hex clicks, card clicks, etc.) dispatch actions directly through
sendAction.
- No persisted replay log format exists today.
Expected Behavior
- A completed game can be exported/imported as a replay log.
- Replay mode can play/pause, step, and scrub to any timeline position.
- Existing board/hand rendering path is reused (state-driven rendering remains the source of truth).
- Input/gameplay actions are disabled while replay mode is active.
Investigation Findings
- Rendering is already largely state-driven and reusable for historical snapshots.
- Primary coupling is interaction binding in render-time overlay handlers and turn-gated input hooks.
- Engine/server are deterministic with seeded RNG, making action-sequence replay feasible.
- Server currently returns events + resulting state per action; this is a strong base for logging.
Proposed Technical Approach
- Add replay log schema in shared types (versioned): metadata + initial seed + ordered actions.
- Add optional periodic checkpoints (serialized state every N actions) to speed seek/scrub.
- Add replay logger around server action handling.
- Build replay controller/provider in client:
- manages timeline index, play/pause, speed, seek/step
- exposes effective state (
live vs replay) to existing UI
- Gate/disable gameplay dispatch and interactive handlers while in replay mode.
- Add replay controls UI (timeline slider + step buttons + play/pause).
Affected Files
packages/client/src/context/GameProvider.tsx
packages/client/src/components/GameBoard/pixi/rendering/overlays.ts
packages/client/src/components/GameBoard/hooks/useHexInteraction.ts
packages/client/src/components/Hand/PlayerHand.tsx
packages/client/src/components/GameBoard/hooks/useGameBoardRenderer.ts
packages/server/src/GameServer.ts
packages/shared/src/connection.ts
packages/core/src/utils/rng.ts
Acceptance Criteria
Rough Effort Estimate
- MVP (load log + play/pause + step + basic scrub): ~1-2 weeks
- Production-ready (fast seek, polish, import/export UX, test coverage): ~3-5 weeks total
Summary
Add a replay system that can load a recorded game log, play it back through the existing UI, and support scrubbing/jumping to any point in the game timeline.
Problem Statement
We need a way to review completed games without live user input driving the game. The current client/server architecture is close to replay-ready, but input handling and replay control need explicit support.
Current Behavior
ClientGameStatevia context and Pixi/React components.sendAction.Expected Behavior
Investigation Findings
Proposed Technical Approach
livevsreplay) to existing UIAffected Files
packages/client/src/context/GameProvider.tsxpackages/client/src/components/GameBoard/pixi/rendering/overlays.tspackages/client/src/components/GameBoard/hooks/useHexInteraction.tspackages/client/src/components/Hand/PlayerHand.tsxpackages/client/src/components/GameBoard/hooks/useGameBoardRenderer.tspackages/server/src/GameServer.tspackages/shared/src/connection.tspackages/core/src/utils/rng.tsAcceptance Criteria
Rough Effort Estimate