예제 #1
0
        /* public IFigure RevivalNewFigure() Probably not on place. Should be in pawns and controller
         * {
         *   ConsoleIO.WriteConsole("Queen: 1   ");
         *   ConsoleIO.WriteConsole("Knight: 2  ");
         *   ConsoleIO.WriteConsole("Rook: 3    ");
         *   ConsoleIO.WriteConsole("Bishop: 4  ");
         *
         *   int choiseFigureUser = int.Parse(ConsoleIO.ReadFromConsole());
         *
         *   IFigure figure = null;
         *   switch (choiseFigureUser)
         *   {
         *       case 1:
         *           figure = new Queen();
         *           break;
         *       case 2:
         *           figure = new Knight();
         *           break;
         *       case 3:
         *           figure = new Rook();
         *           break;
         *       case 4:
         *          // figure = new Bishop();
         *           break;
         *   }
         *
         *   return figure;
         * } */

        public void DrawBoard(Board board)
        {
            ConsoleIO.ClearConsole();
            int countSpacePaip = CountSpacePaipDrawBoard;

            ConsoleIO.WriteLineConsole(string.Empty);

            int row = 0;
            int num = board.BoardSize;

            // print boxes rows
            for (int col = 0; col < board.BoardSize; col++)
            {
                DrawBox(countSpacePaip, row, num, board);
                row++;
                num--;
            }

            // print labels
            int countSpace = StartCountSpaces;

            for (char symbol = 'a'; symbol <= 'h'; symbol++)
            {
                ConsoleIO.SetCursorPositionConsole(countSpace, WidthCursorPositionDrawFigures);
                ConsoleIO.WriteConsole(symbol);
                countSpace += IncrementFiguresPosition;
            }

            //print names  and figs taken of players
            ConsoleIO.SetCursorPositionConsole(countSpace, WidthCursorPositionDrawFigures);
            ConsoleIO.WriteConsole(board.FirstPlayer.Name);
            if (board.FirstPlayer.FiguresTaken.Count > 0)
            {
                ConsoleIO.SetCursorPositionConsole(countSpace, WidthCursorPositionDrawFigures + 1);
                ConsoleIO.ConsoleForegroundColor((ConsoleColor)board.SecondPlayer.Color);
                ConsoleIO.WriteConsole("Figs:");
                foreach (var fig in board.FirstPlayer.FiguresTaken)
                {
                    ConsoleIO.WriteConsole(fig + " ");
                }
                Console.ForegroundColor = ConsoleColor.White;
            }

            ConsoleIO.SetCursorPositionConsole(countSpace, 1);
            ConsoleIO.WriteConsole(board.SecondPlayer.Name);
            if (board.SecondPlayer.FiguresTaken.Count > 0)
            {
                ConsoleIO.SetCursorPositionConsole(countSpace, 2);
                ConsoleIO.ConsoleForegroundColor((ConsoleColor)board.FirstPlayer.Color);
                ConsoleIO.WriteConsole("Figs:");
                foreach (var fig in board.SecondPlayer.FiguresTaken)
                {
                    ConsoleIO.WriteConsole(fig + " ");
                }
                Console.ForegroundColor = ConsoleColor.White;
            }

            this.PrintFiguresOfPlayer(board.FirstPlayer, 0);
            this.PrintFiguresOfPlayer(board.SecondPlayer, 1);
        }