static Weights()
 {
     ItemCache = new SimpleCache <float> {
         MaxAge = MinCaching
     };
     LongCache = new SimpleCache <float> {
         MaxAge = 3000
     };
     InvertedPrefix = "[i]";
     CustomPrefix   = "[c]";
     PItems         = new List <Item>();
     PItems.AddRange(
         new List <Item>
     {
         new Item(
             "killable", "AA Killable", 20, false,
             t => t.Health < ObjectManager.Player.GetAutoAttackDamage(t, true) ? 1 : 0,
             "Checks if target is killable with one auto attack."),
         new Item(
             "attack-damage", "Attack Damage", 15, false, delegate(Obj_AI_Hero t)
         {
             var ad       = t.FlatPhysicalDamageMod;
             var infinity = LongCache.GetOrAdd(
                 "infinity-edge-" + t.ChampionName,
                 () => ItemData.Infinity_Edge.GetItem().IsOwned(t) ? 2.5f : 2);
             ad += ad / 100 * (t.Crit * 100) * (infinity ?? 1f);
             var averageArmor = LongCache.GetOrAdd(
                 "average-armor",
                 delegate
             {
                 return(HeroManager.Allies.Select(a => a.Armor).DefaultIfEmpty(0).Average() *
                        t.PercentArmorPenetrationMod - t.FlatArmorPenetrationMod);
             });
             return(ad * (100 / (100 + (averageArmor ?? 0))) *
                    (1f / ObjectManager.Player.AttackDelay));
         }, "AD + Pen + Crit + Speed = Higher Weight"),
         new Item(
             "ability-power", "Ability Power", 15, false, delegate(Obj_AI_Hero t)
         {
             var averageMr = LongCache.GetOrAdd(
                 "average-magic-resist",
                 delegate
             {
                 return
                 (HeroManager.Allies.Select(a => a.SpellBlock).DefaultIfEmpty(0).Average() *
                  t.PercentMagicPenetrationMod - t.FlatMagicPenetrationMod);
             });
             return(t.FlatMagicDamageMod * (100 / (100 + (averageMr ?? 0))));
         }, "AP + Pen = Higher Weight"),
         new Item(
             "low-resists", "Resists", 0, true,
             t =>
             ObjectManager.Player.FlatPhysicalDamageMod >= ObjectManager.Player.FlatMagicDamageMod
                         ? t.Armor
                         : t.SpellBlock, "Low Armor / Magic-Resist = Higher Weight"),
         new Item("low-health", "Health", 20, true, t => t.Health, "Low Health = Higher Weight"),
         new Item(
             "short-distance-player", "Distance to Player", 5, true,
             t => t.Distance(ObjectManager.Player), "Close to Player = Higher Weight"),
         new Item(
             "short-distance-cursor", "Distance to Cursor", 0, true, t => t.Distance(Game.CursorPos),
             "Close to Cursor = Higher Weight"),
         new Item(
             "crowd-control", "Crowd Control", 0, false, delegate(Obj_AI_Hero t)
         {
             var buffs =
                 t.Buffs.Where(
                     x =>
                     x.Type == BuffType.Charm || x.Type == BuffType.Knockback ||
                     x.Type == BuffType.Suppression || x.Type == BuffType.Fear ||
                     x.Type == BuffType.Taunt || x.Type == BuffType.Stun ||
                     x.Type == BuffType.Slow || x.Type == BuffType.Silence ||
                     x.Type == BuffType.Snare || x.Type == BuffType.Polymorph).ToList();
             return(buffs.Any() ? buffs.Select(x => x.EndTime).DefaultIfEmpty(0).Max() : 0);
         }, "Checks if the target suffers from any form of crowd control."),
         new Item(
             "gold", "Acquired Gold", 0, false,
             t =>
             (t.MinionsKilled + t.NeutralMinionsKilled) * 27.35f + t.ChampionsKilled * 300f +
             t.Assists * 85f, "Calculates the approx. amount of Gold."),
         new Item(
             "team-focus", "Team Focus", 0, false,
             t =>
             Aggro.Items.Where(a => a.Value.Target.Hero.NetworkId == t.NetworkId)
             .Select(a => a.Value.Value)
             .DefaultIfEmpty(0)
             .Sum(), "Checks who your allies are targeting."),
         new Item(
             "focus-me", "Focus Me", 0, false, delegate(Obj_AI_Hero t)
         {
             var entry = Aggro.GetSenderTargetItem(t, ObjectManager.Player);
             return(entry != null ? entry.Value : 0);
         }, "Checks who is targeting you.")
     });
 }
        static Weights()
        {
            try
            {
                _drawingTargets = new List <Targets.Item>();
                Items           = new HashSet <Item>
                {
                    new Item(
                        "killable", "AA Killable", 20, false,
                        t => t.Health < ObjectManager.Player.GetAutoAttackDamage(t, true) ? 10 : 0),
                    new Item(
                        "attack-damage", "Attack Damage", 15, false, delegate(Obj_AI_Hero t)
                    {
                        var ad           = t.FlatPhysicalDamageMod;
                        ad              += ad / 100 * (t.Crit * 100) * (t.HasItem(ItemData.Infinity_Edge.Id) ? 2.5f : 2f);
                        var averageArmor = GameObjects.AllyHeroes.Select(a => a.Armor).DefaultIfEmpty(0).Average() *
                                           t.PercentArmorPenetrationMod - t.FlatArmorPenetrationMod;
                        return((ad * (100 / (100 + (averageArmor > 0 ? averageArmor : 0)))) * t.AttackSpeedMod);
                    }),
                    new Item(
                        "ability-power", "Ability Power", 15, false, delegate(Obj_AI_Hero t)
                    {
                        var averageMr =
                            GameObjects.AllyHeroes.Select(a => a.SpellBlock).DefaultIfEmpty(0).Average() *
                            t.PercentMagicPenetrationMod - t.FlatMagicPenetrationMod;
                        return(t.FlatMagicDamageMod * (100 / (100 + (averageMr > 0 ? averageMr : 0))));
                    }),
                    new Item(
                        "low-resists", "Resists", 0, true,
                        t =>
                        ObjectManager.Player.FlatPhysicalDamageMod >= ObjectManager.Player.FlatMagicDamageMod
                                ? t.Armor
                                : t.SpellBlock),
                    new Item("low-health", "Health", 20, true, t => t.Health),
                    new Item(
                        "short-distance-player", "Distance to Player", 5, true, t => t.Distance(ObjectManager.Player)),
                    new Item("short-distance-cursor", "Distance to Cursor", 0, true, t => t.Distance(Game.CursorPos)),
                    new Item(
                        "crowd-control", "Crowd Control", 0, false, delegate(Obj_AI_Hero t)
                    {
                        var buffs =
                            t.Buffs.Where(
                                x =>
                                x.Type == BuffType.Charm || x.Type == BuffType.Knockback ||
                                x.Type == BuffType.Suppression || x.Type == BuffType.Fear ||
                                x.Type == BuffType.Taunt || x.Type == BuffType.Stun || x.Type == BuffType.Slow ||
                                x.Type == BuffType.Silence || x.Type == BuffType.Snare ||
                                x.Type == BuffType.Polymorph).ToList();
                        return(buffs.Any() ? buffs.Max(x => x.EndTime) + 1f : 0f);
                    }),
                    new Item(
                        "gold", "Acquired Gold", 0, false,
                        t =>
                        (t.MinionsKilled + t.NeutralMinionsKilled) * 22.35f + t.ChampionsKilled * 300f +
                        t.Assists * 95f),
                    new Item(
                        "team-focus", "Team Focus", 0, false,
                        t =>
                        Aggro.Items.Where(a => a.Value.Target.Hero.NetworkId == t.NetworkId)
                        .Select(a => a.Value.Value)
                        .DefaultIfEmpty(0)
                        .Sum()),
                    new Item(
                        "focus-me", "Focus Me", 0, false, delegate(Obj_AI_Hero t)
                    {
                        var entry = Aggro.GetSenderTargetEntry(t, ObjectManager.Player);
                        return(entry != null ? entry.Value + 1f : 0);
                    })
                };

                Average  = (float)Items.Select(w => w.Weight).DefaultIfEmpty(0).Average();
                MaxRange = 2000f;
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }