예제 #1
0
        public void Start()
        {
            Console.Clear();
            Console.WriteLine("----------------------------------------------------------------------------------------------");
            Console.WriteLine($"***** HERO VS ENEMY *****");
            Console.WriteLine("----------------------------------------------------------------------------------------------");
            Console.WriteLine($"# Remember, Monster '{Enemy.Name}' is {Enemy.Diffculty} Level");

            while (Enemy.CurrentHP > 0 && Hero.CurrentHP > 0)
            {
                //  When Hero has equipped items, Add defense and strength ability
                var EquippedWeaponStrength = 0;
                var EquippedArmorDefense   = 0;
                var EquippedShieldDefense  = 0;

                if (Hero.EquippedWeapon != null)
                {
                    EquippedWeaponStrength = Hero.EquippedWeapon.Strength;
                }

                if (Hero.EquippedArmor != null)
                {
                    EquippedArmorDefense = Hero.EquippedArmor.Defense;
                }

                if (Hero.EquippedShield != null)
                {
                    EquippedShieldDefense = Hero.EquippedShield.Defense;
                }

                Console.WriteLine($"# {Hero.Name}, You got the power : Strength({Hero.Strength + EquippedWeaponStrength}), Defense({Hero.Defense + EquippedArmorDefense + EquippedShieldDefense}), HP({Hero.CurrentHP})");
                Console.WriteLine($"# You've encountered a '{Enemy.Name}' monster! : Strength({Enemy.Strength}), Defense({Enemy.Defense}), HP({Enemy.CurrentHP})");

                Console.WriteLine($"# What will you do?");
                Console.WriteLine("----------------------------------------------------------------------------------------------");
                Console.WriteLine("1. Fight");
                Console.WriteLine("2. Use potion");
                Console.WriteLine("3. Run Away!");
                Console.WriteLine("----------------------------------------------------------------------------------------------");
                Console.Write("Selet the menu : ");

                var input = Console.ReadLine();

                if (input == "1")
                {
                    HeroTurn();
                }
                else if (input == "2")
                {
                    Hero.UsingPotion();
                }
                else if (input == "3")
                {
                    RunAway();
                    //After hero runaway frome the game get out of this while Loop
                }
            }

            //Check Hero currentHP to restart the game or go main menu
            if (Hero.CurrentHP <= 0)
            {
                Lose();
            }
        }