Exemplo n.º 1
0
        public ItemAttributesFromLevel(Hero hero)
        {
            switch (hero.HeroClass)
            {
            case HeroClass.Monk:
            case HeroClass.DemonHunter:
                dexterityItem    = new ItemValueRange(7 + 3 * hero.Level);
                intelligenceItem = new ItemValueRange(7 + 1 * hero.Level);
                strengthItem     = new ItemValueRange(7 + 1 * hero.Level);
                break;

            case HeroClass.WitchDoctor:
            case HeroClass.Wizard:
                dexterityItem    = new ItemValueRange(7 + 1 * hero.Level);
                intelligenceItem = new ItemValueRange(7 + 3 * hero.Level);
                strengthItem     = new ItemValueRange(7 + 1 * hero.Level);
                break;

            case HeroClass.Barbarian:
            case HeroClass.Crusader:
                dexterityItem    = new ItemValueRange(7 + 1 * hero.Level);
                intelligenceItem = new ItemValueRange(7 + 1 * hero.Level);
                strengthItem     = new ItemValueRange(7 + 3 * hero.Level);
                break;
            }

            vitalityItem = new ItemValueRange(7 + 2 * hero.Level);

            critDamagePercent      = new ItemValueRange(0.5);
            critPercentBonusCapped = new ItemValueRange(0.05);
        }
Exemplo n.º 2
0
 private static void PopulateCalculatedData(Control textBox, ItemValueRange itemValueRange)
 {
     if (itemValueRange != null && itemValueRange.Min != 0)
     {
         textBox.Text = itemValueRange.Min.ToString();
     }
 }
Exemplo n.º 3
0
 private static void PopulateCalculatedDataPercent(Control textBox, ItemValueRange itemValueRange)
 {
     if (itemValueRange != null && !itemValueRange.IsZero())
     {
         textBox.Text = (100 * itemValueRange.Min).ToString("N2");
     }
 }
Exemplo n.º 4
0
        public ItemAttributesFromLevel(Follower follower, HeroClass heroClass)
        {
            switch (heroClass)
            {
            case HeroClass.ScoundrelFollower:
                dexterityItem    = new ItemValueRange(8 + 3 * follower.Level);
                intelligenceItem = new ItemValueRange(8 + 1 * follower.Level);
                strengthItem     = new ItemValueRange(9 + 1 * follower.Level);
                vitalityItem     = new ItemValueRange(7 + 2 * follower.Level);
                break;

            case HeroClass.EnchantressFollower:
                dexterityItem    = new ItemValueRange(9 + 1 * follower.Level);
                intelligenceItem = new ItemValueRange(5 + 3 * follower.Level);
                strengthItem     = new ItemValueRange(9 + 1 * follower.Level);
                vitalityItem     = new ItemValueRange(7 + 2 * follower.Level);
                break;

            case HeroClass.TemplarFollower:
                dexterityItem    = new ItemValueRange(8 + 1 * follower.Level);
                intelligenceItem = new ItemValueRange(10 + 1 * follower.Level);
                strengthItem     = new ItemValueRange(7 + 3 * follower.Level);
                vitalityItem     = new ItemValueRange(9 + 2 * follower.Level);
                break;
            }

            critDamagePercent = new ItemValueRange(0.5);
        }
Exemplo n.º 5
0
        private void GuiDoCalculationsForFollower()
        {
            // Retrieve follower from the GUI
            var follower = GetEditedFollower();

            // Retrieve worn items from the GUI
            var items = new List <Item>
            {
                guiItemChoiceSpecial.Tag as Item,
                guiItemChoiceLeftFinger.Tag as Item,
                guiItemChoiceNeck.Tag as Item,
                guiItemChoiceRightFinger.Tag as Item,
                guiSetBonusEditor.GetEditedItem()
            };

            items = items.Where(i => i != null)
                    .Select(i => i.DeepClone())
                    .ToList();

            var mainHand = (guiItemChoiceMainHand.Tag as Item).DeepClone();

            var offHand = (guiItemChoiceOffHand.Tag as Item).DeepClone();

            var heroClass = (HeroClass)Enum.Parse(typeof(HeroClass), (String)(guiHeroClass.SelectedItem));

            var d3Calculator = new D3Calculator(follower, heroClass, mainHand, offHand, items.ToArray());

            // Retrieve used skills from the GUI
            var passiveSkills = new List <ID3SkillModifier>();

            // Some buffs are applied after passives skills: followers skills and active skills
            var activeSkills = new List <ID3SkillModifier>();

            // Followers
            if (guiSkillAnatomy.Checked)
            {
                activeSkills.Add(new Anatomy());
            }
            if (guiSkillFocusedMind.Checked)
            {
                activeSkills.Add(new FocusedMind());
            }
            if (guiSkillPoweredArmor.Checked)
            {
                activeSkills.Add(new PoweredArmor());
            }

            calculatedDps = d3Calculator.GetHeroDps(passiveSkills, activeSkills);

            guiCalculatedDPS.Text = calculatedDps.Min.ToString();

            UpdateItemsSummary(d3Calculator);

            UpdateCalculationResults(d3Calculator);

            DoActionOnCalculatedControls(UpdateResultControlColor);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Checks if <paramref name="value.Min"/> and <paramref name="value.Max"/> are both 0 or almost 0 (using <see cref="Tolerance"/>).
        /// A <c>null</c> <paramref name="value"/> is considered to be 0.
        /// </summary>
        /// <param name="value"></param>
        /// <returns><c>true</c> if <paramref name="value"/> is null or smaller than <see cref="Tolerance"/>.</returns>
        public static bool IsZero(this ItemValueRange value)
        {
            if (value == null)
            {
                return(true);
            }

            return(Math.Abs(value.Min) < Tolerance && Math.Abs(value.Max) < Tolerance);
        }
Exemplo n.º 7
0
 private static void PopulateDataPercent(Control textBox, ItemValueRange itemValueRange)
 {
     if (itemValueRange != null && itemValueRange.Min != 0)
     {
         textBox.Text = (100 * itemValueRange.Min).ToString();
     }
     else
     {
         textBox.Text = String.Empty;
     }
 }
Exemplo n.º 8
0
        public static ItemValueRange SumAsPercentOnRemaining(this IEnumerable <ItemValueRange> itemValueRanges)
        {
            var target = new ItemValueRange();

            foreach (var attr in itemValueRanges.Where(i => i != null))
            {
                ItemValueRange.SumAsPercentOnRemainingIntoLeftOperand(target, attr);
            }

            return(target);
        }
Exemplo n.º 9
0
 private static void PopulateCalculatedData(Control textBox, ItemValueRange itemValueRange)
 {
     if (itemValueRange != null && !itemValueRange.IsZero())
     {
         var round = Math.Round(itemValueRange.Min);
         if (Math.Abs(itemValueRange.Min - round) < 0.0001)
         {
             textBox.Text = itemValueRange.Min.ToString("N0");
         }
         else
         {
             textBox.Text = itemValueRange.Min.ToString("N2");
         }
     }
 }
Exemplo n.º 10
0
 public ThornsMultiplier(double multiplier)
 {
     this.multiplier = new ItemValueRange(multiplier);
 }
Exemplo n.º 11
0
 private static void CopyValue(PropertyInfo info, object target, ItemValueRange value)
 {
     info.SetValue(target, new ItemValueRange(value), null);
 }
Exemplo n.º 12
0
 public static ItemValueRange GetWeaponAttackPerSecond(this Item item, ItemValueRange increaseFromOtherItems)
 {
     return(item.AttributesRaw.GetWeaponAttackPerSecond(increaseFromOtherItems));
 }
Exemplo n.º 13
0
        /// <summary>
        /// Computes weapon attack speed.
        /// </summary>
        /// <param name="weaponAttr">Attributes of used weapon.</param>
        /// <param name="increaseFromOtherItems">Increase Attack Speed from items other than the weapon.</param>
        /// <returns></returns>
        public static ItemValueRange GetWeaponAttackPerSecond(this ItemAttributes weaponAttr, ItemValueRange increaseFromOtherItems)
        {
            var weaponAttackSpeed = weaponAttr.attacksPerSecondItem;

            weaponAttackSpeed *= 1 + weaponAttr.attacksPerSecondItemPercent + increaseFromOtherItems;

            return(weaponAttackSpeed);
        }
Exemplo n.º 14
0
        private void GuiDoCalculationsForHero()
        {
            // Retrieve hero from the GUI
            var hero = GetEditedHero();

            heroLevel = hero.Level;

            // Retrieve worn items from the GUI
            var items = new List <Item>
            {
                guiItemChoiceBracers.Tag as Item,
                guiItemChoiceFeet.Tag as Item,
                guiItemChoiceHands.Tag as Item,
                guiItemChoiceHead.Tag as Item,
                guiItemChoiceLeftFinger.Tag as Item,
                guiItemChoiceLegs.Tag as Item,
                guiItemChoiceNeck.Tag as Item,
                guiItemChoiceRightFinger.Tag as Item,
                guiItemChoiceShoulders.Tag as Item,
                guiItemChoiceTorso.Tag as Item,
                guiItemChoiceWaist.Tag as Item,
                guiSetBonusEditor.GetEditedItem()
            };

            items = items.Where(i => i != null)
                    .Select(i => i.DeepClone())
                    .ToList();

            var mainHand = (guiItemChoiceMainHand.Tag as Item).DeepClone();

            var offHand = (guiItemChoiceOffHand.Tag as Item).DeepClone();

            var d3Calculator = new D3Calculator(hero, mainHand, offHand, items.ToArray());

            // Retrieve used skills from the GUI
            var passiveSkills = passiveCheckBoxes
                                .Where(p => p.Checked)
                                .Select(checkBox => PassiveSkillModifierFactory.GetFromSlug(checkBox.Tag as string))
                                .ToList();

            // Some buffs are applied after passives skills: followers skills and active skills
            var activeSkills = new List <ID3SkillModifier>();

            // Barbarian active skills
            AddActiveSkillIfChecked(activeSkills, guiSkillWarCry_Invigorate, typeof(WarCry_Invigorate));

            // Demon Hunter active skills
            AddActiveSkillIfChecked(activeSkills, guiSkillCompanion_BoarCompanion, typeof(Companion_BoarCompanion));

            // Monk active skills
            AddActiveSkillIfChecked(activeSkills, guiSkillMantraOfHealing_TimeOfNeed, typeof(MantraOfHealing_TimeOfNeed));
            AddActiveSkillIfChecked(activeSkills, guiSkillMantraOfEvasion_HardTarget, typeof(MantraOfEvasion_HardTarget));
            AddActiveSkillIfChecked(activeSkills, guiSkillMantraOfRetribution_Transgression, typeof(MantraOfRetribution_Transgression));
            AddActiveSkillIfChecked(activeSkills, guiSkillMysticAlly_EarthAlly, typeof(MysticAlly_EarthAlly));
            AddActiveSkillIfChecked(activeSkills, guiSkillMysticAlly_FireAlly, typeof(MysticAlly_FireAlly));

            // Witch Doctor active skills

            // Wizard skills

            // Followers
            AddActiveSkillIfChecked(activeSkills, guiSkillAnatomy, typeof(Anatomy));
            AddActiveSkillIfChecked(activeSkills, guiSkillFocusedMind, typeof(FocusedMind));
            AddActiveSkillIfChecked(activeSkills, guiSkillPoweredArmor, typeof(PoweredArmor));

            calculatedDps = d3Calculator.GetHeroDps(passiveSkills, activeSkills);

            UpdateItemsSummary(d3Calculator);

            UpdateCalculationResults(d3Calculator);

            DoActionOnCalculatedControls(UpdateResultControlColor);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Returns <c>null</c> if <paramref name="value"/> is 0-0 of the value if different.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static ItemValueRange NullIfZero(this ItemValueRange value)
 {
     return(value.IsZero() ? null : value);
 }
Exemplo n.º 16
0
 private static void UpdateNodeText(TreeNode node, ItemValueRange d3Object)
 {
     node.Text += " >> [ " + d3Object.Min + " - " + d3Object.Max + "]";
 }
Exemplo n.º 17
0
 private static void UpdateNodeText(TreeNode node, ItemValueRange d3Object)
 {
     node.Text += $" >> [ {d3Object.Min} - {d3Object.Max}]";
 }
Exemplo n.º 18
0
        /// <summary>
        /// Sets the value of an attribute of an ItemAttributes given the attribute's name
        /// </summary>
        /// <param name="itemAttributes">Source attributes</param>
        /// <param name="fieldName">Name of the attribute to retrieve</param>
        /// <param name="value">Value to set</param>
        public static ItemAttributes SetAttributeByName(this ItemAttributes itemAttributes, string fieldName, ItemValueRange value)
        {
            typeof(ItemAttributes).GetTypeInfo().GetDeclaredField(fieldName).SetValue(itemAttributes, value);

            return(itemAttributes);
        }
Exemplo n.º 19
0
 public DamageMultiplier(double multiplier)
 {
     this.multiplier = new ItemValueRange(multiplier);
 }
Exemplo n.º 20
0
 public ResistancesMultiplier(double multiplier)
 {
     this.multiplier = new ItemValueRange(multiplier);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="attributeName">Name of the attribute that will receive the bonus (a field name of <see cref="ItemAttributes"/>).</param>
 /// <param name="bonusPerPoint">Bonus increment for each paragon point.</param>
 /// <param name="maxPoints">Max paragon point in this entry (0 for infinite).</param>
 public ParagonBonus(string attributeName, ItemValueRange bonusPerPoint, int maxPoints)
 {
     AttributeName = attributeName;
     BonusPerPoint = bonusPerPoint;
     MaxPoints     = maxPoints;
 }