Esempio n. 1
0
        private static bool EvaluateRule(CachedACDItem cItem, ItemProperty prop, double value, int variant, RuleType type = RuleType.Test)
        {
            var result = false;
            string friendlyVariant = string.Empty;
            double itemValue = 0;
            double ruleValue = 0;

            switch (prop)
            {
                case ItemProperty.Ancient:
                    itemValue = cItem.IsAncient ? 1 : 0;
                    ruleValue = value;
                    result = cItem.IsAncient == (value == 1);
                    break;

                case ItemProperty.PrimaryStat:
                    itemValue = ItemDataUtils.GetMainStatValue(cItem.AcdItem);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.CriticalHitChance:
                    itemValue = cItem.CritPercent;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.CriticalHitDamage:
                    itemValue = cItem.CritDamagePercent;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.AttackSpeed:
                    itemValue = ItemDataUtils.GetAttackSpeed(cItem.AcdItem);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.ResourceCost:
                    itemValue = Math.Round(cItem.AcdItem.Stats.ResourceCostReductionPercent, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.Cooldown:
                    itemValue = Math.Round(cItem.AcdItem.Stats.PowerCooldownReductionPercent, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.ResistAll:
                    itemValue = cItem.AcdItem.Stats.ResistAll;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.Sockets:
                    itemValue = cItem.AcdItem.Stats.Sockets;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.Vitality:
                    itemValue = cItem.AcdItem.Stats.Vitality;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.AreaDamage:
                    itemValue = cItem.AcdItem.Stats.OnHitAreaDamageProcChance;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.FireSkills:
                    itemValue = cItem.AcdItem.Stats.FireSkillDamagePercentBonus;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.ColdSkills:
                    itemValue = cItem.AcdItem.Stats.ColdSkillDamagePercentBonus;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.LightningSkills:
                    itemValue = cItem.AcdItem.Stats.LightningSkillDamagePercentBonus;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.ArcaneSkills:
                    itemValue = cItem.AcdItem.Stats.ArcaneSkillDamagePercentBonus;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.HolySkills:
                    itemValue = cItem.AcdItem.Stats.HolySkillDamagePercentBonus;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.PoisonSkills:
                    itemValue = cItem.AcdItem.Stats.PosionSkillDamagePercentBonus;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.PhysicalSkills:
                    itemValue = cItem.AcdItem.Stats.PhysicalSkillDamagePercentBonus;
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.DamageAgainstElites:
                    itemValue = Math.Round(cItem.AcdItem.Stats.DamagePercentBonusVsElites, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.DamageFromElites:
                    itemValue = Math.Round(cItem.AcdItem.Stats.DamagePercentReductionFromElites, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.BaseMaxDamage:
                    itemValue = ItemDataUtils.GetMaxBaseDamage(cItem.AcdItem);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.SkillDamage:

                    var skillId = variant;
                    var skill = ItemDataUtils.GetSkillsForItemType(cItem.TrinityItemType, Trinity.Player.ActorClass).FirstOrDefault(s => s.Id == skillId);
                    if (skill != null)
                    {
                        friendlyVariant = skill.Name;
                        itemValue = cItem.AcdItem.SkillDamagePercent(skill.SNOPower);
                    }

                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.ElementalDamage:

                    var elementId = variant;
                    var element = (Element)elementId;
                    if (element != Element.Unknown)
                    {
                        friendlyVariant = ((EnumValue<Element>)element).Name;
                        itemValue = Math.Round(ItemDataUtils.GetElementalDamage(cItem.AcdItem, element), MidpointRounding.AwayFromZero);
                    }

                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.PercentDamage:
                    itemValue = Math.Round(cItem.AcdItem.WeaponDamagePercent(), MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.CriticalHitsGrantArcane:
                    itemValue = Math.Round(cItem.ArcaneOnCrit, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.Armor:
                    itemValue = Math.Round(cItem.Armor, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.ChanceToBlock:
                    itemValue = Math.Round(cItem.BlockChance, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.HatredRegen:
                    itemValue = Math.Round(cItem.HatredRegen, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.LifePercent:
                    itemValue = Math.Round(cItem.LifePercent, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.LifePerHit:
                    itemValue = Math.Round(cItem.LifeOnHit, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.RegenerateLifePerSecond:
                    itemValue = Math.Round(cItem.AcdItem.Stats.HealthPerSecond, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.ManaRegen:
                    itemValue = Math.Round(cItem.AcdItem.Stats.ManaRegen, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.MovementSpeed:
                    itemValue = Math.Round(cItem.AcdItem.Stats.MovementSpeed, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.SpiritRegen:
                    itemValue = Math.Round(cItem.AcdItem.Stats.SpiritRegen, MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.WrathRegen:
                    itemValue = Math.Round((double)cItem.AcdItem.GetAttribute<float>(ActorAttributeType.ResourceRegenPerSecondFaith), MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.LifePerFury:
                    itemValue = Math.Round((double)cItem.AcdItem.GetAttribute<float>(ActorAttributeType.SpendingResourceHealsPercentFury), MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.LifePerSpirit:
                    itemValue = Math.Round((double)cItem.AcdItem.GetAttribute<float>(ActorAttributeType.SpendingResourceHealsPercentSpirit), MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;

                case ItemProperty.LifePerWrath:
                    itemValue = Math.Round((double)cItem.AcdItem.GetAttribute<float>(ActorAttributeType.SpendingResourceHealsPercentFaith), MidpointRounding.AwayFromZero);
                    ruleValue = value;
                    result = itemValue >= ruleValue;
                    break;
            }

            Logger.LogVerbose("  >>  Evaluated {0} -- {1} {5} Type={6} (Item: {2} -v- Rule: {3}) = {4}",
                cItem.RealName,
                prop.ToString().AddSpacesToSentence(),
                itemValue,
                ruleValue,
                result,
                friendlyVariant,
                type);

            return result;
        }
Esempio n. 2
0
        private static bool EvaluateRule(CachedACDItem cItem, ItemProperty prop, double value, int variant, RuleType type = RuleType.Test)
        {
            var    result          = false;
            string friendlyVariant = string.Empty;
            double itemValue       = 0;
            double ruleValue       = 0;

            switch (prop)
            {
            case ItemProperty.Ancient:
                itemValue = cItem.IsAncient ? 1 : 0;
                ruleValue = value;
                result    = cItem.IsAncient == (value == 1);
                break;

            case ItemProperty.PrimaryStat:
                itemValue = ItemDataUtils.GetMainStatValue(cItem.AcdItem);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.CriticalHitChance:
                itemValue = cItem.CritPercent;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.CriticalHitDamage:
                itemValue = cItem.CritDamagePercent;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.AttackSpeed:
                itemValue = ItemDataUtils.GetAttackSpeed(cItem.AcdItem);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.ResourceCost:
                itemValue = Math.Round(cItem.AcdItem.Stats.ResourceCostReductionPercent, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.Cooldown:
                itemValue = Math.Round(cItem.AcdItem.Stats.PowerCooldownReductionPercent, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.ResistAll:
                itemValue = cItem.AcdItem.Stats.ResistAll;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.Sockets:
                itemValue = cItem.AcdItem.Stats.Sockets;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.Vitality:
                itemValue = cItem.AcdItem.Stats.Vitality;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.AreaDamage:
                itemValue = cItem.AcdItem.Stats.OnHitAreaDamageProcChance;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.FireSkills:
                itemValue = cItem.AcdItem.Stats.FireSkillDamagePercentBonus;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.ColdSkills:
                itemValue = cItem.AcdItem.Stats.ColdSkillDamagePercentBonus;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.LightningSkills:
                itemValue = cItem.AcdItem.Stats.LightningSkillDamagePercentBonus;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.ArcaneSkills:
                itemValue = cItem.AcdItem.Stats.ArcaneSkillDamagePercentBonus;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.HolySkills:
                itemValue = cItem.AcdItem.Stats.HolySkillDamagePercentBonus;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.PoisonSkills:
                itemValue = cItem.AcdItem.Stats.PosionSkillDamagePercentBonus;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.PhysicalSkills:
                itemValue = cItem.AcdItem.Stats.PhysicalSkillDamagePercentBonus;
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.DamageAgainstElites:
                itemValue = Math.Round(cItem.AcdItem.Stats.DamagePercentBonusVsElites, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.DamageFromElites:
                itemValue = Math.Round(cItem.AcdItem.Stats.DamagePercentReductionFromElites, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.BaseMaxDamage:
                itemValue = ItemDataUtils.GetMaxBaseDamage(cItem.AcdItem);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.SkillDamage:

                var skillId = variant;
                var skill   = ItemDataUtils.GetSkillsForItemType(cItem.TrinityItemType, Trinity.Player.ActorClass).FirstOrDefault(s => s.Id == skillId);
                if (skill != null)
                {
                    friendlyVariant = skill.Name;
                    itemValue       = cItem.AcdItem.SkillDamagePercent(skill.SNOPower);
                }

                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.ElementalDamage:

                var elementId = variant;
                var element   = (Element)elementId;
                if (element != Element.Unknown)
                {
                    friendlyVariant = ((EnumValue <Element>)element).Name;
                    itemValue       = Math.Round(ItemDataUtils.GetElementalDamage(cItem.AcdItem, element), MidpointRounding.AwayFromZero);
                }

                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.PercentDamage:
                itemValue = Math.Round(cItem.AcdItem.WeaponDamagePercent(), MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.CriticalHitsGrantArcane:
                itemValue = Math.Round(cItem.ArcaneOnCrit, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.Armor:
                itemValue = Math.Round(cItem.Armor, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.ChanceToBlock:
                itemValue = Math.Round(cItem.BlockChance, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.HatredRegen:
                itemValue = Math.Round(cItem.HatredRegen, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.LifePercent:
                itemValue = Math.Round(cItem.LifePercent, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.LifePerHit:
                itemValue = Math.Round(cItem.LifeOnHit, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.RegenerateLifePerSecond:
                itemValue = Math.Round(cItem.AcdItem.Stats.HealthPerSecond, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.ManaRegen:
                itemValue = Math.Round(cItem.AcdItem.Stats.ManaRegen, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.MovementSpeed:
                itemValue = Math.Round(cItem.AcdItem.Stats.MovementSpeed, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.SpiritRegen:
                itemValue = Math.Round(cItem.AcdItem.Stats.SpiritRegen, MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.WrathRegen:
                itemValue = Math.Round((double)cItem.AcdItem.GetAttribute <float>(ActorAttributeType.ResourceRegenPerSecondFaith), MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.LifePerFury:
                itemValue = Math.Round((double)cItem.AcdItem.GetAttribute <float>(ActorAttributeType.SpendingResourceHealsPercentFury), MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.LifePerSpirit:
                itemValue = Math.Round((double)cItem.AcdItem.GetAttribute <float>(ActorAttributeType.SpendingResourceHealsPercentSpirit), MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;

            case ItemProperty.LifePerWrath:
                itemValue = Math.Round((double)cItem.AcdItem.GetAttribute <float>(ActorAttributeType.SpendingResourceHealsPercentFaith), MidpointRounding.AwayFromZero);
                ruleValue = value;
                result    = itemValue >= ruleValue;
                break;
            }

            Logger.LogVerbose("  >>  Evaluated {0} -- {1} {5} Type={6} (Item: {2} -v- Rule: {3}) = {4}",
                              cItem.RealName,
                              prop.ToString().AddSpacesToSentence(),
                              itemValue,
                              ruleValue,
                              result,
                              friendlyVariant,
                              type);

            return(result);
        }
Esempio n. 3
0
 public override string GetText()
 {
     return("Change " + prop.ToString().Replace('_', ' '));
 }