public void Play(char symbol, int x, int y) { //if first move if (_lastSymbol == ' ') { //if player is X if (symbol == 'O') { throw new Exception("Invalid first player"); } } //if not first move but player repeated else if (symbol == _lastSymbol) { throw new Exception("Invalid next player"); } //if not first move but play on an already played tile else if (_board.TileAt(x, y).Symbol != ' ') { throw new Exception("Invalid position"); } // update game state _lastSymbol = symbol; _board.AddTileAt(symbol, x, y); }
public void Play(char symbol, int rowIndex, int columnIndex) { EnsureFirstPlayerIsX(symbol); EnsureCorrectPlayer(symbol); EnsureValidPosition(rowIndex, columnIndex); _lastSymbol = symbol; _board.AddTileAt(symbol, rowIndex, columnIndex); }