public override void CheckPossibilitiesForProvidedLocationAndMarkThem(IChessboard chessBoard, Position position) { var row = position.Row; var column = position.Column; var startingRow = GetStartingRow(); var forwardOffset = GetForwardOffset(); var positionForward = new Position(row + forwardOffset, column); var positionForwardWest = new Position(row + forwardOffset, column - 1); var positionForwardEast = new Position(row + forwardOffset, column + 1); var positionForwardForward = new Position(row + forwardOffset * 2, column); if (!positionForward.IsOutOfBounds() && chessBoard[positionForward].Piece == null) { ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, positionForward); } if (!positionForwardWest.IsOutOfBounds() && chessBoard[positionForwardWest].Piece != null) { ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, positionForwardWest); } if (!positionForwardEast.IsOutOfBounds() && chessBoard[positionForwardEast].Piece != null) { ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, positionForwardEast); } if (row == startingRow && !positionForwardForward.IsOutOfBounds() && chessBoard[positionForward].Piece == null && chessBoard[positionForwardForward].Piece == null) { ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, positionForwardForward); } }
public override void CheckPossibilitiesForProvidedLocationAndMarkThem(IChessboard chessBoard, Position position) { var row = position.Row; var column = position.Column; var destinationNorthNorthEast = new Position(row + 2, column + 1); var destinationSouthSouthEast = new Position(row - 2, column + 1); var destinationNorthEastEast = new Position(row + 1, column + 2); var destinationSouthEastEast = new Position(row - 1, column + 2); var destinationNorthNorthWest = new Position(row + 2, column - 1); var destinationSouthSouthWest = new Position(row - 2, column - 1); var destinationNorthWestWest = new Position(row + 1, column - 2); var destinationSouthWestWest = new Position(row - 1, column - 2); ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, destinationNorthNorthEast); ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, destinationSouthSouthEast); ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, destinationNorthEastEast); ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, destinationSouthEastEast); ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, destinationNorthNorthWest); ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, destinationSouthSouthWest); ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, destinationNorthWestWest); ChessboardAccessibleBoxesHelper.MarkIfAccessible(chessBoard, position, destinationSouthWestWest); }