diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2022-08-11 21:29:26 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2022-08-11 21:29:26 -0400 |
commit | 4efae60183feb616c3dec7698a6a2fe4351b71c7 (patch) | |
tree | 50b193121005f499082e650bd01fd1524e9196f3 /scripts | |
parent | 022950ff4989d6394d193a23de8c91ee4e17fc4d (diff) |
History fixes
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/client.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/client.js b/scripts/client.js index d895bbd..d5a9616 100644 --- a/scripts/client.js +++ b/scripts/client.js @@ -44,7 +44,7 @@ class Client{ constructor (s, g, p) { - window.history.onpopstate = this.stateChange.bind(this); + window.onpopstate = this.stateChange.bind(this); this.socket = new SockWorker(s, VERSION); this.socket.addEventListener("error", this.socketError.bind(this)); @@ -136,6 +136,7 @@ class Client{ } this.gameOptions = new Settings(m.data.game); this.gameOptions.addEventListener("click", ((e) => { + this.lobby.newGame(); if(e.detail == "new") this.socket.send("create", this.gameOptions.getSettings()); }).bind(this)); @@ -176,7 +177,7 @@ class Client{ alert(`Failed to join game. ${m.data}`); break; case "leave": - if (this.game.id !== m.data) { + if (this.game.id !== m.data && this.game.id != null) { this.lobby.setState("Joining...", "loading", this.socket.server); this.socket.send("join", this.game); } else { @@ -248,9 +249,8 @@ class Client{ } stateChange(e) { - if (e.state.id != null) { - this.game = e.state; - } + this.table.reset(); + this.game = e.state; if (this.inGame) { this.leaveGame(); |