Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                ChessGame chessGame = new ChessGame();
                while (!chessGame.Terminated)
                {
                    try
                    {
                        Console.Clear();
                        Screen.PrintChessGame(chessGame);

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

                        bool[,] posiblePositions = chessGame.BoardGame.Piece(origin).PossibleMoves();
                        Console.Clear();
                        Screen.PrintBoardGame(chessGame.BoardGame, posiblePositions);

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

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

                Console.Clear();
                Screen.PrintChessGame(chessGame);
            }
            catch (BoardException e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                ChessGame Game = new ChessGame();

                while (!Game.Finish)
                {
                    Console.Clear();
                    Screen.ImprimirPartida(Game);

                    Console.WriteLine();
                    Console.WriteLine("PRIMEIRO LETRA DEOPIS NUMERO  EX: a1");
                    Console.WriteLine();
                    Console.Write("Origin: ");
                    Posicao origin = Screen.ReadPositionChess().ToPosition();

                    bool[,] PossiblePosition = Game.Chess.Piece(origin).PossibleMovments();


                    Console.Clear();
                    Screen.ImprimirTabuleiro(Game.Chess, PossiblePosition);



                    Console.WriteLine();
                    Console.Write("Destino: ");
                    Posicao destiny = Screen.ReadPositionChess().ToPosition();
                    Game.ValidatePositionDestiny(origin, destiny);


                    Game.MakePlay(origin, destiny);
                }
            }
            catch (ChessBoardException ce)
            {
                Console.WriteLine(ce.Message);
            }

            Console.ReadLine();
        }