]> git.cworth.org Git - empires-server/blobdiff - tictactoe.js
game: Index players directly by session ID
[empires-server] / tictactoe.js
index d5a07b25506b79618993ed9ec67befb6ee289936..35019840cc13a68fa225482610876e9c5c3b5932 100644 (file)
@@ -9,13 +9,14 @@ class TicTacToe extends Game {
       board: Array(9).fill(""),
       next_player: "X",
     };
+    this.teams = ["X", "O"];
   }
 
   /* Returns true if move was legal and added, false otherwise. */
   add_move(square) {
     /* Cannot move to an occupied square. */
     if (this.state.board[square])
-      return false;
+      return { legal: false, message: "Square is already occupied" };
 
     this.state.board[square] = this.state.next_player;
     this.state.moves.push(square);
@@ -25,7 +26,7 @@ class TicTacToe extends Game {
     else
       this.state.next_player = "X";
 
-    return true;
+    return { legal: true };
   }
 }