Add debug logging and fix registerPlayer UI feedback

This commit is contained in:
2025-12-13 20:55:30 +11:00
parent b57611f0c4
commit 831aa0856d
2 changed files with 9 additions and 3 deletions

View File

@@ -201,17 +201,21 @@ class MultiplayerClient {
modal.classList.remove('active');
}
// Show loading state if connecting
// Show loading state
const loading = document.querySelector('.loading');
if (loading && !this.socket) {
loading.textContent = 'Connecting to server...';
if (loading) {
loading.textContent = 'Registering...';
}
if (!this.socket || !this.socket.connected) {
console.log('Socket not ready yet, username saved and will be sent on connect.');
if (loading) {
loading.textContent = 'Connecting to server...';
}
return;
}
console.log('Emitting register_player for:', username);
this.socket.emit('register_player', { username });
}