Exemplo n.º 1
0
        void Start()
        {
            ChessGame chessGame = new ChessGame();

            ChessPiece[,] chessboard = chessGame.CreateChessboard();
            chessGame.InitChessboard(chessboard);
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("CONSOLE CHESS V1.1\n");
            Console.ResetColor();
            DisplayChessboard(chessboard);
            PlayChess(chessboard, chessGame);
        }
Exemplo n.º 2
0
        void PlayChess(ChessPiece[,] chessboard, ChessGame chessGame)
        {
            int move = 1;

            while (chessGame.GameCheck(chessboard, move))
            {
                Turn turn = chessGame.DetermineTurn(move);
                Console.WriteLine($"{turn}'s turn");
                Position fromPos = ReadPosition("Enter 'from' position: ");
                Position toPos   = ReadPosition("Enter 'to' position: ");
                try
                {
                    chessGame.CheckMove(chessboard, fromPos, toPos, turn);
                    chessGame.DoMove(chessboard, fromPos, toPos);
                    move++;
                    DisplayChessboard(chessboard);
                    DisplayEliminatedPieces(chessGame);
                }
                catch (Exception error)
                {
                    Console.WriteLine(error.Message);
                }
            }
        }
Exemplo n.º 3
0
 void DisplayEliminatedPieces(ChessGame chessGame)
 {
     Console.WriteLine(chessGame.deadWhite);
     Console.WriteLine(chessGame.deadBlack);
 }