Exemple #1
0
        public static Point GetNextEatPoint(Board board)
        {
            while (true)
            {
                Console.WriteLine("\nEnter Y Location:");

                if (int.TryParse(Console.ReadLine(), out int height) == false)
                {
                    Console.WriteLine("\nSorry,That's Not a Number...\n");
                    continue;
                }

                else if (height > board.Tiles.GetLength(0) || height < 0)
                {
                    Console.WriteLine("\nSorry, This number is not in the borders of the board\nPlease Try Again...");
                    continue;
                }

                Console.WriteLine($"\nY Position = {height}\n");

                Console.WriteLine("\nEnter X Location:");

                if (int.TryParse(Console.ReadLine(), out int width) == false)
                {
                    Console.WriteLine("\nSorry,That's Not a Number...\n");
                    continue;
                }

                else if (width > board.Tiles.GetLength(1) || width < 0)
                {
                    Console.WriteLine("\nSorry, This number is not in the borders of the board\nPlease Try Again...");
                    continue;
                }

                DisplayBoard.Display(board);

                Console.WriteLine($"\nYour Position = ({height}, {width})\n");

                return(new Point {
                    Height = height, Width = width
                });
            }
        }
Exemple #2
0
        private static object Compare(Board board)
        {
            //Input
            var obj1 = Console.ReadKey(true);

            if (int.TryParse(obj1.KeyChar.ToString(), out int number) == true)
            {
                return(number);
            }

            if (obj1.Key == ConsoleKey.Escape)
            {
                if (Exit.ExitGame() == true)
                {
                    return(false);
                }
                return("You Didn't Want To Exit Your Game");
            }

            if (obj1.Key == ConsoleKey.H)
            {
                DisplayBoard.Display(board);
                MainMenu.Guide();
                return("End of Help");
            }

            if (obj1.Key == ConsoleKey.F5)
            {
                if (SettingGame.SaveGame(board) == true)
                {
                    return(false);
                }
                return("You Didn't Want To Save Your Game");
            }

            return("That's Not a Number or Exit or Save or Help\nPlease Try again...\n");
        }
Exemple #3
0
        public static bool Eat(PlayerRequest playerRequest, Board board, GamePlay gamePlay)
        {
            if (gamePlay.ExecuteFirstEatMove(playerRequest) == true)
            {
                Console.WriteLine("\n***Successful First Eat Move***\n");

                bool optionsToEat;

                var playerinput = playerRequest.MovementInput;

                do
                {
                    optionsToEat = false;

                    PawnActionUtillities.DeletePawn(playerinput, board);

                    playerinput.StartingPoint = playerinput.EndPoint;

                    //Printing the points list, using another DiplayBoard function

                    var points = GameInput.IsTherePawnsAround(playerinput.StartingPoint);

                    //Console.WriteLine($"Number of Points in The List: {points.Count}\n");

                    foreach (var point in points)
                    {
                        var tempRequest = new PlayerRequest
                        {
                            Board         = board,
                            MovementInput = new Input
                            {
                                StartingPoint = playerinput.EndPoint, EndPoint = point
                            }
                        };

                        //Checking if the points in the list are valid to eat
                        if (gamePlay.EatingLoop(tempRequest) == true)
                        {
                            optionsToEat = true;
                            Console.WriteLine($"You can go to The Tile : ( {point.Height} , {point.Width} )\n");
                        }
                    }

                    //Clean the List Of Points
                    points.Clear();

                    //If There's no more pawns you can eat this turn
                    if (optionsToEat == false)
                    {
                        return(true);
                    }

                    //Printing The Board
                    DisplayBoard.Display(board);

                    Console.WriteLine("Enter The Location You Want To Move To With Your Pawn...\nIf You Wont eat another pawn, your turn will end!\n");

                    //Input Of The Next Eating Position
                    playerinput.EndPoint = GameInput.GetNextEatPoint(board);


                    playerRequest.MovementInput = playerinput;
                    playerRequest.Board         = board;

                    //Did the user succeeded to eat?
                    if (gamePlay.EatingLoop(playerRequest) == false)
                    {
                        Console.WriteLine("\nYou didn't choose one of the tiles...\nUnsuccessful Next Eat Move\n");
                        //This Ends the Player's Turn
                        break;
                    }
                    Console.WriteLine("\n***successful Next Eat Move***\n");
                } while (optionsToEat == true);
            }

            return(false);
        }
Exemple #4
0
        private static object GetPoint(Board board)
        {
            var point = new Point();


            //Y Loop
            while (true)
            {
                Console.WriteLine("\nEnter Y Location:");

                var obj1 = Compare(board);

                if (obj1.Equals(false))
                {
                    return(false);
                }

                else if (obj1 is int Y)
                {
                    if (Y > board.Tiles.GetLength(0) || Y < 0)
                    {
                        Console.WriteLine("\nSorry, This number is not in the borders of the board\nPlease Try Again...");
                        continue;
                    }

                    point.Height = Y;
                    break;
                }

                Console.WriteLine(obj1);
            }

            Console.WriteLine($"\nY Position = {point.Height}\n");


            //X Loop
            while (true)
            {
                Console.WriteLine("\nEnter X Location:");

                var obj2 = Compare(board);

                if (obj2.Equals(false))
                {
                    return(false);
                }

                else if (obj2 is int X)
                {
                    if (X > board.Tiles.GetLength(1) || X < 0)
                    {
                        Console.WriteLine("\nSorry, This number is not in the borders of the board\nPlease Try Again...");
                        continue;
                    }

                    point.Width = X;
                    break;
                }

                Console.WriteLine(obj2);
            }

            DisplayBoard.Display(board);

            Console.WriteLine($"\nYour Position = ({point.Height}, {point.Width})\n");

            return(point);
        }