Exemplo n.º 1
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);
        }