Exemple #1
0
        public static void printMatch(ChessMatch match)
        {
            Console.WriteLine("The White Pieces is the Green Pieces");
            Console.WriteLine("The Black Pieces is the Yellow Pieces");
            Console.WriteLine();

            Screen.printBoard(match.board);
            Console.WriteLine();
            printCapturedPieces(match);
            Console.WriteLine();
            Console.Write(" TURN: " + match.Turn);
            if (!match.Finishe)
            {
                Console.WriteLine(" WAITING FOR MOVE " + match.Player);
                if (match.Check)
                {
                    Console.WriteLine("Check!");
                }
            }
            else
            {
                Console.WriteLine("CHECKMATE");
                Console.WriteLine("WINNER: " + match.Player);
            }
        }
Exemple #2
0
        public static void PrintMatch(ChessMatch match)
        {
            PrintBoard(match.BoardOfMatch);

            Console.WriteLine();

            PrintTakenPieces(match);

            Console.WriteLine();

            Console.WriteLine("Turn: " + match.Turn);
            Console.WriteLine("Waiting For: " + match.ActualPlayer);

            if (!match.Ended)
            {
                if (match.Check)
                {
                    Console.WriteLine(match.ActualPlayer + ": You are under Check!");
                }
            }
            else
            {
                Console.WriteLine("Checkmate!");
                Console.WriteLine("Winner: " + match.ActualPlayer);
            }
        }
Exemple #3
0
 public static void printCapturedPieces(ChessMatch match)
 {
     Console.WriteLine("Captured Pieces");
     Console.Write("Whites: ");
     printSet(match.piecesCaptured(Color.White));
     Console.WriteLine();
     Console.Write("Blacks: ");
     printSet(match.piecesCaptured(Color.Black));
 }
