public ChampionStatistics(int championId, AggregatedStats statistics)
        {
            ChampionId = championId;
            Statistics = statistics;

            Wins   = Load("TOTAL_SESSIONS_WON");
            Losses = Load("TOTAL_SESSIONS_LOST");

            Kills   = Load("TOTAL_CHAMPION_KILLS");
            Deaths  = Load("TOTAL_DEATHS_PER_SESSION");
            Assists = Load("TOTAL_ASSISTS");

            MinionKills = Load("TOTAL_MINION_KILLS");

            Gold = Load("TOTAL_GOLD_EARNED");

            TurretsDestroyed = Load("TOTAL_TURRETS_KILLED");

            DamageDealt         = Load("TOTAL_DAMAGE_DEALT");
            PhysicalDamageDealt = Load("TOTAL_PHYSICAL_DAMAGE_DEALT");
            MagicalDamageDealt  = Load("TOTAL_MAGIC_DAMAGE_DEALT");

            DamageTaken = Load("TOTAL_DAMAGE_TAKEN");

            DoubleKills = Load("TOTAL_DOUBLE_KILLS");
            TripleKills = Load("TOTAL_TRIPLE_KILLS");
            QuadraKills = Load("TOTAL_QUADRA_KILLS");
            PentaKills  = Load("TOTAL_PENTA_KILLS");

            TimeSpentDead = Load("TOTAL_TIME_SPENT_DEAD");

            MaximumKills  = Load("MAX_CHAMPIONS_KILLED");
            MaximumDeaths = Load("MAX_NUM_DEATHS");
        }
Example #2
0
        private async void ViewAggregatedStatsButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            AggregatedStats x = await Client.PVPNet.GetAggregatedStats(AccId, "CLASSIC", "3");

            Client.OverlayContainer.Content    = new AggregatedStatsOverlay(x, AccId == Client.LoginPacket.AllSummonerData.Summoner.AcctId).Content;
            Client.OverlayContainer.Visibility = System.Windows.Visibility.Visible;
        }
Example #3
0
        private async void ViewAggregatedStatsButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            AggregatedStats x = await RiotCalls.GetAggregatedStats(AccId, "CLASSIC", Client.LoginPacket.ClientSystemStates.currentSeason.ToString());

            Client.OverlayContainer.Content    = new AggregatedStatsOverlay(x, AccId == Client.LoginPacket.AllSummonerData.Summoner.AcctId).Content;
            Client.OverlayContainer.Visibility = System.Windows.Visibility.Visible;
        }
        void UpdateSummonerRankedStatistics(Summoner summoner, int season, AggregatedStats aggregatedStatistics, DbConnection connection)
        {
            List <ChampionStatistics> statistics = ChampionStatistics.GetChampionStatistics(aggregatedStatistics);

            foreach (var champion in statistics)
            {
                using (var championUpdate = Command("update summoner_ranked_statistics set wins = :wins, losses = :losses, kills = :kills, deaths = :deaths, assists = :assists, minion_kills = :minion_kills, gold = :gold, turrets_destroyed = :turrets_destroyed, damage_dealt = :damage_dealt, physical_damage_dealt = :physical_damage_dealt, magical_damage_dealt = :magical_damage_dealt, damage_taken = :damage_taken, double_kills = :double_kills, triple_kills = :triple_kills, quadra_kills = :quadra_kills, penta_kills = :penta_kills, time_spent_dead = :time_spent_dead, maximum_kills = :maximum_kills, maximum_deaths = :maximum_deaths where summoner_id = :summoner_id and season = :season and champion_id = :champion_id", connection))
                {
                    SetSummonerRankedStatisticsParameters(championUpdate, summoner, season, champion);

                    int rowsAffected = championUpdate.Execute();

                    if (rowsAffected == 0)
                    {
                        //The champion entry didn't exist yet so we must create a new entry first
                        string query = string.Format("insert into summoner_ranked_statistics ({0}) values ({1})", GetGroupString(SummonerRankedStatisticsFields), GetPlaceholderString(SummonerRankedStatisticsFields));
                        using (var championInsert = Command(query, connection))
                        {
                            SetSummonerRankedStatisticsParameters(championInsert, summoner, season, champion);
                            championInsert.Execute();
                        }
                    }
                }
            }
        }
