public void GotRecentGames(RecentGames result) { GameStats.Clear(); try { result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats Game in result.GameStatistics) { Game.GameType = Client.TitleCaseString(Game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var Match = new MatchStats(); foreach (RawStat Stat in Game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(Stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(Match, Stat.Value); } Match.Game = Game; GameStats.Add(Match); } } catch { Client.Log("Can't load player recent games", "ERROR"); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (MatchStats stats in GameStats) { var item = new RecentGameOverview(); champions GameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = GameChamp.icon; item.ChampionNameLabel.Content = GameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ", stats.ChampionsKilled, stats.NumDeaths, stats.Assists); switch (stats.Game.QueueType) { case "NORMAL": item.ScoreLabel.Content += "(Normal)"; break; case "NORMAL_3x3": item.ScoreLabel.Content += "(Normal 3v3)"; break; case "ARAM_UNRANKED_5x5": item.ScoreLabel.Content += "(ARAM)"; break; case "NONE": item.ScoreLabel.Content += "(Custom)"; break; case "RANKED_SOLO_5x5": item.ScoreLabel.Content += "(Ranked 5v5)"; break; case "RANKED_TEAM_5x5": item.ScoreLabel.Content += "(Ranked Team 5v5)"; break; case "RANKED_TEAM_3x3": item.ScoreLabel.Content += "(Ranked Team 3v3)"; break; case "CAP_5x5": item.ScoreLabel.Content += "(Team Builder)"; break; case "BOT": item.ScoreLabel.Content += "(Bots)"; break; default: Client.Log(stats.Game.QueueType); item.ScoreLabel.Content += "Please upload this log to github."; break; } item.CreepScoreLabel.Content = stats.MinionsKilled + " minions"; item.DateLabel.Content = stats.Game.CreateDate; item.IpEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; var bc = new BrushConverter(); var brush = (Brush)bc.ConvertFrom("#FF609E74"); if (stats.Lose == 1) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } else if (stats.Game.IpEarned == 0) { brush = (Brush)bc.ConvertFrom("#FFE27100"); } item.GridView.Background = brush; item.GridView.Width = 250; GamesListView.Items.Add(item); } if (GamesListView.Items.Count > 0) { GamesListView.SelectedIndex = 0; } })); }
public void GotRecentGames(RecentGames result) { if (result.GameStatistics == null) { return; } _gameStats.Clear(); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (var game in result.GameStatistics) { game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", string.Empty).Replace("MATCHED", "NORMAL")); var match = new MatchStats(); foreach (var stat in game.Statistics) { var type = typeof(MatchStats); var fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", string.Empty); var f = type.GetField(fieldName); f.SetValue(match, stat.Value); } match.Game = game; _gameStats.Add(match); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (var stats in _gameStats) { var item = new RecentGameOverview(); var gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = gameChamp.icon; item.ChampionNameLabel.Content = gameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ", stats.ChampionsKilled, stats.NumDeaths, stats.Assists); switch (stats.Game.QueueType) { case "NORMAL": item.ScoreLabel.Content += "(Normal)"; break; case "NORMAL_3x3": item.ScoreLabel.Content += "(Normal 3v3)"; break; case "ARAM_UNRANKED_5x5": item.ScoreLabel.Content += "(ARAM)"; break; case "NONE": item.ScoreLabel.Content += "(Custom)"; break; case "RANKED_SOLO_5x5": item.ScoreLabel.Content += "(Ranked 5v5)"; break; case "RANKED_TEAM_5x5": item.ScoreLabel.Content += "(Ranked Team 5v5)"; break; case "RANKED_TEAM_3x3": item.ScoreLabel.Content += "(Ranked Team 3v3)"; break; case "CAP_5x5": item.ScoreLabel.Content += "(Team Builder)"; break; case "BOT": item.ScoreLabel.Content += "(Bots)"; break; case "KING_PORO": item.ScoreLabel.Content += "(King Poro)"; break; case "COUNTER_PICK": item.ScoreLabel.Content += "(Nemesis Draft)"; break; default: Client.Log(stats.Game.QueueType); item.ScoreLabel.Content += "Please upload this log to github."; break; } item.CreepScoreLabel.Content = stats.MinionsKilled + " minions"; item.DateLabel.Content = stats.Game.CreateDate; item.IPEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; var bc = new BrushConverter(); var brush = (Brush)bc.ConvertFrom("#FF609E74"); if (Math.Abs(stats.Lose - 1) < .00001) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } else if (Math.Abs(stats.Game.IpEarned) < .00001) { brush = (Brush)bc.ConvertFrom("#FFE27100"); } item.GridView.Background = brush; item.GridView.Width = 280; GamesListView.Items.Add(item); } if (GamesListView.Items.Count > 0) { GamesListView.SelectedIndex = 0; } })); }
public void GotRecentGames(RecentGames result) { GameStats.Clear(); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats Game in result.GameStatistics) { Game.GameType = Client.TitleCaseString(Game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); MatchStats Match = new MatchStats(); foreach (RawStat Stat in Game.Statistics) { var type = typeof(MatchStats); string fieldName = Client.TitleCaseString(Stat.StatType.Replace('_', ' ')).Replace(" ", ""); var f = type.GetField(fieldName); f.SetValue(Match, Stat.Value); } Match.Game = Game; GameStats.Add(Match); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (MatchStats stats in GameStats) { RecentGameOverview item = new RecentGameOverview(); champions GameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = GameChamp.icon; item.ChampionNameLabel.Content = GameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ({3})", stats.ChampionsKilled, stats.NumDeaths, stats.Assists, stats.Game.GameType); item.CreepScoreLabel.Content = stats.MinionsKilled + " minions"; item.DateLabel.Content = stats.Game.CreateDate; item.IPEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; BrushConverter bc = new BrushConverter(); Brush brush = (Brush)bc.ConvertFrom("#FF609E74"); if (stats.Lose == 1) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } else if (stats.Game.IpEarned == 0) { brush = (Brush)bc.ConvertFrom("#FFE27100"); } item.GridView.Background = brush; item.GridView.Width = 250; GamesListView.Items.Add(item); } })); }