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()); } }
public void SetLeagueInfo(PublicSummoner summoner, SummonerLeaguesDTO leagueInfo) { if (summoner == null || leagueInfo == null) return; if (InvokeRequired) { Invoke(new Action<PublicSummoner, SummonerLeaguesDTO>(SetLeagueInfo), summoner, leagueInfo); return; } foreach (var entry in leagueInfo.summonerLeagues) { foreach (var entry2 in entry.entries) { if (entry2.PlayerOrTeamName.Equals(summoner.Name)) { division.Text = entry2.Tier + "." + ToInt(entry2.Rank) + "." + entry2.LeaguePoints; return; } } } }
public void SetStats(PublicSummoner summoner, PlayerLifetimeStats stats) { if (summoner == null || stats == null) return; if (InvokeRequired) { Invoke(new Action<PublicSummoner, PlayerLifetimeStats>(SetStats), summoner, stats); return; } SetLevel(summoner.SummonerLevel); RemoveAll(p => (p.Tag as string) == "Stats"); foreach (var stat in stats.PlayerStatSummaries.PlayerStatSummarySet) { if (!stat.PlayerStatSummaryType.Contains("RankedSolo5x5")) continue; var sc = new StatsControl { Dock = DockStyle.Fill, Tag = "Stats" }; sc.SetStatSummary(stat); var tab = new TabPage(MinifyStatType(stat.PlayerStatSummaryType)) { BackColor = this.BackColor, Tag = "Stats" }; tab.Controls.Add(sc); AddTab(tab); } }