Add unready toggle in lobby
- Server: Handle unready event to set player ready state to false - Client: Ready button toggles between READY and UNREADY - Client: Unready sends unready socket event to server Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -62,10 +62,10 @@
|
||||
</div>
|
||||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="js/network.js?v=5"></script>
|
||||
<script src="js/network.js?v=6"></script>
|
||||
<script src="js/game.js?v=4"></script>
|
||||
<script src="js/renderer.js?v=5"></script>
|
||||
<script src="js/ui.js?v=5"></script>
|
||||
<script src="js/ui.js?v=6"></script>
|
||||
<script src="js/app.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -110,6 +110,11 @@ class NetworkManager {
|
||||
this.socket.emit('ready');
|
||||
}
|
||||
|
||||
unready() {
|
||||
if (!this.socket) return;
|
||||
this.socket.emit('unready');
|
||||
}
|
||||
|
||||
sendMove(direction) {
|
||||
if (!this.socket || !this.currentPlayerId) return;
|
||||
this.socket.emit('player-move', { playerId: this.currentPlayerId, direction });
|
||||
|
||||
+9
-3
@@ -62,9 +62,15 @@ class UIManager {
|
||||
}
|
||||
|
||||
handleReady() {
|
||||
network.ready();
|
||||
this.buttons.ready.textContent = 'READY!';
|
||||
this.buttons.ready.disabled = true;
|
||||
if (this.buttons.ready.textContent === 'READY') {
|
||||
network.ready();
|
||||
this.buttons.ready.textContent = 'UNREADY';
|
||||
this.buttons.ready.disabled = false;
|
||||
} else {
|
||||
network.unready();
|
||||
this.buttons.ready.textContent = 'READY';
|
||||
this.buttons.ready.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
handleLeave() {
|
||||
|
||||
Reference in New Issue
Block a user