Example #5
0
        private void GotStats(AggregatedStats stats)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                SelectedAggregatedStats = stats;

                ViewAggregatedStatsButton.IsEnabled = false;
                TopChampionsListView.Items.Clear();
                List <AggregatedChampion> ChampionStats = new List <AggregatedChampion>();
                int i = 0;

                if (SelectedAggregatedStats.LifetimeStatistics != null)
                {
                    if (SelectedAggregatedStats.LifetimeStatistics.Count() > 0)
                    {
                        foreach (AggregatedStat stat in SelectedAggregatedStats.LifetimeStatistics)
                        {
                            AggregatedChampion Champion = null;
                            Champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId);
                            if (Champion == null)
                            {
                                Champion            = new AggregatedChampion();
                                Champion.ChampionId = stat.ChampionId;
                                ChampionStats.Add(Champion);
                            }

                            var type         = typeof(AggregatedChampion);
                            string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", "");
                            var f            = type.GetField(fieldName);
                            f.SetValue(Champion, stat.Value);
                        }

                        ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed));

                        foreach (AggregatedChampion info in ChampionStats)
                        {
                            if (i++ > 6)
                            {
                                break;
                            }
                            ViewAggregatedStatsButton.IsEnabled = true;
                            if (info.ChampionId != 0.0)
                            {
                                ChatPlayer player            = new ChatPlayer();
                                champions Champion           = champions.GetChampion(Convert.ToInt32(info.ChampionId));
                                player.LevelLabel.Visibility = System.Windows.Visibility.Hidden;
                                player.PlayerName.Content    = Champion.displayName;
                                player.PlayerStatus.Content  = info.TotalSessionsPlayed + " games played";
                                player.ProfileImage.Source   = champions.GetChampion(Champion.id).icon;
                                TopChampionsListView.Items.Add(player);
                            }
                        }
                    }
                }
            }));
        }
 public AggregatedStatsOverlay(AggregatedStats stats, Boolean IsSelf)
 {
     InitializeComponent();
     IsOwnPlayer   = IsSelf;
     AllStats      = new AggregatedChampion();
     ChampionStats = new List <AggregatedChampion>();
     ParseStats(stats);
     SelectedStats       = AllStats;
     HideGrid.Visibility = System.Windows.Visibility.Visible;
     DisplayStats();
 }
 public AggregatedStatsOverlay(AggregatedStats stats, bool isSelf)
 {
     InitializeComponent();
     isOwnPlayer   = isSelf;
     allStats      = new AggregatedChampion();
     championStats = new List <AggregatedChampion>();
     ParseStats(stats);
     selectedStats       = allStats;
     HideGrid.Visibility = Visibility.Visible;
     DisplayStats();
 }
        public AggregatedStatsOverlay(AggregatedStats stats, Boolean isSelf)
        {
            InitializeComponent();
            Change();

            _isOwnPlayer   = isSelf;
            _allStats      = new AggregatedChampion();
            _championStats = new List <AggregatedChampion>();
            ParseStats(stats);
            _selectedStats      = _allStats;
            HideGrid.Visibility = Visibility.Visible;
            DisplayStats();
        }
Example #9
0
        public async Task <AggregatedStats> GetAggregatedStats(Double summonerId, String gameMode, String season)
        {
            int Id = Invoke("playerStatsService", "getAggregatedStats", new object[] { summonerId, gameMode, season });

            while (!results.ContainsKey(Id))
            {
                await Task.Delay(10);
            }
            TypedObject     messageBody = results[Id].GetTO("data").GetTO("body");
            AggregatedStats result      = new AggregatedStats(messageBody);

            results.Remove(Id);
            return(result);
        }
