Example #1
0
        public static void ViewGame(ChessRound chessRound)
        {
            ViewBoard(chessRound.board);
            PrintCapturedPieces(chessRound);

            if (!chessRound.finished)
            {
                Console.WriteLine($" Turno: {chessRound.round}");
                Console.Write(" Turno de : ");
                ConsoleColor aux = Console.ForegroundColor;
                if (chessRound.player == Color.Black)
                {
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                }
                Console.WriteLine(chessRound.player);
                Console.ForegroundColor = aux;
                if (chessRound.check)
                {
                    Console.WriteLine(" XEQUE!");
                }
            }
            else
            {
                Console.WriteLine("XEQUE-MATE!!!");
                Console.WriteLine($"Vencedor: {chessRound.player}");
            }
        }
Example #2
0
        public static void PrintCapturedPieces(ChessRound round)
        {
            Console.WriteLine(" -------------------------------");
            Console.WriteLine(" Peças capturadas");
            Console.Write(" Brancas: ");
            PrintSet(round.CapturedPieces(Color.White));
            ConsoleColor aux = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.Write("\n Pretas: ");
            Console.ForegroundColor = aux;
            PrintSet(round.CapturedPieces(Color.Black));
            Console.WriteLine(" \n -------------------------------");
        }
Example #3
0
        static void Main(string[] args)
        {
            ChessRound chessRound = new ChessRound();

            while (!chessRound.finished)
            {
                try
                {
                    Console.Clear();
                    View.ViewGame(chessRound);

                    Console.Write(" Peça de origem: ");

                    Position origin = View.ReadChessPosition().ToPosition();
                    chessRound.ValidOriginPosition(origin);



                    bool[,] possibleMoves = chessRound.board.Piece(origin).PossibleMoves();
                    Console.Clear();
                    View.ViewBoard(chessRound.board, possibleMoves);

                    Console.WriteLine(" -------------------------------");
                    Console.Write(" Peça de destino: ");
                    Position destiny = View.ReadChessPosition().ToPosition();
                    chessRound.ValidDestinyPosition(origin, destiny);

                    chessRound.PlayRound(origin, destiny);
                }
                catch (BoardException e)
                {
                    ConsoleColor aux = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine(e.Message);
                    Console.ForegroundColor = aux;
                    Console.ReadLine();
                }
            }
            Console.Clear();
            View.ViewGame(chessRound);
        }