use of no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder in project L4J8 by stelar7.
the class DivTests method test.
@Test
public void test() {
R4J api = new R4J(SecretFile.CREDS);
String user = "stelar7";
LeagueShard region = LeagueShard.EUW1;
Summoner summoner = new SummonerBuilder().withPlatform(region).withName(user).get();
Map<Integer, StaticChampion> champData = api.getDDragonAPI().getChampions();
// pfp
String pfp = ImageAPI.getInstance().getProfileIcon(region, user);
// name and lv
int level = summoner.getSummonerLevel();
String name = summoner.getName();
// most recent game
List<String> matches = summoner.getLeagueGames().get();
LOLMatch match = LOLMatch.get(region, matches.get(0));
MatchParticipant self = match.getParticipants().stream().filter(p -> p.getPuuid().equals(summoner.getPUUID())).findFirst().get();
StaticChampion champion = champData.get(self.getChampionId());
MatchPerks summs = self.getPerks();
boolean won = self.didWin();
System.out.println("Profile icon: " + pfp);
System.out.println(name + ", Level " + level);
System.out.println();
System.out.format(name + " %s their most recent game.", won ? "won" : "lost");
System.out.println();
System.out.println("They were playing " + self.getChampionSelectLane() + " " + champion.getName());
}
use of no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder in project L4J8 by stelar7.
the class CurrentGameTest method testCurrentGame.
@Test
public void testCurrentGame() {
final R4J r4J = new R4J(SecretFile.CREDS);
SpectatorBuilder sb = new SpectatorBuilder().withPlatform(LeagueShard.EUW1);
// Get a game in progess
final List<SpectatorGameInfo> game = sb.getFeaturedGames();
// Get a summoner from that game
final String name = game.get(0).getParticipants().get(0).getSummonerName();
final Summoner sum = new SummonerBuilder().withPlatform(game.get(0).getPlatform()).withName(name).get();
// Get game info
final SpectatorGameInfo currentGame = sb.withSummonerId(sum.getSummonerId()).getCurrentGame();
if (currentGame != null) {
doAssertions.accept(currentGame);
}
}
use of no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder in project L4J8 by stelar7.
the class TournamentTest method testAllRegistrations.
@Test
@Disabled
public void testAllRegistrations() {
final ProviderRegistrationParameters params = new ProviderRegistrationParameters(LeagueShard.EUW1, "http://stelar7.no/loltest/provider.php");
final long providerId = this.api.registerAsProvider(params);
final TournamentRegistrationParameters trparams = new TournamentRegistrationParameters("THE BEST TOURNAMENT EVER", providerId);
final long tournamentId = this.api.registerTournament(trparams);
final int teamSize = 5;
SpectatorBuilder spectatorBuilder = new SpectatorBuilder().withPlatform(LeagueShard.EUW1);
final SpectatorGameInfo game = spectatorBuilder.getFeaturedGames().get(0);
List<String> names = game.getParticipants().stream().map(SpectatorParticipant::getSummonerName).collect(Collectors.toList());
List<String> ids = new ArrayList<>();
SummonerBuilder sb = new SummonerBuilder().withPlatform(LeagueShard.EUW1);
for (String name : names) {
ids.add(sb.withName(name).get().getSummonerId());
}
final TournamentCodeUpdateParameters tcinner = new TournamentCodeUpdateParameters(ids, TournamentMapType.SUMMONERS_RIFT, TournamentPickType.TOURNAMENT_DRAFT, TournamentSpectatorType.ALL);
final TournamentCodeParameters tcparams = new TournamentCodeParameters(tcinner, "THIS IS METADATA YOOO", teamSize);
final List<String> codes = this.api.generateTournamentCodes(tcparams, tournamentId, 1);
final TournamentCodeUpdateParameters tcuparams = new TournamentCodeUpdateParameters(ids, TournamentMapType.TWISTED_TREELINE, TournamentPickType.TOURNAMENT_DRAFT, TournamentSpectatorType.ALL);
final List<LobbyEvent> events = this.api.getTournamentLobbyInfo(codes.get(0));
if (!api.isStub()) {
this.api.updateTournament(codes.get(0), tcuparams);
final TournamentCode id = this.api.getTournamentInfo(codes.get(0));
final List<Long> tournamentCodeMatchIds = this.api.getMatchIds(LeagueShard.EUW1, codes.get(0));
final LOLMatch matchDetail = this.api.getMatchInfo(LeagueShard.EUW1, codes.get(0), tournamentCodeMatchIds.get(0));
}
}
use of no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder in project L4J8 by stelar7.
the class SummonerTest method testByPUUID.
@Test
public void testByPUUID() {
String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
Summoner optional = new SummonerBuilder().withPlatform(s.getPlatform()).withPUUID(s.getPUUID()).get();
doAssertions.accept(optional);
}
use of no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder in project L4J8 by stelar7.
the class SummonerTest method testByName.
@Test
public void testByName() {
String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
Summoner optional = new SummonerBuilder().withPlatform(s.getPlatform()).withName(s.getNormalizedName()).get();
doAssertions.accept(optional);
}
Aggregations