Esempio n. 1
0
        private ICheckersBoard GetCheckrersOnBoard(ICheckersBoard board)
        {
            int numberOfCellsBetweenCheckers = 3;

            if (board.GetDimesionLength(0) % 2 == 0)
            {
                numberOfCellsBetweenCheckers = 2;
            }

            for (int i = (board.GetDimesionLength(0) - numberOfCellsBetweenCheckers) / 2 - 1; i >= 0; i--)
            {
                for (int j = 0; j < board.GetDimesionLength(1); j++)
                {
                    if (board[i, j].Color == CellColor.Red)
                    {
                        board[i, j].CheckerOnCell = new Checker(i, j, CheckerColor.White);
                    }
                }
            }

            for (int i = board.GetDimesionLength(0) - (board.GetDimesionLength(0) - numberOfCellsBetweenCheckers) / 2;
                 i < board.GetDimesionLength(0); i++)
            {
                for (int j = 0; j < board.GetDimesionLength(1); j++)
                {
                    if (board[i, j].Color == CellColor.Red)
                    {
                        board[i, j].CheckerOnCell = new Checker(i, j, CheckerColor.Black);
                    }
                }
            }

            return(board);
        }
Esempio n. 2
0
        private ICheckersBoard ColorCell(ICheckersBoard board)
        {
            for (int i = 0; i < board.GetDimesionLength(0); i++)
            {
                for (int j = 0; j < board.GetDimesionLength(1); j++)
                {
                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0))
                    {
                        board[i, j] = new Cell(CellColor.Red);
                    }
                    else
                    {
                        board[i, j] = new Cell(CellColor.White);
                    }
                }
            }

            return(board);
        }
Esempio n. 3
0
 public static void Print(ICheckersBoard board)
 {
     for (int i = 0; i < board.GetDimesionLength(0); i++)
     {
         for (int j = 0; j < board.GetDimesionLength(1); j++)
         {
             Console.BackgroundColor = ConvertColors.ChangeCellColorIntoConsoleColor(board[i, j].Color);
             if (board[i, j].CheckerOnCell != null)
             {
                 Console.ForegroundColor = ConvertColors.ChangeCheckerColorIntoConsoleColor(board[i, j].CheckerOnCell.CheckerColor);
             }
             else
             {
                 Console.ForegroundColor = Console.BackgroundColor;
             }
             Console.Write("*");
         }
         Console.WriteLine();
     }
     Console.ForegroundColor = ConsoleColor.White;
     Console.BackgroundColor = ConsoleColor.Black;
 }
Esempio n. 4
0
 public FillCkeckersBoard(ICheckersBoard board)
 {
     checkerBoard = board;
 }