Files
battle-royal-tetris/PLAN.md
T
jozamudi e7917a338e Refactor to single global lobby
Changes:
- Removed room-based architecture, now using single global lobby
- Players only need to enter their name to join
- Game starts when all players in lobby are ready (min 2, max 8)
- Simplified UI - no room name field, shows "Global Lobby" header
- Updated all server events to use io.emit instead of io.to(roomName)

Files modified:
- server/index.js: Replaced rooms Map with single lobby object
- public/index.html: Removed room name input, updated button text
- public/js/network.js: Renamed joinRoom/leaveRoom to joinLobby/leaveLobby
- public/js/ui.js: Simplified join flow, removed room name validation
- public/js/app.js: Updated game header to show "GLOBAL LOBBY"
- PLAN.md: Marked all phases as complete
2026-03-20 07:09:51 -07:00

3.4 KiB

Single Global Lobby - Implementation Plan

Context

Changed from room-based architecture to a single global lobby where:

  • No room name input needed
  • All players join the same lobby
  • Player list shows everyone in the lobby
  • Game starts when all players are ready (minimum 2 players)

Phase 1: Server - Replace Rooms with Single Lobby [DONE]

Goal: Remove room-based architecture and use a single global lobby.

Todos

  • Replace rooms Map with single lobby object
  • Change join-room event to join-lobby
    • Remove roomName parameter
    • Only accept playerName
    • Add player to global lobby
  • Update ready event
    • Check if all players in global lobby are ready
    • Start game when all ready (min 2 players, max 8)
  • Update disconnect handling
    • Remove from global lobby
    • Handle game-in-progress disconnections
  • Update all broadcast functions
    • Remove room name parameter
    • Broadcast to all connected clients (io.emit instead of io.to(roomName).emit)

Files modified: server/index.js

Success criteria: Server uses single lobby, no room names needed.


Phase 2: Frontend HTML - Remove Room Name Input [DONE]

Goal: Simplify the login screen to only require player name.

Todos

  • Remove "Room Name" input field from login screen
  • Remove room name label
  • Change button text from "JOIN ROOM" to "JOIN LOBBY"
  • Update lobby screen header
    • Remove room name display
    • Show "Global Lobby" instead

Files modified: public/index.html

Success criteria: Login screen only asks for player name.


Phase 3: Network Module - Update Lobby Methods [DONE]

Goal: Update client-side network methods for single lobby architecture.

Todos

  • Rename joinRoom to joinLobby
    • Remove roomName parameter
    • Emit join-lobby event with just playerName
  • Rename leaveRoom to leaveLobby
    • Remove room name handling
  • Remove currentRoom property (no longer needed)
  • Update all event listeners to work without room names

Files modified: public/js/network.js

Success criteria: Network module works with single lobby.


Phase 4: UI Module - Simplify Join Flow [DONE]

Goal: Update UI handling for simplified lobby flow.

Todos

  • Update handleJoin method
    • Remove roomName input validation
    • Only validate playerName
    • Call network.joinLobby(playerName)
  • Update lobby display
    • Show "Global Lobby" instead of room name
    • Update player list display
  • Update game over "Back to Lobby" flow

Files modified: public/js/ui.js

Success criteria: UI works with single lobby flow.


Phase 5: App Module - Update Event Handling [DONE]

Goal: Update main application to work with global lobby events.

Todos

  • Update network listener setup
    • Adapt to new event structure (no room names)
  • Update game start handling
    • Works with global lobby players
  • Update state sync for single lobby

Files modified: public/js/app.js

Success criteria: Game syncs properly with single lobby.


Verification

  1. Start server: cd server && node index.js
  2. Open http://localhost:3000 in 2+ browser tabs
  3. Enter only your name (no room name field exists)
  4. Click "JOIN LOBBY"
  5. All players should see each other in the same "Global Lobby"
  6. All players click READY
  7. Game starts automatically when all players are ready (minimum 2)