Example #1
0
        public static void UseOffenseDamageAbility(Monster monster, Player player, int index)
        {
            if (player.PlayerClass == PlayerClassType.Archer && PlayerHelper.OutOfArrows(player))
            {
                /* If quiver is empty, player can only do a normal attack, and attack() also checks for
                 * arrow count and informs player that they are out of arrows */
                player.PhysicalAttack(monster);
                return;
            }

            DeductAbilityCost(player, index);

            if (player.PlayerClass == PlayerClassType.Archer)
            {
                player.PlayerQuiver.UseArrow();
            }

            int abilityDamage = PlayerHelper.CalculateAbilityDamage(player, monster, index);

            monster.HitPoints -= abilityDamage;

            string abilitySuccessString = $"Your {player.Abilities[index].Name} hit the {monster.Name} for {abilityDamage} physical damage.";

            OutputHelper.Display.StoreUserOutput(
                Settings.FormatAttackSuccessText(),
                Settings.FormatDefaultBackground(),
                abilitySuccessString);

            if (player.Abilities[index].Offensive.AmountOverTime <= 0)
            {
                return;
            }

            switch (player.Abilities[index].Offensive.OffensiveGroup)
            {
            case OffensiveType.Normal:
                break;

            case OffensiveType.Bleed:
                string bleedString = $"The {monster.Name} is bleeding!";
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatAttackSuccessText(),
                    Settings.FormatDefaultBackground(),
                    bleedString);

                EffectOverTimeSettings effectSettings = new EffectOverTimeSettings {
                    AmountOverTime = player.Abilities[index].Offensive.AmountOverTime,
                    EffectHolder   = monster,
                    MaxRound       = player.Abilities[index].Offensive.AmountMaxRounds,
                    Name           = player.Abilities[index].Name
                };
                monster.Effects.Add(new BleedingEffect(effectSettings));
                break;

            case OffensiveType.Fire:
                string onFireString = $"The {monster.Name} bursts into flame!";
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatOnFireText(),
                    Settings.FormatDefaultBackground(),
                    onFireString);

                EffectOverTimeSettings effectOverTimeSettings = new EffectOverTimeSettings {
                    AmountOverTime = player.Abilities[index].Offensive.AmountOverTime,
                    EffectHolder   = monster,
                    MaxRound       = player.Abilities[index].Offensive.AmountMaxRounds,
                    Name           = player.Abilities[index].Name
                };
                monster.Effects.Add(new BurningEffect(effectOverTimeSettings));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }