Esempio n. 1
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);
        }
Esempio n. 2
0
 /// <inheritdoc />
 public ItemAttributes GetBonus(D3Calculator calculator)
 {
     return new ItemAttributes { armorBonusItem = new ItemValueRange(calculator.GetHeroDexterity()) * (new ItemValueRange(0.5)) };
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
 /// <inheritdoc />
 public ItemAttributes GetBonus(D3Calculator calculator)
 {
     return(new ItemAttributes {
         armorBonusItem = new ItemValueRange(calculator.GetHeroDexterity()) * (new ItemValueRange(0.5))
     });
 }