Example #10
0
        private async void LeaguesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (LeaguesListView.SelectedItem != null)
            {
                LeagueItem item = (LeagueItem)LeaguesListView.SelectedItem;
                TopChampionsListView.Items.Clear();
                PublicSummoner x = await RiotCalls.GetSummonerByName((string)item.PlayerLabel.Content);

                AggregatedStats stats = await RiotCalls.GetAggregatedStats(x.AcctId, "CLASSIC", Client.LoginPacket.ClientSystemStates.currentSeason.ToString());

                GotStats(stats);
                PlayerLabel.Content = item.PlayerLabel.Content;
            }
        }
Example #11
0
        void RankedStatistics(List <string> arguments, bool sortByGames, bool currentOnly)
        {
            string         summonerName   = GetSummonerName(arguments[0]);
            PublicSummoner publicSummoner = RPC.GetSummonerByName(summonerName);

            if (publicSummoner == null)
            {
                NoSuchSummoner();
                return;
            }
            string[] seasonStrings =
            {
                "CURRENT",
                "TWO",
                "ONE",
            };

            foreach (string seasonString in seasonStrings)
            {
                Output.WriteLine("Season: \"{0}\"", seasonString);
                AggregatedStats aggregatedStatistics = RPC.GetAggregatedStats(publicSummoner.acctId, "CLASSIC", seasonString);
                if (aggregatedStatistics == null)
                {
                    Output.WriteLine("Unable to retrieve aggregated statistics");
                    return;
                }
                List <ChampionStatistics> statistics = ChampionStatistics.GetChampionStatistics(aggregatedStatistics);
                foreach (var entry in statistics)
                {
                    entry.Name = GetChampionName(entry.ChampionId);
                }
                if (sortByGames)
                {
                    statistics.Sort(CompareChampionGames);
                }
                else
                {
                    statistics.Sort(CompareChampionNames);
                }
                foreach (var entry in statistics)
                {
                    Output.WriteLine("{0}: {1} {2}, {3}/{4}/{5} ({6})", entry.Name, entry.Games, entry.Games == 1 ? "game" : "games", Round(entry.KillsPerGame()), Round(entry.DeathsPerGame()), Round(entry.AssistsPerGame()), Round(entry.KillsAndAssistsPerDeath()));
                }
                if (currentOnly)
                {
                    break;
                }
            }
        }
        private void ParseStats(AggregatedStats stats)
        {
            foreach (var stat in stats.LifetimeStatistics)
            {
                var champion =
                    _championStats.Find(x => Math.Abs(x.ChampionId - stat.ChampionId) < Math.Abs(x.ChampionId * .00001));
                if (champion == null)
                {
                    champion = new AggregatedChampion
                    {
                        ChampionId = stat.ChampionId
                    };
                    _championStats.Add(champion);
                }

                var type      = typeof(AggregatedChampion);
                var fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", string.Empty);
                var f         = type.GetField(fieldName);
                f.SetValue(champion, stat.Value);
            }

            _championStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed));

            //AllStats = ChampionStats;

            foreach (var championStat in _championStats)
            {
                if (Math.Abs(championStat.ChampionId) < .00001)
                {
                    continue;
                }

                var item          = new ListViewItem();
                var championImage = new ProfileChampionImage();
                var champ         = champions.GetChampion((int)championStat.ChampionId);
                championImage.ChampImage.Source = champ.icon;
                championImage.ChampName.Content = champ.displayName;
                championImage.Width             = 96;
                championImage.Height            = 84;
                item.Tag     = championStat;
                item.Content = championImage.Content;
                ChampionsListView.Items.Add(item);
            }
        }
        public static List <ChampionStatistics> GetChampionStatistics(AggregatedStats statistics)
        {
            Dictionary <int, ChampionStatistics> output = new Dictionary <int, ChampionStatistics>();

            foreach (var statisticsEntry in statistics.lifetimeStatistics)
            {
                int key = statisticsEntry.championId;
                if (key == 0)
                {
                    continue;
                }
                if (output.ContainsKey(key))
                {
                    continue;
                }
                ChampionStatistics newEntry = new ChampionStatistics(key, statistics);
                output[key] = newEntry;
            }
            return(output.Values.ToList());
        }
        private void ParseStats(AggregatedStats stats)
        {
            foreach (AggregatedStat stat in stats.LifetimeStatistics)
            {
                AggregatedChampion Champion = null;
                Champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId);
                if (Champion == null)
                {
                    Champion            = new AggregatedChampion();
                    Champion.ChampionId = stat.ChampionId;
                    ChampionStats.Add(Champion);
                }

                var    type      = typeof(AggregatedChampion);
                string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", "");
                var    f         = type.GetField(fieldName);
                f.SetValue(Champion, stat.Value);
            }

            ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed));

            //AllStats = ChampionStats;

            foreach (AggregatedChampion ChampionStat in ChampionStats)
            {
                if (ChampionStat.ChampionId != 0)
                {
                    ListViewItem         item          = new ListViewItem();
                    ProfileChampionImage championImage = new ProfileChampionImage();
                    champions            champ         = champions.GetChampion((int)ChampionStat.ChampionId);
                    championImage.ChampImage.Source = champ.icon;
                    championImage.ChampName.Content = champ.displayName;
                    championImage.Width             = 96;
                    championImage.Height            = 84;
                    item.Tag     = ChampionStat;
                    item.Content = championImage.Content;
                    ChampionsListView.Items.Add(item);
                }
            }
        }
