game:answer WS handler — collect answers #44

Open
opened 2026-04-19 07:23:40 +00:00 by forgejo-lila · 0 comments
Owner

Context

During multiplayer, players submit answers via WebSocket. Server collects and determines when to evaluate.

Files to change

  • apps/api/src/ws/handlers/gameHandlers.ts

Behavior varies by mode

Simultaneous (Race to the Top, Elimination):

  1. Validate: player in lobby, game in_progress, correct question.
  2. Store answer in Valkey.
  3. All answered OR timeout: trigger evaluation.

Turn-based (Chain Link):

  1. Validate: it's this player's turn.
  2. Store, evaluate immediately, broadcast, advance.

Buzzer (TV Quiz Show):

  1. First game:buzz claims question.
  2. Only buzzer can submit game:answer.
  3. Wrong: open to next buzzer or skip.

Acceptance criteria

  • Duplicate answers rejected
  • Answers after timeout rejected
  • Late answers handled gracefully
  • Answer state tracked in Valkey per lobby per round
  • Evaluation triggers correctly

Notes

Answer evaluation logic exists in gameService.evaluateAnswer(). Multiplayer version wraps it with coordination.

## Context During multiplayer, players submit answers via WebSocket. Server collects and determines when to evaluate. ## Files to change - `apps/api/src/ws/handlers/gameHandlers.ts` ## Behavior varies by mode **Simultaneous (Race to the Top, Elimination):** 1. Validate: player in lobby, game in_progress, correct question. 2. Store answer in Valkey. 3. All answered OR timeout: trigger evaluation. **Turn-based (Chain Link):** 1. Validate: it's this player's turn. 2. Store, evaluate immediately, broadcast, advance. **Buzzer (TV Quiz Show):** 1. First `game:buzz` claims question. 2. Only buzzer can submit `game:answer`. 3. Wrong: open to next buzzer or skip. ## Acceptance criteria - Duplicate answers rejected - Answers after timeout rejected - Late answers handled gracefully - Answer state tracked in Valkey per lobby per round - Evaluation triggers correctly ## Notes Answer evaluation logic exists in `gameService.evaluateAnswer()`. Multiplayer version wraps it with coordination.
forgejo-lila added the
multiplayer
label 2026-04-19 07:23:40 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: forgejo-lila/lila#44
No description provided.