// current player performs a move public void DoMove(IGameMove move) { TicTacToeGameMove tttMove = new TicTacToeGameMove(move, this); if (move < 0 || move > board.Length || board[move] != 0) { throw new ArgumentException("Wrong Move!"); } _stateChanged = false; board[move] = currentPlayer; no_moves--; _stateChanged = true; if (CheckWinDirections(currentPlayer, tttMove.GetX, tttMove.GetY)) { // there is a winner _winner = currentPlayer; } else if (no_moves == 0) { // otherwise if there are no more moves there is a tie _winner = 0; } this.playerJustMoved = this.currentPlayer; this.currentPlayer = 3 - this.currentPlayer; }
public override bool Equals(object obj) { if (obj is TicTacToeGameMove) { TicTacToeGameMove gMove = obj as TicTacToeGameMove; return(gMove.x == x && gMove.y == y); } return(false); }