예제 #1
0
        public static void ExecuteHeroTurn()
        {
            var heroChoice         = Console.ReadLine();
            var selectedHeroChoice = Enum.Parse <HeroChoice>(heroChoice);

            Console.WriteLine(
                $"You chose to {Enum.Parse<HeroChoice>(heroChoice).ToString().ConvertToCamelCase()}!");

            if (selectedHeroChoice == HeroChoice.Attack)
            {
                HeroActions.HeroAttack(hero, monster);
            }
            else if (selectedHeroChoice == HeroChoice.Heal)
            {
                HeroActions.HeroHeal(hero);
            }
            else if (selectedHeroChoice == HeroChoice.DefensePotion)
            {
                HeroActions.HeroPotion(hero, monster);
            }
            //else if (selectedHeroChoice == HeroChoice.Fireball)
            //{
            //    HeroFireball(hero);
            //}
        }
예제 #2
0
        public void StartHere()
        {
            Console.WriteLine("WELCOME TO THE GAME\n");
            Console.Write("What is your name? ");

            hero = new Hero
            {
                Name           = Console.ReadLine(),
                Health         = 100,
                DefensePotions = 3,
                PotionsUsed    = false,
                AttackValue    = HeroActions.GetHeroAttackValue()
            };

            monster = new Monster
            {
                Name           = "Monster",
                Health         = 100,
                DefensePotions = 3,
                PotionsUsed    = false,
                AttackValue    = MonsterActions.GetMonsterAttackValue()
            };


            Console.WriteLine($"{hero.Name}'s Health: {hero.Health}");
            Console.WriteLine($"{monster.Name}'s Health: {monster.Health}\n");

            while (hero.Health > 0)
            {
                Console.WriteLine($"It's your turn {hero.Name}, what's your next move?!\n");
                var heroOptions = Enum.GetValues(typeof(HeroChoice));

                foreach (var value in heroOptions)
                {
                    Console.WriteLine($"{(int) value}: {value.ToString().ConvertToCamelCase()}");
                }

                Console.WriteLine();

                HeroActions.ExecuteHeroTurn();

                if (monster.Health <= 0)
                {
                    break;
                }

                Console.WriteLine($"It's {monster.Name}'s turn! \n");

                MonsterActions.ExecuteMonsterTurn();

                Console.WriteLine("--------------------------------------------------------------------------");
            }

            if (hero.Health <= 0)
            {
                EndGame(hero, monster);
            }

            if (monster.Health <= 0)
            {
                EndGame(hero, monster);
            }
        }