X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=tictactoe.js;h=da55c9f48e42c663f3e4016acaf6f4f083f15061;hb=ee64666099c0401afdc1e51fe378359f943d3f69;hp=a60eed600c9bdccde3736d56bf2b988dd1a9e892;hpb=f27cdf8b57b41a91dd7ab67be407d803dcaad1a3;p=empires-server diff --git a/tictactoe.js b/tictactoe.js index a60eed6..da55c9f 100644 --- a/tictactoe.js +++ b/tictactoe.js @@ -11,11 +11,11 @@ class TicTacToe extends Game { }; } - /* Returns Boolean indicating whether move was legal and added. */ + /* 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 +25,7 @@ class TicTacToe extends Game { else this.state.next_player = "X"; - return true; + return { legal: true }; } }