taycaldwell / riot-api-java

Riot Games API Java Library
http://taycaldwell.github.io/riot-api-java/
Apache License 2.0
190 stars 73 forks source link

Guidance in getting wins ? #116

Closed ccancin0 closed 7 years ago

ccancin0 commented 7 years ago

Not sure if I am calling the right methods here:

import net.rithms.riot.api.endpoints.league.dto.LeagueList;

Summoner summoner = api.getSummonerByName(Platform.NA, username); Set league = api.getLeaguePositionsBySummonerId(Platform.NA, summoner.getId());

Now after this if I'm correct so far to get wins would if be like this: int wins = league.getWins();

Because league. doesn't give me those methods. Using newest version 4.0.1

Linnun commented 7 years ago

Note that league is a Set.

You can iterate over it like this:

Summoner summoner = api.getSummonerByName(Platform.NA, username);
Set<LeaguePosition> leagues = api.getLeaguePositionsBySummonerId(Platform.NA, summoner.getId());

for(LeaguePosition league : leagues){
   int wins = league.getWins();
}

Note that this iterates over all your leagues. If you want wins for a specific league, you could go like this:

Summoner summoner = api.getSummonerByName(Platform.NA, username);
Set<LeaguePosition> leagues = api.getLeaguePositionsBySummonerId(Platform.NA, summoner.getId());

int wins = 0;
for(LeaguePosition league : leagues){
   if(league.getQueueType().equalsIgnoreCase(LeagueQueue.RANKED_SOLO_5x5.toString())){
      wins = league.getWins();
      break;
   }
}
ccancin0 commented 7 years ago

Thanks!