예제 #1
0
        /// <summary>
        /// Computes min 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 GetRawWeaponDamageMin(this ItemAttributes weaponAttr, String resist, bool useDamageTypePercentBonus = true)
        {
            var damage = weaponAttr.GetBaseWeaponDamageMin(resist);

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

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

            return(damage);
        }
예제 #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);
        }
예제 #3
0
 public void GetBaseWeaponDamageMin()
 {
     Assert.AreEqual(new ItemValueRange(12, 120), weaponAttr.GetBaseWeaponDamageMin("Arcane"));
     Assert.AreEqual(new ItemValueRange(24, 240), weaponAttr.GetBaseWeaponDamageMin("Physical"));
 }