X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=tictactoe.js;h=d123c5718f01b5fb93280447d003f91e4eac1e1a;hb=041cdbd90052345df5a05779ada61aec53e403d4;hp=256afecde34d86fd12af215d089c0b6cae9edcee;hpb=fbb338a161c79e0f889a30d8f08058c16583944b;p=lmno-server diff --git a/tictactoe.js b/tictactoe.js index 256afec..d123c57 100644 --- a/tictactoe.js +++ b/tictactoe.js @@ -15,19 +15,12 @@ class TicTacToe extends Game { /* Returns true if move was legal and added, false otherwise. */ add_move(player, square) { - /* Cannot move if you are not on a team. */ - if (player.team === "") - { - return { legal: false, - message: "You must be on a team to take a turn" }; - } + const result = super.add_move(player, square); - /* Cannot move if it's not this player's team's turn. */ - if (player.team !== this.state.team_to_play) - { - return { legal: false, - message: "It's not your turn to move" }; - } + /* If the generic Game class can reject this move, then we don't + * need to look at it any further. */ + if (! result.legal) + return result; /* Cannot move to an occupied square. */ if (this.state.board[square])