Beispiel #1
0
 public void GetHitpointsPerVitalityFactor()
 {
     Assert.AreEqual(100, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 70));
     Assert.AreEqual(90, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 69));
     Assert.AreEqual(80, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 68));
     Assert.AreEqual(70, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 67));
     Assert.AreEqual(60, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 66));
     Assert.AreEqual(55, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 65));
     Assert.AreEqual(25, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 50));
     Assert.AreEqual(11, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 36));
     Assert.AreEqual(10, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 35));
     Assert.AreEqual(10, D3Calculator.GetHitpointsPerVitalityFactor(HeroClass.Monk, 1));
 }
        private void UpdateItemsSummary(D3Calculator d3Calculator)
        {
            var attr = d3Calculator.HeroStatsItem.AttributesRaw;

            PopulateCalculatedData(guiItemsDexterity, attr.dexterityItem);
            PopulateCalculatedData(guiItemsIntelligence, attr.intelligenceItem);
            PopulateCalculatedData(guiItemsStrength, attr.strengthItem);
            PopulateCalculatedData(guiItemsVitality, attr.vitalityItem);

            PopulateCalculatedDataPercent(guiItemsCriticChance, attr.critPercentBonusCapped);
            PopulateCalculatedDataPercent(guiItemsSpeedAttack, attr.attacksPerSecondPercent);
            PopulateCalculatedDataPercent(guiItemsCriticDamage, attr.critDamagePercent);
            PopulateCalculatedDataPercent(guiItemsLifePercent, attr.hitpointsMaxPercentBonusItem);
            PopulateCalculatedData(guiItemsLifeOnHit, attr.hitpointsOnHit);
            PopulateCalculatedData(guiItemsLifePerSecond, attr.hitpointsRegenPerSecond);
            PopulateCalculatedDataPercent(guiItemsLifeSteal, attr.stealHealthPercent);

            PopulateCalculatedData(guiItemsResistance_All, attr.resistance_All);
            PopulateCalculatedData(guiItemsResistance_Arcane, attr.resistance_Arcane);
            PopulateCalculatedData(guiItemsResistance_Cold, attr.resistance_Cold);
            PopulateCalculatedData(guiItemsResistance_Fire, attr.resistance_Fire);
            PopulateCalculatedData(guiItemsResistance_Lightning, attr.resistance_Lightning);
            PopulateCalculatedData(guiItemsResistance_Physical, attr.resistance_Physical);
            PopulateCalculatedData(guiItemsResistance_Poison, attr.resistance_Poison);
        }
        private void UpdateCalculationResults(D3Calculator d3Calculator)
        {
            var attr = d3Calculator.HeroStatsItem.AttributesRaw;

            guiCalculatedAttackPerSecond.Text = d3Calculator.GetActualAttackSpeed().Min.ToString();
            PopulateCalculatedData(guiCalcultatedDamageMin, d3Calculator.HeroStatsItem.GetWeaponDamageMin() * d3Calculator.GetDamageMultiplierNormal());
            PopulateCalculatedData(guiCalcultatedDamageMax, d3Calculator.HeroStatsItem.GetWeaponDamageMax() * d3Calculator.GetDamageMultiplierNormal());
            PopulateCalculatedData(guiCalcultatedDamageCriticMin, d3Calculator.HeroStatsItem.GetWeaponDamageMin() * d3Calculator.GetDamageMultiplierCritic());
            PopulateCalculatedData(guiCalcultatedDamageCriticMax, d3Calculator.HeroStatsItem.GetWeaponDamageMax() * d3Calculator.GetDamageMultiplierCritic());
            PopulateCalculatedData(guiCalculatedHitpoints, d3Calculator.GetHeroHitpoints());
            guiCalculatedDodge.Text = d3Calculator.GetHeroDodge().ToString();

            PopulateCalculatedData(guiCalculatedArmor, d3Calculator.GetHeroArmor());
            PopulateCalculatedData(guiCalculatedResistance_Arcane, d3Calculator.GetHeroResistance("Arcane"));
            PopulateCalculatedData(guiCalculatedResistance_Cold, d3Calculator.GetHeroResistance("Cold"));
            PopulateCalculatedData(guiCalculatedResistance_Fire, d3Calculator.GetHeroResistance("Fire"));
            PopulateCalculatedData(guiCalculatedResistance_Lightning, d3Calculator.GetHeroResistance("Lightning"));
            PopulateCalculatedData(guiCalculatedResistance_Physical, d3Calculator.GetHeroResistance("Physical"));
            PopulateCalculatedData(guiCalculatedResistance_Poison, d3Calculator.GetHeroResistance("Poison"));
            PopulateCalculatedData(guiCalculatedResistance_All, d3Calculator.getHeroResistance_All());

            guiCalculatedDamageReduction_Armor.Text = (100 * d3Calculator.GetHeroDamageReduction_Armor(heroLevel)).ToString();
            guiCalculatedDamageReduction_Arcane.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Arcane")).ToString();
            guiCalculatedDamageReduction_Cold.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Cold")).ToString();
            guiCalculatedDamageReduction_Fire.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Fire")).ToString();
            guiCalculatedDamageReduction_Lightning.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Lightning")).ToString();
            guiCalculatedDamageReduction_Physical.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Physical")).ToString();
            guiCalculatedDamageReduction_Poison.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Poison")).ToString();

            PopulateCalculatedData(guiCalculatedBlockChance, attr.blockChanceItem);
            PopulateCalculatedData(guiCalculatedBlockMin, attr.blockAmountItemMin);
            PopulateCalculatedData(guiCalculatedBlockMax, attr.blockAmountItemMin + attr.blockAmountItemDelta);

            guiCalculatedEffectiveHitpoints.Text = Math.Round(d3Calculator.GetHeroEffectiveHitpoints(heroLevel)).ToString();
            guiCalculatedDPSEHPRatio.Text = Math.Round(d3Calculator.GetHeroDps().Min * d3Calculator.GetHeroEffectiveHitpoints(heroLevel) / 1000000).ToString();
        }
        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>
            {
                guiBracersEditor.GetEditedItem(),
                guiFeetEditor.GetEditedItem(),
                guiHandsEditor.GetEditedItem(),
                guiHeadEditor.GetEditedItem(),
                guiLeftFingerEditor.GetEditedItem(),
                guiLegsEditor.GetEditedItem(),
                guiNeckEditor.GetEditedItem(),
                guiRightFingerEditor.GetEditedItem(),
                guiShouldersEditor.GetEditedItem(),
                guiTorsoEditor.GetEditedItem(),
                guiWaistEditor.GetEditedItem(),
                guiSetBonusEditor.GetEditedItem()
            };

            var mainHand = guiMainHandEditor.GetEditedItem();

            var offHand = guiOffHandEditor.GetEditedItem();

            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
            if (guiSkillWarCry_Invigorate.Checked)
            {
                activeSkills.Add(new WarCry_Invigorate());
            }

            // Demon Hunter active skills

            // Monk active skills
            if (guiSkillMantraOfHealing_TimeOfNeed.Checked)
            {
                activeSkills.Add(new MantraOfHealing_TimeOfNeed());
            }
            if (guiSkillMantraOfEvasion_HardTarget.Checked)
            {
                activeSkills.Add(new MantraOfEvasion_HardTarget());
            }
            if (guiSkillMysticAlly_EarthAlly.Checked)
            {
                activeSkills.Add(new MysticAlly_EarthAlly());
            }

            // Witch Doctor active skills

            // Wizard skills

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

            guiCalculatedDPS.Text = d3Calculator.GetHeroDps(passiveSkills, activeSkills).Min.ToString();

            UpdateItemsSummary(d3Calculator);

            UpdateCalculationResults(d3Calculator);
        }
        private void GuiDoCalculationsForFollower()
        {
            // Retrieve follower from the GUI
            var follower = GetEditedFollower();

            // Retrieve worn items from the GUI
            var items = new List<Item>
            {
                guiSpecialEditor.GetEditedItem(),
                guiLeftFingerEditor.GetEditedItem(),
                guiNeckEditor.GetEditedItem(),
                guiRightFingerEditor.GetEditedItem(),
                guiSetBonusEditor.GetEditedItem()
            };

            var mainHand = guiMainHandEditor.GetEditedItem();

            var offHand = guiOffHandEditor.GetEditedItem();

            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());
            }

            guiCalculatedDPS.Text = d3Calculator.GetHeroDps(passiveSkills, activeSkills).Min.ToString();

            UpdateItemsSummary(d3Calculator);

            UpdateCalculationResults(d3Calculator);
        }
