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);
                }
            }
        }
Example #2
0
        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);
        }