Closed Coltsbro closed 9 years ago
Sure, I'll have a look in the morning. In the meantime, have a look at linq, it should help you with what you're trying to accomplish.
I'm also having problems getting a player summary. Here's what I have so far.
private void statSummary()
{
var api = RiotApi.GetInstance(devKey);
string input = txtSummonerName.Text;
var summoner = api.GetSummoner(RiotSharp.Region.na, input);
var rankedGamesPlayed = api.GetStatsRanked(RiotSharp.Region.na, summoner.Id, RiotSharp.StatsEndpoint.Season.Season4);
foreach(var played in rankedGamesPlayed)
{
lstShow.Items.Add(played.Stats.RankedSoloGamesPlayed).ToString();
}
//summoner.GetStatsRanked();
var playerLeague = summoner.GetLeagues();
}
Whenever I run it, and go for the ranked games played, it always shows up as 0 (which is false). Also, I have no idea how to display the player league in the list box. Thanks so much for the help, and sorry if I'm bugging you. I'm trying to (re)teach myself C# and getting used to using API's and all that.
Hey, this worked! Thanks so much! Any idea on why I'm getting 0's for ranked stats in my second post?
I'm not sure the previous solution was working properly. I'm working on a new solution.
Yea, I actually just tested it and it was showing the wrong champion as the most played, but it's more than I had before lol.
var championIds = new List<int>();
for (int i = 0; i < 30; i += 15)
{
var matches = api.GetMatchHistory(Region.euw, id, i, i + 15, null,
new List<Queue>() { Queue.RankedSolo5x5 });
foreach (var match in matches)
{
championIds.Add(match.Participants[0].ChampionId);
}
}
var mostPlayedChampId = championIds.
GroupBy(c => c).
OrderByDescending(g => g.Count()).
FirstOrDefault().Key;
var mostPlayedChamp = staticApi.GetChampion(Region.euw, mostPlayedChampId);
Console.WriteLine(mostPlayedChamp.Name);
The problem is you can only go so far in the history, for me it was around 40, so it's only the most played champ during the last 40 games.
It is working! I'm still struggling with actually getting ranked stats to show though. Everytime I try it just shows all stats as 0. Is it also an issue with only being able to go back 40 games or so?
I don't have any issues with ranked stats, I'll check back later during the day.
Ok. Here's what I'm using to pull the stats for the most played champ:
var mostPlayedStats = api.GetStatsRanked(RiotSharp.Region.na, player.id, RiotSharp.StatsEndpoint.Season.Season4);
var mostPlayedStatsSeason3 = api.GetStatsRanked(RiotSharp.Region.na, player.id, RiotSharp.StatsEndpoint.Season.Season3);
foreach(var c in mostPlayedStats)
{
if(c.ChampionId == mostPlayedChampId)
{
lstShow.Items.Add(c.Stats.AverageChampionsKilled.ToString());
lstShow.Items.Add(c.Stats.AverageNumDeaths.ToString());
lstShow.Items.Add(c.Stats.AverageAssists.ToString());
int kda = 0;
if(c.Stats.AverageNumDeaths == 0)
{
kda = (c.Stats.AverageChampionsKilled + c.Stats.AverageAssists);
}
else
kda = (c.Stats.AverageChampionsKilled + c.Stats.AverageAssists) / c.Stats.AverageNumDeaths;
lstShow.Items.Add(kda.ToString());
break;
}
}
Thanks again!
I'm looking at the number of RankedSoloGamesPlayed and I have been able to reproduce the issue, I'm looking into it right now.
Yeah, as I thought it always gives back 0 because it's either not present in the data being retrieved or is actually zero. So, it doesn't come from the wrapper but from Riot.
Hmmm, so there's really no solution to this problem then? Because I can assure you people I tested with this do not have 0 ranked games played.
Compare what you would get from the API directly with what you get from the wrapper but personnally I get the exact same results.
I figured it out. I looked at the documentation and saw that the AverageKills, AverageDeaths, etc were from Dominion only, so I wouldn't have any data from that. Thanks a lot for your help!
No problem.
Hi.
I'm having issues with getting the most played champion in ranked and displaying it. Could you help me out here? I know its kind of a mess, but I've been trying to play around with the api and found myself stuck and honestly don't know how to do it. Thanks.