Ejemplo n.º 1
0
        /// <summary>
        /// Computes max damage of the weapon (based on a specific resist).
        /// </summary>
        /// <param name="weaponAttr">Attributes of a weapon.</param>
        /// <param name="resist">Name of the resist.</param>
        /// <param name="useDamageTypePercentBonus"></param>
        /// <returns></returns>
        public static ItemValueRange GetRawWeaponDamageMax(this ItemAttributes weaponAttr, String resist, bool useDamageTypePercentBonus = true)
        {
            var damage = weaponAttr.GetBaseWeaponDamageMax(resist);

            damage *= ItemValueRange.One + weaponAttr.GetAttributeByName("damageWeaponPercentBonus_" + resist);

            if (useDamageTypePercentBonus && resist != "Physical")
            {
                damage += weaponAttr.GetRawWeaponDamageMax("Physical") * weaponAttr.GetAttributeByName("damageTypePercentBonus_" + resist);
            }

            return(damage);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a new <see cref="ItemAttributes"/> by aggregating some raw attributes of <paramref name="itemAttr"/> (for easier editing for example).
        /// </summary>
        /// <param name="itemAttr"></param>
        /// <returns>The <paramref name="itemAttr"/> instance.</returns>
        public static ItemAttributes GetSimplified(this ItemAttributes itemAttr)
        {
            var attr = new ItemAttributes(itemAttr);

            // Characteristics
            attr.armorItem      = itemAttr.GetArmor().NullIfZero();
            attr.armorBonusItem = null;

            // Weapon characterics
            attr.attacksPerSecondItem        = itemAttr.GetRawWeaponAttackPerSecond().NullIfZero();
            attr.attacksPerSecondItemPercent = null;

            itemAttr.CheckAndUpdateWeaponDelta();

            foreach (var resist in D3Calculator.DamageResists)
            {
                var baseWeaponDamageMin   = itemAttr.GetBaseWeaponDamageMin(resist);
                var baseWeaponDamageDelta = itemAttr.GetBaseWeaponDamageMax(resist) - baseWeaponDamageMin;

                attr.SetAttributeByName("damageWeaponMin_" + resist, baseWeaponDamageMin.NullIfZero())
                .SetAttributeByName("damageWeaponDelta_" + resist, baseWeaponDamageDelta.NullIfZero())
                .SetAttributeByName("damageWeaponBonusMin_" + resist, null)
                .SetAttributeByName("damageWeaponBonusDelta_" + resist, null)
                .SetAttributeByName("damageWeaponBonusMinX1_" + resist, null)
                .SetAttributeByName("damageWeaponBonusDeltaX1_" + resist, null)
                .SetAttributeByName("damageWeaponBonusFlat_" + resist, null);
            }

            // Item damage bonuses
            foreach (var resist in D3Calculator.DamageResists)
            {
                var rawDamageMin   = itemAttr.GetRawBonusDamageMin(resist, false);
                var rawDamageDelta = itemAttr.GetRawBonusDamageMax(resist, false) - rawDamageMin;

                attr.SetAttributeByName("damageMin_" + resist, rawDamageMin.NullIfZero())
                .SetAttributeByName("damageDelta_" + resist, rawDamageDelta.NullIfZero())
                .SetAttributeByName("damageBonusMin_" + resist, null);
            }

            return(attr);
        }
Ejemplo n.º 3
0
 public void GetBaseWeaponDamageMax()
 {
     Assert.AreEqual(new ItemValueRange(18, 180), weaponAttr.GetBaseWeaponDamageMax("Arcane"));
     Assert.AreEqual(new ItemValueRange(36, 360), weaponAttr.GetBaseWeaponDamageMax("Physical"));
 }