Skip to content

Ring Toss carnival game#2

Merged
LinaBell merged 5 commits intomainfrom
dev
Apr 24, 2026
Merged

Ring Toss carnival game#2
LinaBell merged 5 commits intomainfrom
dev

Conversation

@LinaBell
Copy link
Copy Markdown
Contributor

Summary

  • Full implementation of a 1-2 player turn-based ring toss carnival game for school field day environments
  • Skill-based power meter with admin-configurable difficulty (Easy/Hard/Progressive)
  • Canvas integration: peg images update with ring stacks, missed rings scatter on ground, players teleported to mats
  • 9 achievement badges with safe awarding (Sharp Shooter, On Fire, Stack Master, Piggyback Pro, Comeback Kid, All Miss No Hit, Ring Toss Regular, Ring Rockstar, Field Day Champion)
  • In-memory SSE for real-time updates (replaces polling, ~95% API load reduction)
  • Per-visitor game stats tracking (gamesPlayed, gamesWon) for badge eligibility
  • Instructions modal auto-opens for first-time players
  • Auto-cleanup of previous game remnants on new game start

Test plan

  • Solo game: join, start, play through all 6 tosses, verify game ends and badges awarded
  • 2-player game: both join, start, alternate turns, verify SSE updates opponent in real-time
  • Reset during game (player and admin), verify pegs reset and rings removed from canvas
  • Play Again after game over, verify clean board and both players can rejoin
  • Progressive difficulty: verify meter starts slow and gets faster each toss
  • Badges tab shows earned badges in color, unearned grayed out
  • Game auto-ends when all pegs are full
  • 20-second turn timer auto-misses on timeout
  • Spectator view shows game in progress with scores
  • Admin settings: change difficulty, verify it persists across resets

Generated with Claude Code (https://claude.com/claude-code)

LinaBell and others added 5 commits April 20, 2026 17:08
Full implementation of a 1-2 player turn-based ring toss game:

Server:
- 6 endpoints: game-state, join, start, toss, end-game, reset
- Skill-based power meter determines hit/miss
- Peg images update on canvas via updateWebImageLayers
- Missed rings drop as scattered assets on canvas
- Players teleported to mats on game start (using stored interactiveNonce)
- 9 achievement badges via processGameCompletion shared util
- Per-visitor game stats (gamesPlayed, gamesWon) for badge eligibility
- getVisitor util initializes visitor data before any updates
- Reset clears board, removes ring assets, resets peg images

Client:
- GameLobby: Join/Start/Reset with player slot display
- GameBoard: Peg selection, power meter, 20s turn timer with auto-miss
- PowerMeter: 5-section animated oscillating meter
- GameOver: Final scores, winner display, Play Again
- GameInProgress: Spectator view for non-players
- BadgesDisplay: Tabbed badges UI (earned/unearned)
- 3s polling for lobby updates and opponent turns
- Background image from S3

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add in-memory SSE connection manager (sseManager.ts) with connection
  registration, heartbeat tracking, publish-to-others filtering, and
  stale connection pruning (10min timeout, 60s interval)
- Add SSE endpoint (GET /sse) and heartbeat endpoint (POST /heartbeat)
- All 5 game controllers now publish SSE events after state changes
  (player_joined, game_started, toss, game_ended, game_reset)
- Client replaces 3-second polling with EventSource connection
- Includes 5-minute heartbeat interval to keep connections alive
- Reduces API load from N/3 requests/second (continuous) to ~14 events
  per game total

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mes, reset fixes

- Add InstructionsModal with 6-step how-to-play guide
- Auto-open instructions for first-time players (gamesPlayed === 0)
- Info icon button next to page title (PageContainer updated with onInfoClick + tabs props)
- Game auto-ends when all pegs are full (no more points possible)
- Show player names next to Red/Blue on ScoreBoard and GameOver
- Play Again visible only for current players, others see Reset
- Reset button always visible in lobby
- Re-fetch game state on game end for both players to update badges
- Server returns visitorGameData from /game-state endpoint

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rogressive meter fix

- Add admin Difficulty setting (Easy/Hard/Progressive) saved to key asset data object
- New PUT /settings endpoint for admin to update difficulty
- PowerMeter speed adapts to difficulty: Easy=280ms, Hard=140ms, Progressive=280→140ms
- Fix progressive tossNumber calculation for solo mode (was counting blue's 0 rings as 6 used)
- Fix Comeback Kid badge: now tracks wasLosing per player, only awards if actually came from behind
- Extract cleanupBoard util from duplicate logic in handleReset and handleStart
- handleStart now resets all gameplay fields via DEFAULT_GAME_STATE before starting
- Preserve difficulty setting across game resets

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@LinaBell LinaBell requested a review from cpsiaki as a code owner April 24, 2026 00:23
@LinaBell LinaBell added the major label Apr 24, 2026
@LinaBell LinaBell requested a review from liebeskind as a code owner April 24, 2026 00:23
@LinaBell LinaBell merged commit d527323 into main Apr 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant