summaryrefslogtreecommitdiff
path: root/scripts/client.js
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-08-11 00:03:45 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-08-11 00:03:45 -0400
commitad911d6edd0fa76431284ef6283bb07da45d808d (patch)
tree77ea7c6f18b6b29a0e49b3050bfdc8ae41e6d2e6 /scripts/client.js
parent32a50674868c48c34d35694009f3f1a59e3cf823 (diff)
A few small fixes
Diffstat (limited to 'scripts/client.js')
-rw-r--r--scripts/client.js25
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