]> git.cworth.org Git - lmno-server/blobdiff - game.js
Empathy: Reject categories with more than 20 items
[lmno-server] / game.js
diff --git a/game.js b/game.js
index bf74de46105aa62804c17b196c5df2fe4e9d3fd8..86a0e70b96f311dc2133898e679c1afa619406a7 100644 (file)
--- a/game.js
+++ b/game.js
@@ -36,7 +36,8 @@ class Player {
     return JSON.stringify({
       id: this.id,
       name: this.name,
-      team: this.team.name
+      team: this.team.name,
+      score: this.score
     });
   }
 }
@@ -184,7 +185,7 @@ class Game {
 
     /* After adding the player to the list, and if we are already past
      * the first move, assign this player to the first team that
-     * doesn't already have a player aissgned (if any). */
+     * doesn't already have a player assigned (if any). */
     if (! this.first_move) {
       const have_players = Array(this.teams.length).fill(false);
       this.players.forEach(p => {
@@ -224,6 +225,10 @@ class Game {
     this.broadcast_string(`event: ${type}\ndata: ${data}\n`);
   }
 
+  broadcast_event_object(type, obj) {
+    this.broadcast_event(type, JSON.stringify(obj));
+  }
+
   handle_events(request, response) {
     /* These headers will keep the connection open so we can stream events. */
     const headers = {
@@ -306,7 +311,7 @@ class Game {
   }
 
   broadcast_move(move) {
-    this.broadcast_event("move", move);
+    this.broadcast_event("move", JSON.stringify(move));
   }
 
 }