X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=tictactoe.js;fp=tictactoe.js;h=256afecde34d86fd12af215d089c0b6cae9edcee;hb=fbb338a161c79e0f889a30d8f08058c16583944b;hp=f9198432826376426d5d5a527e145bfe71f9e172;hpb=92382a8dd4bfc9c83b7cf5fa1c0981b01096efd0;p=empires-server diff --git a/tictactoe.js b/tictactoe.js index f919843..256afec 100644 --- a/tictactoe.js +++ b/tictactoe.js @@ -7,7 +7,7 @@ class TicTacToe extends Game { this.state = { moves: [], board: Array(9).fill(""), - next_player: "X", + team_to_play: "X", }; this.teams = ["X", "O"]; } @@ -23,7 +23,7 @@ class TicTacToe extends Game { } /* Cannot move if it's not this player's team's turn. */ - if (player.team !== this.state.next_player) + if (player.team !== this.state.team_to_play) { return { legal: false, message: "It's not your turn to move" }; @@ -36,13 +36,13 @@ class TicTacToe extends Game { message: "Square is already occupied" }; } - this.state.board[square] = this.state.next_player; + this.state.board[square] = this.state.team_to_play; this.state.moves.push(square); - if (this.state.next_player === "X") - this.state.next_player = "O"; + if (this.state.team_to_play === "X") + this.state.team_to_play = "O"; else - this.state.next_player = "X"; + this.state.team_to_play = "X"; return { legal: true }; }