public void UseAbility(Monster opponent, string[] input) { StringBuilder inputName = new StringBuilder(); for (int i = 1; i < input.Length; i++) { inputName.Append(input[i]); if (i != input.Length - 1) { inputName.Append(" "); } } int index = Abilities.FindIndex( f => f.Name == inputName.ToString() || f.Name == input[1] || f.Name.Contains(input[1]) || f.Name.Contains(inputName.ToString())); if (index != -1 && RagePoints >= Abilities[index].RageCost && PlayerClass == PlayerClassType.Warrior) { switch (Abilities[index].WarAbilityCategory) { case WarriorAbility.Slash: PlayerAbility.UseOffenseDamageAbility(opponent, this, index); return; case WarriorAbility.Rend: PlayerAbility.UseOffenseDamageAbility(opponent, this, index); return; case WarriorAbility.Charge: PlayerAbility.UseStunAbility(opponent, this, index); return; case WarriorAbility.Block: PlayerAbility.UseDefenseAbility(this, index); return; case WarriorAbility.Berserk: PlayerAbility.UseBerserkAbility(this, index); return; case WarriorAbility.Disarm: PlayerAbility.UseDisarmAbility(opponent, this, index); return; case WarriorAbility.Bandage: PlayerAbility.UseBandageAbility(this, index); return; case WarriorAbility.PowerAura: PlayerAbility.UsePowerAura(this, index); return; case WarriorAbility.WarCry: PlayerAbility.UseWarCry(this, index); return; case WarriorAbility.Onslaught: for (int i = 0; i < 2; i++) { if (RagePoints >= Abilities[index].RageCost) { PlayerAbility.UseOffenseDamageAbility(opponent, this, index); } else { OutputHelper.Display.StoreUserOutput( Settings.FormatAttackFailText(), Settings.FormatDefaultBackground(), "You didn't have enough rage points for the second attack!"); } } return; default: throw new ArgumentOutOfRangeException(); } } if (index != -1 && ComboPoints >= Abilities[index].ComboCost && PlayerClass == PlayerClassType.Archer) { switch (Abilities[index].ArcAbilityCategory) { case ArcherAbility.Distance: return; case ArcherAbility.Gut: if (PlayerWeapon?.WeaponGroup != WeaponType.Bow) { throw new InvalidOperationException(); } PlayerAbility.UseOffenseDamageAbility(opponent, this, index); return; case ArcherAbility.Precise: if (PlayerWeapon?.WeaponGroup != WeaponType.Bow) { throw new InvalidOperationException(); } PlayerAbility.UseOffenseDamageAbility(opponent, this, index); return; case ArcherAbility.Stun: if (PlayerWeapon?.WeaponGroup != WeaponType.Bow) { throw new InvalidOperationException(); } PlayerAbility.UseStunAbility(opponent, this, index); return; case ArcherAbility.Double: if (PlayerWeapon?.WeaponGroup != WeaponType.Bow) { throw new InvalidOperationException(); } for (int i = 0; i < 2; i++) { if (ComboPoints >= Abilities[index].ComboCost) { PlayerAbility.UseOffenseDamageAbility(opponent, this, index); } else { OutputHelper.Display.StoreUserOutput( Settings.FormatAttackFailText(), Settings.FormatDefaultBackground(), "You didn't have enough combo points for the second shot!"); } } return; case ArcherAbility.Wound: if (PlayerWeapon?.WeaponGroup != WeaponType.Bow) { throw new InvalidOperationException(); } PlayerAbility.UseOffenseDamageAbility(opponent, this, index); return; case ArcherAbility.Bandage: PlayerAbility.UseBandageAbility(this, index); return; case ArcherAbility.SwiftAura: PlayerAbility.UseSwiftAura(this, index); return; case ArcherAbility.ImmolatingArrow: if (PlayerWeapon?.WeaponGroup != WeaponType.Bow) { throw new InvalidOperationException(); } PlayerAbility.UseOffenseDamageAbility(opponent, this, index); return; case ArcherAbility.Ambush: if (PlayerWeapon?.WeaponGroup != WeaponType.Bow) { throw new InvalidOperationException(); } if (!InCombat) { PlayerAbility.UseOffenseDamageAbility(opponent, this, index); } else { OutputHelper.Display.StoreUserOutput( Settings.FormatAttackFailText(), Settings.FormatDefaultBackground(), $"You can't ambush {opponent.Name}, you're already in combat!"); } return; default: throw new ArgumentOutOfRangeException(); } } if (index != -1) { throw new InvalidOperationException(); } throw new IndexOutOfRangeException(); }
public void UseAbility(string[] input) { StringBuilder inputName = new StringBuilder(); for (int i = 1; i < input.Length; i++) { inputName.Append(input[i]); } int index = Abilities.FindIndex( f => f.Name == inputName.ToString() || f.Name.Contains(input[1])); if (index != -1 && RagePoints >= Abilities[index].RageCost && PlayerClass == PlayerClassType.Warrior) { switch (Abilities[index].WarAbilityCategory) { case WarriorAbility.Slash: case WarriorAbility.Rend: case WarriorAbility.Charge: case WarriorAbility.Block: case WarriorAbility.Berserk: case WarriorAbility.Disarm: case WarriorAbility.Onslaught: OutputHelper.Display.StoreUserOutput( Settings.FormatAttackFailText(), Settings.FormatDefaultBackground(), "You cannot use that ability outside combat!"); return; case WarriorAbility.Bandage: PlayerAbility.UseBandageAbility(this, index); return; case WarriorAbility.PowerAura: PlayerAbility.UsePowerAura(this, index); return; case WarriorAbility.WarCry: PlayerAbility.UseWarCry(this, index); return; default: throw new ArgumentOutOfRangeException(); } } if (index != -1 && ComboPoints >= Abilities[index].ComboCost && PlayerClass == PlayerClassType.Archer) { switch (Abilities[index].ArcAbilityCategory) { case ArcherAbility.Distance: if (PlayerWeapon?.WeaponGroup != WeaponType.Bow) { throw new InvalidOperationException(); } string direction = input.Last(); PlayerAbility.UseDistanceAbility(this, index, direction); return; case ArcherAbility.Gut: case ArcherAbility.Precise: case ArcherAbility.Stun: case ArcherAbility.Double: case ArcherAbility.Wound: case ArcherAbility.ImmolatingArrow: OutputHelper.Display.StoreUserOutput( Settings.FormatAttackFailText(), Settings.FormatDefaultBackground(), "You cannot use that ability outside combat!"); return; case ArcherAbility.Bandage: PlayerAbility.UseBandageAbility(this, index); return; case ArcherAbility.SwiftAura: PlayerAbility.UseSwiftAura(this, index); return; default: throw new ArgumentOutOfRangeException(); } } if (index != -1) { throw new InvalidOperationException(); } throw new IndexOutOfRangeException(); }