Example #15
0
        private void GotStats(AggregatedStats stats)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                _selectedAggregatedStats = stats;

                ViewAggregatedStatsButton.IsEnabled = false;
                TopChampionsListView.Items.Clear();
                var championStats = new List <AggregatedChampion>();
                var i             = 0;
                if (_selectedAggregatedStats.LifetimeStatistics == null)
                {
                    return;
                }

                if (!_selectedAggregatedStats.LifetimeStatistics.Any())
                {
                    return;
                }

                foreach (var stat in _selectedAggregatedStats.LifetimeStatistics)
                {
                    var champion = championStats.Find(x => Math.Abs(x.ChampionId - stat.ChampionId) < .00001);
                    if (champion == null)
                    {
                        champion = new AggregatedChampion
                        {
                            ChampionId = stat.ChampionId
                        };
                        championStats.Add(champion);
                    }

                    var type      = typeof(AggregatedChampion);
                    var fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", string.Empty);
                    var f         = type.GetField(fieldName);

                    f.SetValue(champion, stat.Value);
                }

                championStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed));

                foreach (var info in championStats.TakeWhile(info => i++ <= 6))
                {
                    ViewAggregatedStatsButton.IsEnabled = true;
                    if (!(Math.Abs(info.ChampionId) > 0))
                    {
                        continue;
                    }

                    var champion = champions.GetChampion(Convert.ToInt32(info.ChampionId));
                    var player   = new ChatPlayer
                    {
                        LevelLabel   = { Visibility = Visibility.Hidden },
                        PlayerName   = { Content = champion.displayName },
                        PlayerStatus = { Content = info.TotalSessionsPlayed + " games played" },
                        ProfileImage = { Source = champions.GetChampion(champion.id).icon },
                        Background   = new SolidColorBrush(Color.FromArgb(102, 80, 80, 80)),
                        Width        = 270
                    };

                    TopChampionsListView.Items.Add(player);
                }
            }));
        }
Example #16
0
 void GetAggregatedStatistics(AggregatedStats aggregatedStatistics, int season)
 {
     AggregatedStatistics[season] = aggregatedStatistics;
     ProcessReply();
 }
Example #17
0
        /// 21.)
        public void GetAggregatedStats(Double summonerId, String gameMode, String season, AggregatedStats.Callback callback)
        {
            AggregatedStats cb = new AggregatedStats(callback);

            InvokeWithCallback("playerStatsService", "getAggregatedStats", new object[] { summonerId, gameMode, season }, cb);
        }
