e7917a338e
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
122 lines
3.4 KiB
Markdown
122 lines
3.4 KiB
Markdown
# 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
|
|
- [x] Replace `rooms` Map with single `lobby` object
|
|
- [x] Change `join-room` event to `join-lobby`
|
|
- Remove roomName parameter
|
|
- Only accept playerName
|
|
- Add player to global lobby
|
|
- [x] Update `ready` event
|
|
- Check if all players in global lobby are ready
|
|
- Start game when all ready (min 2 players, max 8)
|
|
- [x] Update disconnect handling
|
|
- Remove from global lobby
|
|
- Handle game-in-progress disconnections
|
|
- [x] 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
|
|
- [x] Remove "Room Name" input field from login screen
|
|
- [x] Remove room name label
|
|
- [x] Change button text from "JOIN ROOM" to "JOIN LOBBY"
|
|
- [x] 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
|
|
- [x] Rename `joinRoom` to `joinLobby`
|
|
- Remove roomName parameter
|
|
- Emit `join-lobby` event with just playerName
|
|
- [x] Rename `leaveRoom` to `leaveLobby`
|
|
- Remove room name handling
|
|
- [x] Remove `currentRoom` property (no longer needed)
|
|
- [x] 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
|
|
- [x] Update `handleJoin` method
|
|
- Remove roomName input validation
|
|
- Only validate playerName
|
|
- Call `network.joinLobby(playerName)`
|
|
- [x] Update lobby display
|
|
- Show "Global Lobby" instead of room name
|
|
- Update player list display
|
|
- [x] 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
|
|
- [x] Update network listener setup
|
|
- Adapt to new event structure (no room names)
|
|
- [x] Update game start handling
|
|
- Works with global lobby players
|
|
- [x] 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)
|