From: Carl Worth Date: Mon, 11 May 2020 23:03:54 +0000 (-0700) Subject: Implement a more correct response to /reset X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=528ebf61043635bc939b225ce8e2ff6390cfb8d1;p=empires-server Implement a more correct response to /reset Specifically, we fix things here to clear some internal state that was previously being missed (the "characters_to_reveal" field) and we also fix things to report to the clients the new game state and the emptty list of players. --- diff --git a/server.js b/server.js index 244e6da..b0fc79e 100644 --- a/server.js +++ b/server.js @@ -68,9 +68,14 @@ class Game { this.broadcast_event("player-leave", `{"id": ${id}}`); } - remove_all_players() { + reset() { this._players = []; + this.characters_to_reveal = null; this.next_player_id = 1; + + this.change_state(GameState.JOIN); + + this.broadcast_event("players", "{}"); } reveal_next() { @@ -264,7 +269,7 @@ app.post('/start', (request, response) => { }); app.post('/reset', (request, response) => { - game.remove_all_players(); + game.reset(); response.send(); });