public static BoardCell[,] GetStartPositionBoardCells() { BoardCell[,] chessboard = new BoardCell[8, 8]; int[] startRows = { 0, 1, 6, 7 }; for (int row = 0; row <= 7; row++) { for (int column = 0; column <= 7; column++) { if (!startRows.Any(x => x == row)) { chessboard[row, column] = new BoardCell(row, column); continue; } var chessman = ChessmanFactory.TryToCreateChessmanOnStartPosition(row, column); SetColor(chessman, row); chessboard[row, column] = new BoardCell(row, column, chessman); } } return(chessboard); }
public static void NormilizedBoardCells(BoardCell[,] boardCells) { for (int row = 0; row <= 7; row++) { for (int column = 0; column <= 7; column++) { var chessman = boardCells[row, column].Chessman; if (chessman == null) { continue; } boardCells[row, column].Chessman = ChessmanFactory.TryToCreateChessman(chessman.Color, chessman.Type); } } }
static void ChangeTypeInCasePawnAndPossible( ref BaseChessman chessman, Cell newPosition, ChessmenType?newType) { if (chessman.Type != ChessmenType.Pawn || !((Pawn)chessman).IsLastRow(newPosition.Row)) { return; } if (!newType.HasValue) { throw new ArgumentException("New type should be set"); } if (newType == ChessmenType.Pawn || newType == ChessmenType.King) { throw new ArgumentException("New type can not be Pawn or King"); } chessman = ChessmanFactory.TryToCreateChessman(chessman.Color, newType.Value); }