X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=tictactoe.js;h=8efc70f8e791fe20d1aa68233667516a52ed5af0;hb=8adcf9df208ac8d303706f89d359f69bbdc0a7a2;hp=f9b357bf3202dfbc84443818dbd3626958e5f307;hpb=4a744b0425333284979ef76206c457ff7dcf5907;p=lmno-server diff --git a/tictactoe.js b/tictactoe.js index f9b357b..8efc70f 100644 --- a/tictactoe.js +++ b/tictactoe.js @@ -8,6 +8,7 @@ class TicTacToe extends Game { super(id); this.moves = []; this.board = Array(9).fill(""); + this.next_player = "X"; } /* Returns Boolean indicating whether move was legal and added. */ @@ -16,9 +17,14 @@ class TicTacToe extends Game { if (this.board[square]) return false; - this.board[square] = 'X'; + this.board[square] = this.next_player; this.moves.push(square); + if (this.next_player === "X") + this.next_player = "O"; + else + this.next_player = "X"; + return true; }