public static ApTimeLine Mapper(MySqlDataReader reader) { var a = new ApTimeLine(); a.MatchId = reader.GetInt32("MatchId"); a.PlayerId = reader.GetInt32("ParticipantId"); a.Rank = reader.GetString("Rank"); a.ChampionId = reader.GetInt32("ChampionId"); a.Role = reader.GetString("Role"); a.Lane = reader.GetString("Lane"); a.TeamId = reader.GetInt32("TeamId"); a.Minute = reader.GetInt32("Minute"); a.TotalAp = reader.GetInt32("TotalAP"); a.TotalMr = reader.GetInt32("TotalMR"); var itemsIds = reader.GetString("ItemsIds"); a.Patch = reader.GetString("Patch"); a.Items = new List <Item>(); foreach (var itemId in itemsIds.Split(new [] { '|' }, StringSplitOptions.RemoveEmptyEntries)) { if (a.Patch.Contains("5.11")) { a.Items.Add(ItemsCache.GetItemV511(int.Parse(itemId))); } else { a.Items.Add(ItemsCache.GetItemV514(int.Parse(itemId))); } } return(a); }
public FinalStats(dynamic o, string patch) { MagicDamageDealtToChampions = (int)o.magicDamageDealtToChampions.Value; PhysicalDamageDealtToChampions = (int)o.physicalDamageDealtToChampions.Value; TrueDamageDealtToChampions = (int)o.trueDamageDealtToChampions.Value; Items = new List <Item>(); Item i = null; if (patch.Contains("5.11")) { i = ItemsCache.GetItemV511((int)o.item0.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV511((int)o.item1.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV511((int)o.item2.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV511((int)o.item3.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV511((int)o.item4.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV511((int)o.item5.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV511((int)o.item6.Value); if (i != null) { Items.Add(i); } } else { i = ItemsCache.GetItemV514((int)o.item0.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV514((int)o.item1.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV514((int)o.item2.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV514((int)o.item3.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV514((int)o.item4.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV514((int)o.item5.Value); if (i != null) { Items.Add(i); } i = ItemsCache.GetItemV514((int)o.item6.Value); if (i != null) { Items.Add(i); } } }
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; } }
private static ItemsViewModel GetPatchItems(int minute, IGrouping <string, AvgTimeLine> patch, int totalGames) { var itemsView = new ItemsViewModel(); itemsView.TotalGames = totalGames; itemsView.Minute = minute; itemsView.Items = new List <ItemViewModel>(); var dicItems = new Dictionary <int, int>(); foreach (var a in patch) { var itemsPatch = a.Items.Split(new [] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in itemsPatch) { var dataItem = item.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries); var key = int.Parse(dataItem[0]); var val = int.Parse(dataItem[1]); if (patch.Key.Contains("5.11")) { var name = ItemsCache.GetItemV511(key).Name; if (name.Contains("Potion") || name.Contains("Biscuit")) { continue; } } else { var name = ItemsCache.GetItemV514(key).Name; if (name.Contains("Potion") || name.Contains("Biscuit")) { continue; } } if (dicItems.ContainsKey(key)) { dicItems[key] += (val); } else { dicItems.Add(key, (val)); } } } try { dicItems = dicItems.OrderByDescending(d => d.Value).Take(8).ToDictionary(d => d.Key, d => d.Value); foreach (var item in dicItems) { var itemVM = new ItemViewModel(); itemVM.Id = item.Key; if (patch.Key.StartsWith("5.11")) { itemVM.Name = ItemsCache.GetItemV511(item.Key).Name; itemVM.ImageUrl = string.Format(@"http://ddragon.leagueoflegends.com/cdn/5.11.1/img/item/{0}.png", item.Key); } else { itemVM.Name = ItemsCache.GetItemV514(item.Key).Name; itemVM.ImageUrl = string.Format(@"http://ddragon.leagueoflegends.com/cdn/5.14.1/img/item/{0}.png", item.Key); } itemVM.PickRate = string.Format("{0:0.00}%", ((double)item.Value / totalGames) * 100); itemsView.Items.Add(itemVM); } } catch { } return(itemsView); }