Example #1
0
        static void Main(string[] args)
        {
            ChessMoves chessMoves = new ChessMoves();

            try
            {
                while (!chessMoves.Ended)
                {
                    try
                    {
                        Screen.ShowBoard(chessMoves);
                        Console.Write("\nOrigem: ");
                        Position origin = Screen.readPosition().ReturnPosition();
                        chessMoves.VerifyInitialPosition(origin);
                        Console.Clear();
                        bool[,] possibleMovements = chessMoves.Board.ReturnPiece(origin).PossibleMovements();
                        Screen.ShowBoard(chessMoves, possibleMovements);

                        Console.Write("\nDestino: ");
                        Position destiny = Screen.readPosition().ReturnPosition();
                        chessMoves.VerifyFinalPosition(origin, destiny);
                        chessMoves.MakeMoviment(origin, destiny, possibleMovements);
                    }
                    catch (BoardException e)
                    {
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }
                }
            }
            catch (BoardException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #2
0
        private static void PrintOutGamePieces(ChessMoves chessMoves)
        {
            Console.WriteLine("Peças Capturadas: ");
            Console.Write("Brancas: ");
            PrintHashSet(chessMoves.OutPiecesColor(Color.White));
            Console.Write("\nPretas: ");
            ConsoleColor aux = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Blue;
            PrintHashSet(chessMoves.OutPiecesColor(Color.Black));
            Console.ForegroundColor = aux;
            Console.WriteLine();
        }
Example #3
0
 public static void ShowBoard(ChessMoves chessMoves, bool[,] possibleMovements)
 {
     Console.Clear();
     PrintBoard(chessMoves.Board, possibleMovements);
     Console.WriteLine();
     PrintOutGamePieces(chessMoves);
     Console.WriteLine("\nTurno: " + chessMoves.Turn);
     if (chessMoves.CurrentPlayer == Color.Black)
     {
         Console.Write("Aguardando jogada: ");
         ConsoleColor aux = Console.ForegroundColor;
         Console.ForegroundColor = ConsoleColor.Blue;
         Console.WriteLine(chessMoves.CurrentPlayer);
         Console.ForegroundColor = aux;
     }
     else
     {
         Console.WriteLine("Aguardando jogada: " + chessMoves.CurrentPlayer);
     }
 }
Example #4
0
        public ChessMoves(int row, int col)
        {
            Row = row;
            Col = col;

            if (row < 8)
            {
                Top = new ChessMoves(row + 1, col);
            }
            else
            {
                Top = null;
            }
            if (col < 8)
            {
                Right = new ChessMoves(row, col + 1);
            }
            else
            {
                Right = null;
            }
        }