]> git.cworth.org Git - empires-server/commitdiff
Perform broadcasts of deregister and capture events
authorCarl Worth <cworth@cworth.org>
Mon, 4 May 2020 00:34:23 +0000 (17:34 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 4 May 2020 00:34:23 +0000 (17:34 -0700)
Allowing clients to track this state

server.js

index bbc5d8aaea831c7b90b4a98c765b3d47b0d0f5ff..d08011c864966f84dc6cc10e62402d352127d77a 100644 (file)
--- a/server.js
+++ b/server.js
@@ -31,6 +31,8 @@ class Game {
   remove_player(id) {
     const index = this._players.findIndex(player => player.id === id);
     this._players.splice(index, 1);
+
+    this.broadcast("player-deregister", `{"id": ${id}}`);
   }
 
   remove_all_players() {
@@ -44,6 +46,8 @@ class Game {
      * the API specification which we want here. */
     let captor = this._players.find(player => player.id === captor_id);
     captor.captures.push(captee_id);
+
+    this.broadcast("capture", `{"captor": ${captor_id}, "captee": ${captee_id}}`);
   }
 
   liberate(captee_id) {