Exemple #1
0
        public void Start()
        {
            int v = 0;

            Character1 = InitPlayer(0, true);
            Character2 = InitPlayer(1, false);
            World      = InitWorld();
            while (Character1.Alive && !World.HasWinner())
            {
                try
                {
                    Turn++;
                    World.Show(Character1, Character2, Turn, true);
                    Character1.Moving();
                    Console.WriteLine("Tap <Enter> to finish move...");
                    Console.ReadLine();
                    World.Show(Character1, Character2, Turn, false);
                    Character2.Moving();
                    Console.WriteLine("Tap <Enter> to finish move...");
                    Console.ReadLine();
                    World.Show(Character1, Character2, Turn);
                    foreach (Bot item in GameObjects.Where(x => x is Bot b && b.Alive))
                    {
                        item.Move("");
                    }
                    Console.ReadKey();
                    if (Turn == 2)
                    {
                        var a = 5 / v;
                        throw new GameException("Buy this game to continue");
                    }
                }
                catch (GameException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (DivideByZeroException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    Console.ReadLine();
                    Console.WriteLine("End turn.");
                }
            }

            World.Show(Character1, Character2, Turn);
            Console.WriteLine($"Congrats {World.GetWinner().Name}!");
        }