diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2022-08-11 00:03:45 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2022-08-11 00:03:45 -0400 |
commit | ad911d6edd0fa76431284ef6283bb07da45d808d (patch) | |
tree | 77ea7c6f18b6b29a0e49b3050bfdc8ae41e6d2e6 /scripts/client.js | |
parent | 32a50674868c48c34d35694009f3f1a59e3cf823 (diff) |
A few small fixes
Diffstat (limited to 'scripts/client.js')
-rw-r--r-- | scripts/client.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/scripts/client.js b/scripts/client.js index ffba4b5..815d4f2 100644 --- a/scripts/client.js +++ b/scripts/client.js @@ -171,23 +171,32 @@ class Client{ { let m = e.detail; - if(m.type === "nojoin") { + switch (m.type) { + case "nojoin": alert(`Failed to join game. ${m.data}`); - } else if (m.type === "join") { - this.table.openTable(); - this.lobby.setState("In Game", "ok", this.socket.server) - this.inGame = true; - } else if (m.type === "leave") { + break; + case "leave": this.table.reset(); if (this.game.id !== m.data) { this.lobby.setState("Joining...", "loading", this.socket.server); this.socket.send("join", this.game); + } else { + this.lobby.setState("Connected", "ok", this.socket.server); } this.inGame = false; - } else if (TABLE_RPC.includes(m.type)) - this.table[m.type](m.data); + break; + case "join": + this.table.openTable(); + this.lobby.setState("In Game", "ok", this.socket.server); + this.inGame = true; + break; + default: + if (TABLE_RPC.includes(m.type) && this.inGame) + this.table[m.type](m.data); + break; + } } // Callback when a chat event is recieved from the server |