]> git.cworth.org Git - empires-server/commitdiff
Properly JSON-stingify move before broadcasting it
authorCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 15:47:27 +0000 (08:47 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 15:47:27 +0000 (08:47 -0700)
With the Tic Tac Toe game, this bug was hidden, (since the move data
is just an integer and there's no difference in strignifying that or
not). But an upcoming game (Scribe) uses a pair of integers, and
there's a lot of difference between "1,2" and "[1,2]" since only the
latter is proper JSON.

game.js

diff --git a/game.js b/game.js
index bf74de46105aa62804c17b196c5df2fe4e9d3fd8..eb78f31ecbe531a38801cbbb9b4a466eb968d8cc 100644 (file)
--- a/game.js
+++ b/game.js
@@ -306,7 +306,7 @@ class Game {
   }
 
   broadcast_move(move) {
-    this.broadcast_event("move", move);
+    this.broadcast_event("move", JSON.stringify(move));
   }
 
 }