Beispiel #6
0
        private static async Task WriteCalculation(BattleTag battleTag)
        {
            Console.WriteLine("= = = = Calculator of {0} = = = =", battleTag);

            Console.WriteLine("Downloading {0}", "career");
            var career = await D3Api.GetCareerFromBattleTagAsync(battleTag);
            if (career == null || career.Heroes.Length == 0)
            {
                return;
            }

            Console.WriteLine("Downloading Hero {0}/{1}", battleTag, career.Heroes[0].Name);
            var hero = await D3Api.GetHeroFromHeroIdAsync(battleTag, career.Heroes[0].Id);
            if (hero?.Items == null)
            {
                return;
            }

            var bracersTask = GetFullItem(hero.Items.Bracers, "bracers");
            var feetTask = GetFullItem(hero.Items.Feet, "feet");
            var handsTask = GetFullItem(hero.Items.Hands, "hands");
            var headTask = GetFullItem(hero.Items.Hands, "head");
            var leftFingerTask = GetFullItem(hero.Items.LeftFinger, "leftFinger");
            var legsTask = GetFullItem(hero.Items.Legs, "legs");
            var mainHandTask = GetFullItem(hero.Items.MainHand, "mainHand");
            var neckTask = GetFullItem(hero.Items.Neck, "neck");
            var offHandTask = GetFullItem(hero.Items.OffHand, "offHand");
            var rightFingerTask = GetFullItem(hero.Items.RightFinger, "rightFinger");
            var shouldersTask = GetFullItem(hero.Items.Shoulders, "shoulders");
            var torsoTask = GetFullItem(hero.Items.Torso, "torso");
            var waistTask = GetFullItem(hero.Items.Waist, "waist");

            Task.WaitAll(bracersTask, feetTask, handsTask, headTask, leftFingerTask, legsTask, mainHandTask, neckTask, offHandTask, rightFingerTask, shouldersTask, torsoTask, waistTask);

            var bracers = bracersTask.Result;
            var feet = feetTask.Result;
            var hands = handsTask.Result;
            var head = headTask.Result;
            var leftFinger = leftFingerTask.Result;
            var legs = legsTask.Result;
            var mainHand = mainHandTask.Result;
            var neck = neckTask.Result;
            var offHand = offHandTask.Result;
            var rightFinger = rightFingerTask.Result;
            var shoulders = shouldersTask.Result;
            var torso = torsoTask.Result;
            var waist = waistTask.Result;

            var items = new List<Item> { bracers, feet, hands, head, leftFinger, legs, neck, rightFinger, shoulders, torso, waist }.Where(i => i != null).ToList();

            var allItems = new List<Item>(items) { mainHand, offHand }.Where(i => i != null).ToList();

            Console.WriteLine("Calculating activated set");
            foreach (var set in allItems.GetActivatedSets())
            {
                Console.WriteLine("Activated set: {0}", set.name);
            }
            var setBonus = new Item(allItems.GetActivatedSetBonus());
            items.Add(setBonus);

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

            Console.WriteLine("Calculation results");
            var dps = d3Calculator.GetHeroDps(new List<ID3SkillModifier>(), new List<ID3SkillModifier>());
            Console.WriteLine("Dexterity : {0}", d3Calculator.GetHeroDexterity().Min);
            Console.WriteLine("DPS : {0}", dps.Min);
            Console.WriteLine("Attack speed: {0}", d3Calculator.GetActualAttackSpeed().Min);
        }
        private void UpdateCalculationResults(D3Calculator d3Calculator)
        {
            var attr = d3Calculator.HeroStatsItem.AttributesRaw;

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

            guiCalculatedAttackPerSecond.Text = d3Calculator.GetActualAttackSpeed().Min.ToString("N2");
            PopulateCalculatedData(guiCalcultatedDamageMin, d3Calculator.HeroStatsItem.GetWeaponDamageMin() * d3Calculator.GetDamageMultiplierNormal());
            PopulateCalculatedData(guiCalcultatedDamageMax, d3Calculator.HeroStatsItem.GetWeaponDamageMax() * d3Calculator.GetDamageMultiplierNormal());
            PopulateCalculatedData(guiCalcultatedDamageCriticMin, d3Calculator.HeroStatsItem.GetWeaponDamageMin() * d3Calculator.GetDamageMultiplierCritic());
            PopulateCalculatedData(guiCalcultatedDamageCriticMax, d3Calculator.HeroStatsItem.GetWeaponDamageMax() * d3Calculator.GetDamageMultiplierCritic());

            PopulateCalculatedDataPercent(guiCalculatedSkillBonusPercent_Arcane, attr.damageDealtPercentBonusArcane);
            PopulateCalculatedDataPercent(guiCalculatedSkillBonusPercent_Cold, attr.damageDealtPercentBonusCold);
            PopulateCalculatedDataPercent(guiCalculatedSkillBonusPercent_Fire, attr.damageDealtPercentBonusFire);
            PopulateCalculatedDataPercent(guiCalculatedSkillBonusPercent_Holy, attr.damageDealtPercentBonusHoly);
            PopulateCalculatedDataPercent(guiCalculatedSkillBonusPercent_Lightning, attr.damageDealtPercentBonusLightning);
            PopulateCalculatedDataPercent(guiCalculatedSkillBonusPercent_Physical, attr.damageDealtPercentBonusPhysical);
            PopulateCalculatedDataPercent(guiCalculatedSkillBonusPercent_Poison, attr.damageDealtPercentBonusPoison);

            PopulateCalculatedData(guiCalculatedSkillDamage_Arcane, calculatedDps * (1 + attr.damageDealtPercentBonusArcane));
            PopulateCalculatedData(guiCalculatedSkillDamage_Cold, calculatedDps * (1 + attr.damageDealtPercentBonusCold));
            PopulateCalculatedData(guiCalculatedSkillDamage_Fire, calculatedDps * (1 + attr.damageDealtPercentBonusFire));
            PopulateCalculatedData(guiCalculatedSkillDamage_Holy, calculatedDps * (1 + attr.damageDealtPercentBonusHoly));
            PopulateCalculatedData(guiCalculatedSkillDamage_Lightning, calculatedDps * (1 + attr.damageDealtPercentBonusLightning));
            PopulateCalculatedData(guiCalculatedSkillDamage_Physical, calculatedDps * (1 + attr.damageDealtPercentBonusPhysical));
            PopulateCalculatedData(guiCalculatedSkillDamage_Poison, calculatedDps * (1 + attr.damageDealtPercentBonusPoison));

            PopulateCalculatedData(guiCalculatedSkillDamageVsElites_Arcane, calculatedDps * (1 + attr.damageDealtPercentBonusArcane) * (1 + attr.damagePercentBonusVsElites));
            PopulateCalculatedData(guiCalculatedSkillDamageVsElites_Cold, calculatedDps * (1 + attr.damageDealtPercentBonusCold) * (1 + attr.damagePercentBonusVsElites));
            PopulateCalculatedData(guiCalculatedSkillDamageVsElites_Fire, calculatedDps * (1 + attr.damageDealtPercentBonusFire) * (1 + attr.damagePercentBonusVsElites));
            PopulateCalculatedData(guiCalculatedSkillDamageVsElites_Holy, calculatedDps * (1 + attr.damageDealtPercentBonusHoly) * (1 + attr.damagePercentBonusVsElites));
            PopulateCalculatedData(guiCalculatedSkillDamageVsElites_Lightning, calculatedDps * (1 + attr.damageDealtPercentBonusLightning) * (1 + attr.damagePercentBonusVsElites));
            PopulateCalculatedData(guiCalculatedSkillDamageVsElites_Physical, calculatedDps * (1 + attr.damageDealtPercentBonusPhysical) * (1 + attr.damagePercentBonusVsElites));
            PopulateCalculatedData(guiCalculatedSkillDamageVsElites_Poison, calculatedDps * (1 + attr.damageDealtPercentBonusPoison) * (1 + attr.damagePercentBonusVsElites));

            PopulateCalculatedDataPercent(guiSkillCooldownReductionAll, attr.powerCooldownReductionPercentAll);

            PopulateCalculatedDataPercent(guiCalculatedReductionFromElitesPercent, attr.damagePercentReductionFromElites);
            PopulateCalculatedDataPercent(guiCalculatedReductionFromMeleePercent, attr.damagePercentReductionFromMelee);
            PopulateCalculatedDataPercent(guiCalculatedReductionFromRangedPercent, attr.damagePercentReductionFromRanged);

            PopulateCalculatedData(guiCalculatedHitpoints, d3Calculator.GetHeroHitpoints());
            guiCalculatedDodge.Text = d3Calculator.GetHeroDodge().ToString();

            PopulateCalculatedData(guiCalculatedArmor, d3Calculator.GetHeroArmor());
            PopulateCalculatedData(guiCalculatedResistance_Arcane, d3Calculator.GetHeroResistance("Arcane"));
            PopulateCalculatedData(guiCalculatedResistance_Cold, d3Calculator.GetHeroResistance("Cold"));
            PopulateCalculatedData(guiCalculatedResistance_Fire, d3Calculator.GetHeroResistance("Fire"));
            PopulateCalculatedData(guiCalculatedResistance_Lightning, d3Calculator.GetHeroResistance("Lightning"));
            PopulateCalculatedData(guiCalculatedResistance_Physical, d3Calculator.GetHeroResistance("Physical"));
            PopulateCalculatedData(guiCalculatedResistance_Poison, d3Calculator.GetHeroResistance("Poison"));
            PopulateCalculatedData(guiCalculatedResistance_All, d3Calculator.GetHeroResistance_All());

            guiCalculatedDamageReduction_Armor.Text = (100 * d3Calculator.GetHeroDamageReduction_Armor(heroLevel)).ToString("N2");
            guiCalculatedDamageReduction_Arcane.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Arcane")).ToString("N2");
            guiCalculatedDamageReduction_Cold.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Cold")).ToString("N2");
            guiCalculatedDamageReduction_Fire.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Fire")).ToString("N2");
            guiCalculatedDamageReduction_Lightning.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Lightning")).ToString("N2");
            guiCalculatedDamageReduction_Physical.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Physical")).ToString("N2");
            guiCalculatedDamageReduction_Poison.Text = (100 * d3Calculator.GetHeroDamageReduction(heroLevel, "Poison")).ToString("N2");

            PopulateCalculatedData(guiCalculatedBlockChance, attr.blockChanceItem);
            PopulateCalculatedData(guiCalculatedBlockMin, attr.blockAmountItemMin);
            PopulateCalculatedData(guiCalculatedBlockMax, attr.blockAmountItemMin + attr.blockAmountItemDelta);

            guiCalculatedEffectiveHitpoints.Text = Math.Round(d3Calculator.GetHeroEffectiveHitpoints(heroLevel)).ToString("N0");
            guiCalculatedDPSEHPRatio.Text = Math.Round(d3Calculator.GetHeroDps().Min * d3Calculator.GetHeroEffectiveHitpoints(heroLevel) / 1000000).ToString("N0");
        }
        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);
        }
        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);
        }
