Beispiel #1
0
 private static ICollection <StatValue> GetTopHeroStatValues(RawStats rawStats) =>
 rawStats.TopHeroes.ToList().SelectMany(kvp => typeof(TopHero)
                                        .GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
                                        .Select(prop => new StatValue
 {
     HeroName = kvp.Key,
     Name     = prop.Name,
     Value    = prop.GetValue(kvp.Value)
 })).ToList();
Beispiel #2
0
 private static ICollection <StatValue> GetCareerStatsStatValues(RawStats rawStats) =>
 rawStats.CareerStats.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
 .Select(hp => new { HeroName = hp.Name, Hero = hp.GetValue(rawStats.CareerStats) })
 .Where(hp => hp.Hero != null)
 .SelectMany(h => h.Hero.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
             .Select(hsp => new { CategoryName = hsp.Name, CategoryStats = hsp.GetValue(h.Hero) })
             .Where(hsp => hsp.CategoryStats != null)
             .SelectMany(a => a.CategoryStats.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).ToList()
                         .Select(csp => new StatValue
 {
     HeroName     = h.HeroName,
     CategoryName = a.CategoryName,
     Name         = csp.Name,
     Value        = csp.GetValue(a.CategoryStats)
 }))).ToList();
Beispiel #3
0
        public void UpdateFromItem(Item item)
        {
            // Experimental! but should be 100x faster
            string itemStatsJson = AmeisenCore.GetLocalizedText(GetItemStats.Lua(item.Slot), GetItemStats.OutVar());

            AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"GetItemStatsLuaJSON: {itemStatsJson}", this);
            // parse this JSON
            try
            {
                RawStats rawItem = JsonConvert.DeserializeObject <RawStats>(itemStatsJson);
                Armor       = rawItem.armor;
                Strenght    = rawItem.strenght;
                Agility     = rawItem.agility;
                Stamina     = rawItem.stamina;
                Intellect   = rawItem.intellect;
                Spirit      = rawItem.spirit;
                Attackpower = rawItem.attackpower;
                Spellpower  = rawItem.spellpower;
                Mana        = rawItem.mana;
            }
            catch { }
        }
Beispiel #4
0
 internal static Stat ParseStat(RawStats rawStats) =>
 new Stat
 {
     TopHeroes   = GetTopHeroStatValues(rawStats),
     CareerStats = GetCareerStatsStatValues(rawStats)
 };