Example #18
0
        public void SetRankedStats(PublicSummoner summoner, AggregatedStats stats)
        {
            if (summoner == null || stats == null)
            {
                return;
            }

            if (InvokeRequired)
            {
                Invoke(new Action <PublicSummoner, AggregatedStats>(SetRankedStats), summoner, stats);
                return;
            }
            PlayerStats = stats;
            int kills   = 0;
            int assists = 0;
            int deaths  = 0;
            Dictionary <int, int> favChamps = new Dictionary <int, int>();

            foreach (var stat in stats.LifetimeStatistics)
            {
                if (stat.ChampionID == 0)
                {
                    if (stat.StatType.Contains("TOTAL_CHAMPION_KILLS"))
                    {
                        kills = Convert.ToInt32(stat.Value);
                    }
                    if (stat.StatType.Contains("TOTAL_ASSISTS"))
                    {
                        assists = Convert.ToInt32(stat.Value);
                    }
                    if (stat.StatType.Contains("TOTAL_DEATHS_PER_SESSION"))
                    {
                        deaths = Convert.ToInt32(stat.Value);
                    }
                    if (stat.StatType.Contains("TOTAL_SESSIONS_PLAYED"))
                    {
                        totalGames.Text = Convert.ToInt32(stat.Value).ToString();
                    }
                    if (stat.StatType.Contains("TOTAL_SESSIONS_WON"))
                    {
                        totalPercentWon.Text = Convert.ToInt32(stat.Value).ToString();
                    }
                }
                else
                {
                    if (stat.StatType.Contains("TOTAL_SESSIONS_PLAYED"))
                    {
                        if (favChamps.Count() <= 5)
                        {
                            favChamps.Add(stat.ChampionID, Convert.ToInt32(stat.Value));
                        }
                        else
                        {
                            var min      = favChamps.OrderBy(kvp => kvp.Value).First();
                            var minKey   = min.Key;
                            var minValue = min.Value;
                            if (Convert.ToInt32(stat.Value) > minValue)
                            {
                                favChamps.Remove(minKey);
                                favChamps.Add(stat.ChampionID, Convert.ToInt32(stat.Value));
                            }
                        }
                    }
                }
            }
            totalPercentWon.Text = ((100.0f * (Convert.ToInt32(totalPercentWon.Text)) / Convert.ToDouble(totalGames.Text)) + 0.0001).ToString().Substring(0, 4) + "%";
            if (Convert.ToDouble(totalPercentWon.Text.Substring(0, 4)) > 50.0f)
            {
                totalPercentWon.ForeColor = Color.DarkGreen;
            }
            else
            {
                totalPercentWon.ForeColor = Color.DarkRed;
            }
            float totalKdaCalc = (kills + assists) / (float)deaths;

            totalKda.Text = totalKdaCalc.ToString().Substring(0, 4);
            if (totalKdaCalc < 2.25)
            {
                totalKda.ForeColor = Color.DarkRed;
            }
            else if (totalKdaCalc < 3)
            {
                totalKda.ForeColor = Color.DarkOrange;
            }
            else
            {
                totalKda.ForeColor = Color.DarkGreen;
            }
            for (int i = 0; i < 5; i++)
            {
                var favChamp = favChamps.OrderBy(kvp => kvp.Value).Last();
                var name     = ChampNames.GetOrDefault(favChamp.Key);
                favChampIcons[i].Image = ChampIcons.Get(favChamp.Key);
                favChamps.Remove(favChamp.Key);
                foreach (var stat in stats.LifetimeStatistics)
                {
                    if (favChamp.Key == stat.ChampionID)
                    {
                        if (stat.StatType.Contains("TOTAL_CHAMPION_KILLS"))
                        {
                            kills = Convert.ToInt32(stat.Value);
                        }
                        if (stat.StatType.Contains("TOTAL_ASSISTS"))
                        {
                            assists = Convert.ToInt32(stat.Value);
                        }
                        if (stat.StatType.Contains("TOTAL_DEATHS_PER_SESSION"))
                        {
                            deaths = Convert.ToInt32(stat.Value);
                        }
                    }
                }
                float tempChampKda = (kills + assists) / (float)deaths;
                favChampKdas[i].SetToolTip(favChampIcons[i], tempChampKda.ToString());
            }
        }
Example #19
0
 void GetAggregatedStatistics(AggregatedStats aggregatedStatistics)
 {
     AggregatedStatistics = aggregatedStatistics;
     ProcessReply();
 }