feat(web): add visible countdown timer to multiplayer game #10
Labels
No labels
debt
feature
feature
infra
multiplayer
multiplayer
security
ux
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: forgejo-lila/lila#10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
The server enforces a 15-second answer timer per round in multiplayer games.
When the timer expires, unanswered players are marked as timed out and the
round resolves automatically. Currently the client has no visual indication
of the remaining time — players don't know how long they have to answer.
What needs to happen
Add a countdown timer component to the multiplayer game view that:
game:questionmessage is received.game:answer_resultis received (round resolved).continue counting down (showing other players' remaining time) or
stop on answer (simpler).
Options for timer sync
A. Client-side only: start a
setTimeout(15000)ongame:question.Simple, but drifts if the client tab is backgrounded or the device is slow.
The server timer and client timer can get out of sync, causing the UI to
show "5 seconds left" when the server has already resolved the round.
B. Server sends remaining time: include
timeLimitandstartedAtin
game:questionso the client can calculate elapsed time and displayaccurate remaining time. More robust, handles late joins and reconnections.
My lean: B — include
timeLimit: numberandstartedAt: string (ISO)inWsGameQuestionSchema. Client computesremaining = timeLimit - (now - startedAt).Acceptance criteria
game:question, stops ongame:answer_result.Related
packages/shared/src/schemas/lobby.ts—WsGameQuestionSchemaapps/api/src/ws/handlers/gameHandlers.ts—handleLobbyStart,resolveRoundapps/web/src/routes/multiplayer/game.$code.tsx