Exemple #4
0
        static void Main(string[] args)
        {
            ChessMatch        chessMatch     = new ChessMatch();
            List <ChessPiece> capturedPieces = new List <ChessPiece>();

            while (!chessMatch.CheckMate)
            {
                try
                {
                    Console.Clear();
                    UI.PrintMatch(chessMatch, capturedPieces);
                    Console.Write("\nSource: ");
                    ChessPosition source = UI.ReadChessPosition();
                    bool[,] possibleMoves = chessMatch.PossibleMoves(source);
                    Console.Clear();
                    UI.PrintBoard(chessMatch.MakeChessPieces(), possibleMoves);
                    Console.Write("\nTarget: ");
                    ChessPosition target = UI.ReadChessPosition();

                    ChessPiece capturedPiece = chessMatch.PerformChessMove(source, target);
                    if (capturedPiece != null)
                    {
                        capturedPieces.Add(capturedPiece);
                    }

                    if (chessMatch.Promoted != null)
                    {
                        Console.Write("Enter piece for promotion (B/N/R/Q): ");
                        string type = Console.ReadLine().ToUpper();
                        while (!type.Equals("B") && !type.Equals("N") && !type.Equals("R") && !type.Equals("Q"))
                        {
                            Console.Write("Invalid value! Enter piece for promotion (B/N/R/Q): ");
                            type = Console.ReadLine().ToUpper();
                        }
                        chessMatch.ReplacePromotedPiece(type);
                    }
                } catch (ChessException e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadLine();
                } catch (ArgumentException e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadLine();
                } catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadLine();
                }
            }
            Console.Clear();
            UI.PrintMatch(chessMatch, capturedPieces);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            try
            {
                ChessMatch match = new ChessMatch();


                while (!match.Finishe)
                {
                    try
                    {
                        Console.Clear();
                        Screen.printMatch(match);



                        Console.WriteLine();
                        Console.Write("ORIGIN: ");
                        Position origin = Screen.readPositionChess().toPosition();
                        match.validPositionOrigin(origin);
                        bool[,] positionsPossibles = match.board.piece(origin).possibleMoviments();

                        Console.Clear();
                        Screen.printBoard(match.board, positionsPossibles);

                        Console.WriteLine();
                        Console.Write("Destiny: ");
                        Position destiny = Screen.readPositionChess().toPosition();
                        match.validPositionDestiny(origin, destiny);

                        match.makeMove(origin, destiny);
                    }
                    catch (BoardException e)
                    {
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }
                }



                Console.Clear();
                Screen.printMatch(match);

                //Screen.printBoard(match.board);
            }
            catch (BoardException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #6
0
        private static void PrintCapturedPieces(ChessMatch match)
        {
            Console.WriteLine("Captured Pieces: ");
            Console.Write("White: ");
            PrintSet(match.CapturedPieces(Color.White));
            Console.WriteLine();
            Console.Write("Black: ");
            ConsoleColor defaultColor = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Yellow;
            PrintSet(match.CapturedPieces(Color.Black));
            Console.ForegroundColor = defaultColor;
            Console.WriteLine();
        }
Exemple #7
0
        public static void PrintCapturedPieces(ChessMatch match)
        {
            Console.WriteLine("Peças capturadas:");
            Console.Write("Brancas: ");
            PrintSet(match.CapturedPieces(Color.White));
            Console.WriteLine();
            Console.Write("Pretas: ");
            ConsoleColor aux = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Yellow;
            PrintSet(match.CapturedPieces(Color.Black));
            Console.ForegroundColor = aux;
            Console.WriteLine();
        }
Exemple #8
0
        public static void printCapturedPieces(ChessMatch match)
        {
            Console.WriteLine("Captured pieces:");
            Console.Write("White: ");
            printSet(match.capturedPieces(Color.White));
            Console.WriteLine();
            Console.Write("Black: ");
            ConsoleColor aux = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Yellow;
            printSet(match.capturedPieces(Color.Black));
            Console.ForegroundColor = aux;
            Console.WriteLine();
            Console.WriteLine();
        }
Exemple #9
0
        private void StartGame_Click(object sender, EventArgs e)
        {
            match            = new ChessMatch();
            selectedRow      = -1;
            selectedCol      = -1;
            targetRow        = -1;
            targetCol        = -1;
            pieceSelected    = false;
            PlayerLabel.Text = "White to move";

            BlackCapturedBox.Image = match.GenerateCapturedImage(false);
            WhiteCapturedBox.Image = match.GenerateCapturedImage(true);

            BoardImage.Image = match.GenerateBoardImage();
        }
Exemple #10
0
        static void Main(string[] args)
        {
            try
            {
                ChessMatch match = new ChessMatch();

                while (!match.Ended)
                {
                    try
                    {
                        Console.Clear();
                        Screen.PrintMatch(match);

                        Console.WriteLine();

                        Console.Write("Origin: ");
                        Position origin = Screen.ReadChessPosition().ToPosition();

                        match.ValidateOriginPosition(origin);

                        bool[,] possiblePositions = match.BoardOfMatch.UniquePiece(origin).PossibleMoviments();

                        Console.Clear();
                        Screen.PrintBoard(match.BoardOfMatch, possiblePositions);

                        Console.WriteLine();
                        Console.Write("Destiny: ");
                        Position destiny = Screen.ReadChessPosition().ToPosition();
                        match.ValidateDestinyPosition(origin, destiny);

                        match.PerformPlay(origin, destiny);
                    } catch (BoardException e)
                    {
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }
                }
                Console.Clear();
                Screen.PrintMatch(match);
            }
            catch (BoardException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }
Exemple #11
0
        static void Main(string[] args)
        {
            try
            {
                ChessMatch match = new ChessMatch();

                while (!match.EndedMatch)
                {
                    try
                    {
                        Console.Clear();
                        Console.WriteLine("User Guide: K-King; B-Bishop; H-Knight; R-Rook; Q-Queen; P-Pawn");
                        Screen.PrintMatch(match);

                        Console.WriteLine();
                        Console.Write("Origin: ");
                        Position origin = Screen.ReadChessPosition().ToPosition();
                        match.ValidateOriginPosition(origin);

                        bool[,] possiblePositions = match.Board.Piece(origin).PossibleMovements();

                        Console.Clear();
                        Screen.PrintBoard(match.Board, possiblePositions);

                        Console.WriteLine();
                        Console.Write("Destination: ");
                        Position destination = Screen.ReadChessPosition().ToPosition();
                        match.ValidateDestinationPosition(origin, destination);

                        match.PerformMovement(origin, destination);
                    }
                    catch (BoardException exception)
                    {
                        Console.WriteLine(exception.Message);
                        Console.WriteLine("Press Enter to continue...");
                        Console.ReadLine();
                    }
                }
                Console.Clear();
                Screen.PrintMatch(match);
            }
            catch (BoardException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Exemple #12
0
        static void Main(string[] args)
        {
            try
            {
                ChessMatch match = new ChessMatch();

                while (!match.finished)
                {
                    try
                    {
                        Console.Clear();
                        Screen.printMatch(match);

                        Console.Write("Origin: ");
                        Position origin = Screen.readChessPosition().toPosition();
                        match.validateOriginPosition(origin);

                        bool[,] possiblePositions = match.chessboard.piece(origin).possibleMoves();
                        Screen.printBoard(match.chessboard, possiblePositions);

                        Console.Write("Destiny: ");
                        Position destiny = Screen.readChessPosition().toPosition();
                        match.validateDestinyPosition(origin, destiny);

                        match.performMove(origin, destiny);
                    }
                    catch (BoardException e)
                    {
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }
                }

                Console.Clear();
                Screen.printMatch(match);
            }
            catch (BoardException e)
            {
                Console.WriteLine(e.Message);
            }


            Console.ReadLine();
        }
Exemple #13
0
 public static void PrintMatch(ChessMatch chessMatch, List <ChessPiece> captured)
 {
     PrintBoard(chessMatch.MakeChessPieces());
     PrintCapturedPieces(captured);
     Console.WriteLine("\nTurn: " + chessMatch.Turn);
     if (!chessMatch.CheckMate)
     {
         Console.WriteLine("Waiting Player: " + chessMatch.CurrentPlayer);
         if (chessMatch.Check)
         {
             Console.WriteLine("CHECK!");
         }
     }
     else
     {
         Console.WriteLine("CHECKMATE!");
         Console.WriteLine("Winner: " + chessMatch.CurrentPlayer);
     }
 }
Exemple #14
0
 public static void PrintMatch(ChessMatch match)
 {
     PrintBoard(match.Board);
     Console.WriteLine();
     PrintCapturedPieces(match);
     Console.WriteLine();
     Console.WriteLine("Turno: " + match.Turn);
     if (!match.Ended)
     {
         Console.WriteLine("Aguardando: " + (match.Player == Color.White ? "Branca" : "Preta"));
         if (match.Check)
         {
             Console.WriteLine("XEQUE!");
         }
     }
     else
     {
         Console.WriteLine("XEQUE-MATE!");
         Console.WriteLine("Vecedor: " + (match.Player == Color.White ? "Branca" : "Preta"));
     }
 }
Exemple #15
0
        public static void printMatch(ChessMatch match)
        {
            printBoard(match.chessboard);
            Console.WriteLine();
            printCapturedPieces(match);
            Console.WriteLine("Round: " + match.round);

            if (!match.finished)
            {
                Console.WriteLine("Waiting for " + match.currentPlayer + " to play");
                if (match.check)
                {
                    Console.WriteLine("CHECK!");
                }
            }
            else
            {
                Console.WriteLine("CHECKMATE");
                Console.WriteLine(match.currentPlayer + " player win!");
            }
        }
Exemple #16
0
        public static void PrintMatch(ChessMatch match)
        {
            Screen.PrintBoard(match.Board);
            Console.WriteLine();
            PrintCapturedPieces(match);
            Console.WriteLine();
            Console.WriteLine("Turn: " + match.Turn);

            if (!match.EndedMatch)
            {
                Console.WriteLine("Waiting for movement: " + match.ActualPlayer);
                if (match.Check)
                {
                    Console.WriteLine("Check!");
                }
            }
            else
            {
                Console.WriteLine("Checkmate!");
                Console.WriteLine("Winner: " + match.ActualPlayer);
            }
        }
Exemple #17
0
        public static void PrintTakenPieces(ChessMatch match)
        {
            ConsoleColor aux = Console.ForegroundColor;

            Console.WriteLine("Taken Pieces: ");

            Console.Write("White: ");

            Console.ForegroundColor = ConsoleColor.Red;

            PrintArray(match.CapturedPiecesOfTeam(Color.White));

            Console.ForegroundColor = aux;

            Console.Write("Black: ");

            Console.ForegroundColor = ConsoleColor.Cyan;

            PrintArray(match.CapturedPiecesOfTeam(Color.Black));

            Console.ForegroundColor = aux;
        }
Exemple #18
0
        static void Main(string[] args)
        {
            try {
                ChessMatch Match = new ChessMatch();

                while (!Match.Ended)
                {
                    try {
                        Console.Clear();
                        Screen.PrintMatch(Match);

                        Console.WriteLine();
                        Console.Write("Origem: ");
                        Position origin = Screen.ReadPosition().ConvertPosition();
                        Match.ValidOriginPosition(origin);

                        bool[,] possibleMoves = Match.Board.Piece(origin).PossibleMoves();

                        Console.Clear();
                        Screen.PrintBoard(Match.Board, possibleMoves);

                        Console.WriteLine();
                        Console.Write("Destino: ");
                        Position destiny = Screen.ReadPosition().ConvertPosition();
                        Match.ValidDestinyPosition(origin, destiny);
                        Match.MakePlay(origin, destiny);
                    } catch (BoardException e) {
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }
                }
                Console.Clear();
                Screen.PrintMatch(Match);
            }  catch (BoardException e) {
                Console.WriteLine(e.Message);
            }
        }
Exemple #19
0
 public King(Board board, Collor collor, ChessMatch match) : base(collor, board)
 {
     this.match = match;
 }
Exemple #20
0
 public King(Board board, Color color, ChessMatch match) : base(board, color)
 {
     _match = match;
 }
Exemple #21
0
 public Pawn(Board board, Color color, ChessMatch match) : base(board, color)
 {
     Match = match;
 }
Exemple #22
0
 public Pawn(PieceColor color, Board board, ChessMatch chessMatch) : base(color, board)
 {
     this.chessMatch = chessMatch;
 }
Exemple #23
0
 public Pawn(ChessBoard board, Color color, ChessMatch match) : base(board, color)
 {
     this.match = match;
 }
Exemple #24
0
 public King(Gameboard gameboard, Color color, ChessMatch match) : base(gameboard, color)
 {
     this.match = match;
 }
Exemple #25
0
 public King(Board board, Color color, ChessMatch chessMatch) : base(board, color)
 {
     ChessMatch = chessMatch;
 }
Exemple #26
0
        //Constructor

        // @param Color color, Board board
        public King(Color color, Board board, ChessMatch match) : base(color, board)
        {
            this._match = match;
        }
Exemple #27
0
 public King(Colors color, Board board, ChessMatch chessMatch) : base(color, board)
 {
     ChessMatch = chessMatch;
 }
Exemple #28
0
 public Pawn(Colors color, Board board, ChessMatch chessMatch) : base(color, board)
 {
     _chessMatch = chessMatch;
 }
Exemple #29
0
 /// <summary>
 /// Base constructor for a new standard chess board.
 /// </summary>
 public ChessBoard(ChessMatch match)
     : base(8, 8)
 {
     ChessMatch = match;
 }