public Item(dynamic o) { Id = (int)o.id; Name = o.name; Description = o.sanitizedDescription; GoldCost = (int)o.gold.total.Value; ItemStats = new ItemStats(o.stats, Name); }
public static IList <ApTimeLine> GetPlayerApTimeline(Player p, string patch, int matchId, int teamId) { try { IList <ApTimeLine> timelines = new List <ApTimeLine>(); var orderedTime = p.ItemTimeLine.OrderBy(a => a.TimeStamp).ToList(); IDictionary <int, double> apPerMin = new Dictionary <int, double>(); var items = new List <Item>(); var groups = orderedTime.GroupBy(a => (int)Math.Truncate((double)a.TimeStamp / 60000)); var runesAp = p.Runes.Sum(r => r.Ap); var runesApPerLv = p.Runes.Sum(r => r.ApPerLevel); var runesMr = p.Runes.Sum(r => r.MagicResist); var runesMrPerLv = p.Runes.Sum(r => r.MagicResistPerLevel); foreach (var group in groups) { try { var t = new ApTimeLine(); t.Minute = group.Key; var lv = p.TimeLine[t.Minute].Level; t.PlayerId = p.ParticipantId; t.MatchId = matchId; t.TeamId = teamId; foreach (var itemTimeline in group) { Item item; if (patch.StartsWith("5.11")) { item = ItemsCache.GetItemV511(itemTimeline.ItemId); } else { item = ItemsCache.GetItemV514(itemTimeline.ItemId); } double itemAp = 0; if (itemTimeline.EventType == "ITEM_PURCHASED") { items.Add(item); } else { items.Remove(item); } double totalAp = items.Sum(i => ItemStats.GetTotalAP(i, t.Minute, p.SelectedChampion)) + runesAp + runesApPerLv * lv; if (items.Any(i => i.Name == "Rabadon's Deathcap")) { if (patch.StartsWith("5.11")) { totalAp = totalAp * 1.30; } else { totalAp = totalAp * 1.35; } } if (apPerMin.ContainsKey(t.Minute)) { apPerMin[t.Minute] = totalAp; } else { apPerMin.Add(new KeyValuePair <int, double>(t.Minute, totalAp)); } } t.Items = items.ToList(); t.CurrentGold = p.TimeLine[t.Minute].CurrentGold; t.GoldSpent = items.Sum(i => i.GoldCost); t.TotalMr = items.Sum(i => i.ItemStats.MR) + p.SelectedChampion.Stat.MagicResist + p.SelectedChampion.Stat.MagicResistPerLv * lv + runesMr + runesMrPerLv * lv;; t.TotalAp = apPerMin.LastOrDefault().Value; timelines.Add(t); } catch { throw; } } return(timelines); } catch { throw; } }