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
This commit is contained in:
+5
-12
@@ -10,7 +10,6 @@ class UIManager {
|
||||
};
|
||||
|
||||
this.inputs = {
|
||||
roomName: document.getElementById('room-name'),
|
||||
playerName: document.getElementById('player-name')
|
||||
};
|
||||
|
||||
@@ -22,7 +21,6 @@ class UIManager {
|
||||
};
|
||||
|
||||
this.displays = {
|
||||
lobbyRoomName: document.getElementById('lobby-room-name'),
|
||||
gameRoomName: document.getElementById('game-room-name'),
|
||||
playerList: document.getElementById('player-list'),
|
||||
battleGrid: document.getElementById('battle-grid'),
|
||||
@@ -41,9 +39,6 @@ class UIManager {
|
||||
this.buttons.backToLobby.addEventListener('click', () => this.handleBackToLobby());
|
||||
|
||||
// Allow Enter key to submit forms
|
||||
this.inputs.roomName.addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') this.handleJoin();
|
||||
});
|
||||
this.inputs.playerName.addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') this.handleJoin();
|
||||
});
|
||||
@@ -55,21 +50,19 @@ class UIManager {
|
||||
}
|
||||
|
||||
handleJoin() {
|
||||
const roomName = this.inputs.roomName.value.trim();
|
||||
const playerName = this.inputs.playerName.value.trim();
|
||||
|
||||
if (!roomName || !playerName) {
|
||||
this.showMessage('Please enter room name and your name');
|
||||
if (!playerName) {
|
||||
this.showMessage('Please enter your name');
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit join event
|
||||
// Set listener for player joined event
|
||||
network.setListener('player-joined', () => {
|
||||
this.showScreen('lobby');
|
||||
this.displays.lobbyRoomName.textContent = roomName;
|
||||
});
|
||||
|
||||
network.joinRoom(roomName, playerName);
|
||||
network.joinLobby(playerName);
|
||||
}
|
||||
|
||||
handleReady() {
|
||||
@@ -79,7 +72,7 @@ class UIManager {
|
||||
}
|
||||
|
||||
handleLeave() {
|
||||
network.leaveRoom();
|
||||
network.leaveLobby();
|
||||
this.showScreen('room');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user