Aura.Channel.Skills.SkillHelper.UpdateWeapon C# (CSharp) Method

UpdateWeapon() public static method

Reduces weapon's durability and increases its proficiency. Only updates weapon type items that are not null.
public static UpdateWeapon ( Creature attacker, Creature target, ProficiencyGainType profGainType ) : void
attacker Aura.Channel.World.Entities.Creature Creature who's weapon is updated.
target Aura.Channel.World.Entities.Creature /// The target of the skill, used for power rating calculations. /// If target is null, prof will be rewarded regardless of target. ///
profGainType ProficiencyGainType
return void
		public static void UpdateWeapon(Creature attacker, Creature target, ProficiencyGainType profGainType, params Item[] weapons)
		{
			if (attacker == null)
				return;

			var rnd = RandomProvider.Get();

			// Add prof if no target was specified or the target is not "Weakest".
			var addProf = (target == null || attacker.GetPowerRating(target) >= PowerRating.Weak);

			foreach (var weapon in weapons.Where(a => a != null && a.IsTrainableWeapon))
			{
				// Durability
				var reduce = rnd.Next(1, 30);
				attacker.Inventory.ReduceDurability(weapon, reduce);

				// Don't add prof if weapon is broken.
				if (weapon.Durability == 0)
					addProf = false;

				// Proficiency
				if (addProf)
				{
					var amount = Item.GetProficiencyGain(attacker.Age, profGainType);
					attacker.Inventory.AddProficiency(weapon, amount);
				}
			}
		}