예제 #1
0
        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);
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
 protected override void ApplyToItem(AttributeAffix affix, QualityRoll quality)
 {
     armorEnhancement.ApplyArmorAttribute(affix.Attribute, affix.Priority, affix.Range.Value.Interpolate(quality));
 }
예제 #4
0
 protected override bool IsApplicableToItem(AttributeAffix affix)
 {
     return(ArmorEnhancement.IsArmorAttribute(affix.Attribute));
 }
예제 #5
0
 /// <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.");
 }
예제 #6
0
 /// <summary>
 /// Can the affix be applied directly to the item?
 /// </summary>
 protected virtual bool IsApplicableToItem(AttributeAffix affix)
 {
     return(false);
 }
예제 #7
0
 protected override bool IsApplicableToItem(AttributeAffix affix)
 {
     return(WeaponEnhancement.IsWeaponAttribute(affix.Attribute));
 }