Ejemplo n.º 1
0
        public void HeroFight()
        {
            bool fight = false;

            while (!fight)
            {
                Console.WriteLine("Hero turn");
                Console.WriteLine("-----------------------------");
                Console.WriteLine();
                Console.WriteLine("Choose the option you want: ");
                Console.WriteLine("Press 1 to show status.");
                Console.WriteLine("Press 2 to show inventory.");
                Console.WriteLine("Press 3 to choose the weapon.");
                Console.WriteLine("Press 4 to choose the armor.");
                Console.WriteLine("Press 5 to buy health.");
                Console.WriteLine("Press 0 to quit the fight.");
                Console.WriteLine("Press any key to fight directly.");
                char inputValue = Console.ReadKey().KeyChar;
                Console.WriteLine();

                if (inputValue == '0')
                {
                    Hero.CurrentHealth    = Hero.OriginalHealth;
                    Monster.CurrentHealth = Monster.OriginalHealth;
                    throw new Exception("You quit the fight.");
                }
                else if (inputValue == '1')
                {
                    Hero.ShowStats();

                    fight = false;
                }
                else if (inputValue == '2')
                {
                    Hero.ShowInventory();

                    fight = false;
                }
                else if (inputValue == '3')
                {
                    Hero.GetWeapon();

                    fight = false;
                }
                else if (inputValue == '4')
                {
                    Hero.GetArmor();
                    fight = false;
                }
                else if (inputValue == '5')
                {
                    Hero.BuyHealth();
                }
                else
                {
                    fight = true;
                }
            }
            int lostHealth = 0;

            if (Hero.EquippedWeapon == null)
            {
                lostHealth = Hero.Strength - Monster.Defense;
            }
            else
            {
                lostHealth = Hero.Strength + Hero.EquippedWeapon.Power - Monster.Defense;
            }

            if (lostHealth <= 0)
            {
                lostHealth = 0;
            }
            Monster.CurrentHealth -= lostHealth;

            Console.WriteLine();
            Console.WriteLine("Your attack made the monstor lose {0} health.", lostHealth);
            Console.WriteLine();
        }