/* 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])