Beispiel #10
0
        private static void WriteCalculation(BattleTag battleTag)
        {
            Console.WriteLine("= = = = Calculator of {0} = = = =", battleTag);

            Console.WriteLine("Downloading {0}", "career");
            var career = Career.CreateFromBattleTag(battleTag);
            if (career == null || career.Heroes.Length == 0)
            {
                return;
            }

            Console.WriteLine("Downloading Hero {0}/{1}", battleTag, career.Heroes[0].name);
            var hero = Hero.CreateFromHeroId(battleTag, career.Heroes[0].id);
            if (hero == null || hero.items == null)
            {
                return;
            }

            Console.WriteLine("Downloading {0}", "bracers");
            var bracers = hero.items.bracers.GetFullItem();
            Console.WriteLine("Downloading {0}", "feet");
            var feet = hero.items.feet.GetFullItem();
            Console.WriteLine("Downloading {0}", "hands");
            var hands = hero.items.hands.GetFullItem();
            Console.WriteLine("Downloading {0}", "head");
            var head = hero.items.head.GetFullItem();
            Console.WriteLine("Downloading {0}", "leftFinger");
            var leftFinger = hero.items.leftFinger.GetFullItem();
            Console.WriteLine("Downloading {0}", "legs");
            var legs = hero.items.legs.GetFullItem();
            Console.WriteLine("Downloading {0}", "mainHand");
            var mainHand = hero.items.mainHand.GetFullItem();
            Console.WriteLine("Downloading {0}", "neck");
            var neck = hero.items.neck.GetFullItem();
            Console.WriteLine("Downloading {0}", "offHand");
            var offHand = hero.items.offHand.GetFullItem();
            Console.WriteLine("Downloading {0}", "rightFinger");
            var rightFinger = hero.items.rightFinger.GetFullItem();
            Console.WriteLine("Downloading {0}", "shoulders");
            var shoulders = hero.items.shoulders.GetFullItem();
            Console.WriteLine("Downloading {0}", "torso");
            var torso = hero.items.torso.GetFullItem();
            Console.WriteLine("Downloading {0}", "waist");
            var waist = hero.items.waist.GetFullItem();

            var items = new List<Item> { bracers, feet, hands, head, leftFinger, legs, neck, rightFinger, shoulders, torso, waist }.Where(i => i != null).ToList();

            var allItems = new List<Item>(items) { mainHand, offHand }.Where(i => i != null).ToList();

            Console.WriteLine("Calculating activated set");
            foreach (var set in allItems.GetActivatedSets())
            {
                Console.WriteLine("Activated set: {0}", set.name);
            }
            var setBonus = new Item(allItems.GetActivatedSetBonus());
            items.Add(setBonus);

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

            Console.WriteLine("Calculation results");
            var dps = d3Calculator.GetHeroDps(new List<ID3SkillModifier>(), new List<ID3SkillModifier>());
            Console.WriteLine("Dexterity : {0}", d3Calculator.GetHeroDexterity().Min);
            Console.WriteLine("DPS : {0}", dps.Min);
            Console.WriteLine("Attack speed: {0}", d3Calculator.GetActualAttackSpeed().Min);
        }