Пример #1
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.QueueType = Client.TitleCaseString(Game.QueueType.Replace("ODIN", "Dominion").Replace("UNRANKED", "").Replace("_5x5", "").Replace("_", " ")).Replace("Aram", "ARAM").Trim();
                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.QueueType);

                    item.MapLabel.Content = BaseMap.GetMap(stats.Game.GameMapId).DisplayName;
                    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");

                    item.GridView.Background = brush;
                    item.GridView.Width = 250;
                    GamesListView.Items.Add(item);
                }
            }));
        }
Пример #2
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 "ODIN_UNRANKED":
                            item.ScoreLabel.Content += "(Dominion)";
                            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;
                        case "URF":
                            item.ScoreLabel.Content += "(URF)";
                            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;
                }
            }));
        }