예제 #1
0
        static void Main(string[] args)
        {
            try
            {
                var match = new ChessMatch();

                while (!match.Finished)
                {
                    try
                    {
                        Console.Clear();
                        Screnn.PrintMatch(match);

                        Console.WriteLine();
                        Console.Write("From: ");
                        var from = Screnn.GetChessPosition().ToPosition();
                        match.ValidateFromPosition(from);

                        var possiblePositions = match
                                                .Board
                                                .Piece(from)
                                                .PossibleMovements();
                        Console.Clear();
                        Screnn.PrintBoard(match.Board, possiblePositions);

                        Console.WriteLine();
                        Console.Write("To: ");
                        var to = Screnn.GetChessPosition().ToPosition();
                        match.ValidateToPosition(from, to);

                        match.PerformMove(from, to);
                    }
                    catch (BoardException exception)
                    {
                        Console.WriteLine(exception.Message);
                        Console.ReadLine();
                    }
                }
            }
            catch (BoardException exception)
            {
                Console.WriteLine(exception.Message);
            }

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            ChessMatch match = new ChessMatch();

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

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

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

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

                    Console.WriteLine();
                    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();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            Console.Clear();
            Screen.PrintMatch(match);



            Console.ReadLine();
        }