Implement scribble game scenarios 1 to 4#123
Open
anirudhbs wants to merge 28 commits into
Open
Conversation
feat: add isHost to Participant type and tighten playerName validation - Add isHost: boolean to Participant in backend models and frontend api types - Update createParticipant() to require name and isHost (removes optional fallback) - createRoom sets isHost=true, joinRoom sets isHost=false - Tighten createRoomSchema and joinRoomSchema: trim + min(1) required - Add Spec Kit artifacts: constitution, spec, plan, tasks, data-model, contracts, quickstart feat(us1): client-side name validation and host indicator in lobby - Trim and reject empty player name before API call in CreateRoomPage - Show "(Host)" label next to the host participant in LobbyPage feat(us2): client-side name validation and 404 error message on join - Trim and reject empty player name before API call in JoinRoomPage - Trim room code before join request - Map "Unable to join room" 404 response to user-friendly inline error feat(us3,us4): auto-polling lobby and host-only start game gate - Add pollRoom() to RoomStore: silent fetch, no loading indicator - Replace manual Refresh button with setTimeout-after-response polling (2s) - Polling stops on component unmount via useEffect cleanup - Derive isHost from participantId; render Start Game only for host - Disable Start Game until room has >= 2 participants chore: mark completed tasks in tasks.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full implementation of a multiplayer Scribble-style drawing and guessing game, built incrementally across four spec-driven scenarios on top of a minimal Express + React starter.
Scenarios
Scenario 1 — Room Setup & Lobby: Host flag (isHost) on participants, name trimming + blank-name rejection (frontend inline errors + backend Zod), 404 on unknown room codes, 2-second setInterval polling in
LobbyPage (with cleanup on unmount), host-only "Start Game" button disabled until ≥ 2 players.
Scenario 2 — Game Start & Drawer Flow: POST /rooms/:code/start transitions room to "playing", assigns drawer (first participant by join order) and deterministic secret word (first entry in word list);
drawer receives secretWord in the snapshot, all others do not; polling in LobbyPage navigates all clients to the Game screen on state change.
Scenario 3 — Gameplay Interaction: DrawingCanvas upgraded from a static
with 400, compares case-insensitively to secret word, awards 100 / 0 points, appends to room.guesses; strokes and scores synced to all clients via existing 2-second poll.
Scenario 4 — Result, Restart & Final Validation: POST /rooms/:code/end (host-only) transitions to "result"; POST /rooms/:code/restart (host-only) resets to "lobby", clearing
secretWord/drawerName/guesses/scores/strokes while preserving participants; new ResultPage shows secret word, per-player scores, and full ordered guess history; polling in all three pages handles all state
transitions.
Notable decisions
Contributor