protected override void ApplyToItem(AttributeAffix affix, QualityRoll quality) { Assert.IsTrue(IsApplicableToItem(affix)); MagnitudeRange magnitudeRange = affix.Range.Value; int magnitude = magnitudeRange.Interpolate(quality); tempEnhancement.ApplyWeaponAttribute(affix.Attribute, affix.Priority, magnitude); }
/// <summary> /// Apply an attribute affix to the item. The item will consume the affix directly if it can (e.g. weapons may /// consume MinDamage directly by adding it to their minimum damage), in which case the affix will not be applied /// to the player. /// </summary> public void AddAffix(AffixDefinition affix, QualityRoll quality) { if (!isBuilding) { throw new InvalidOperationException("Must start building before adding affixes."); } if (affix == null) { throw new ArgumentNullException("affix"); } // Double-dispatch could be used to avoid the type-sniffing, but this is a lot simpler AttributeAffix attributeAffix = affix as AttributeAffix; bool applyToItem = (attributeAffix != null) && IsApplicableToItem(attributeAffix); if (applyToItem) { ApplyToItem(attributeAffix, quality); } tempAffixes.Add(new Affix(affix, quality, applyToItem)); }
protected override void ApplyToItem(AttributeAffix affix, QualityRoll quality) { armorEnhancement.ApplyArmorAttribute(affix.Attribute, affix.Priority, affix.Range.Value.Interpolate(quality)); }
protected override bool IsApplicableToItem(AttributeAffix affix) { return(ArmorEnhancement.IsArmorAttribute(affix.Attribute)); }
/// <summary> /// Apply the affix, identified by IsApplicableToItem, to the item. /// </summary> protected virtual void ApplyToItem(AttributeAffix affix, QualityRoll quality) { throw new ArgumentException("Affix not applicable to item."); }
/// <summary> /// Can the affix be applied directly to the item? /// </summary> protected virtual bool IsApplicableToItem(AttributeAffix affix) { return(false); }
protected override bool IsApplicableToItem(AttributeAffix affix) { return(WeaponEnhancement.IsWeaponAttribute(affix.Attribute)); }