feat(multiplayer): handle player disconnect during in-progress game #5

Open
opened 2026-04-17 07:02:05 +00:00 by forgejo-lila · 0 comments
Owner

Background

Currently, when a player disconnects during an in-progress game,
handleLobbyLeave removes them from the lobby and broadcasts the
updated state. The game continues with remaining players, and the
disconnected player's answers time out each round via the 15s timer.

This is acceptable for the initial slice but has two known gaps:

Gap 1: Single player remaining

If a disconnect leaves only one player in the game, the game should
end immediately and declare that player the winner. Currently the game
continues until all rounds complete, with the remaining player answering
alone.

Gap 2: No reconnection

A disconnected player cannot rejoin an in-progress game. handleLobbyJoin
rejects non-waiting lobbies. When reconnection handling is added, this
check needs to be revisited.

Acceptance criteria

  • If a player disconnects and only one player remains, end the game
    immediately via game:finished with the remaining player as winner.
  • Reconnection: a player who disconnects mid-game can rejoin within
    N seconds and resume from the current question.
  • Reconnecting player receives current game state on rejoin.
  • Timer is not reset when a player reconnects.
  • Reconnection handling slice (future)
  • apps/api/src/ws/handlers/lobbyHandlers.tshandleLobbyLeave
  • apps/api/src/ws/handlers/gameHandlers.ts — game state management
## Background Currently, when a player disconnects during an in-progress game, `handleLobbyLeave` removes them from the lobby and broadcasts the updated state. The game continues with remaining players, and the disconnected player's answers time out each round via the 15s timer. This is acceptable for the initial slice but has two known gaps: ## Gap 1: Single player remaining If a disconnect leaves only one player in the game, the game should end immediately and declare that player the winner. Currently the game continues until all rounds complete, with the remaining player answering alone. ## Gap 2: No reconnection A disconnected player cannot rejoin an in-progress game. `handleLobbyJoin` rejects non-waiting lobbies. When reconnection handling is added, this check needs to be revisited. ## Acceptance criteria - [ ] If a player disconnects and only one player remains, end the game immediately via `game:finished` with the remaining player as winner. - [ ] Reconnection: a player who disconnects mid-game can rejoin within N seconds and resume from the current question. - [ ] Reconnecting player receives current game state on rejoin. - [ ] Timer is not reset when a player reconnects. ## Related - Reconnection handling slice (future) - `apps/api/src/ws/handlers/lobbyHandlers.ts` — `handleLobbyLeave` - `apps/api/src/ws/handlers/gameHandlers.ts` — game state management
forgejo-lila added this to the lila development project 2026-04-17 07:02:05 +00:00
Sign in to join this conversation.
No labels
feature
multiplayer
No milestone
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#5
No description provided.