Search in sources :

Example 21 with SummonerBuilder

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());
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) StaticChampion(no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion) R4J(no.stelar7.api.r4j.impl.R4J) LeagueShard(no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard) Test(org.junit.jupiter.api.Test)

Example 22 with SummonerBuilder

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);
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SpectatorGameInfo(no.stelar7.api.r4j.pojo.lol.spectator.SpectatorGameInfo) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) R4J(no.stelar7.api.r4j.impl.R4J) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Example 23 with SummonerBuilder

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));
    }
}
Also used : SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) LOLMatch(no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Example 24 with SummonerBuilder

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);
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Example 25 with SummonerBuilder

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);
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Aggregations

SummonerBuilder (no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder)20 Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)18 SpectatorBuilder (no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)16 SummonerBuilder (no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)13 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)9 MatchListBuilder (no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)4 R4J (no.stelar7.api.r4j.impl.R4J)4 ChampionMasteryBuilder (no.stelar7.api.r4j.impl.lol.builders.championmastery.ChampionMasteryBuilder)4 FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)3 L4J8 (no.stelar7.api.l4j8.impl.L4J8)3 MatchListBuilder (no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder)3 ChampionMastery (no.stelar7.api.r4j.pojo.lol.championmastery.ChampionMastery)3 java.awt (java.awt)2 AffineTransform (java.awt.geom.AffineTransform)2 java.awt.image (java.awt.image)2 java.io (java.io)2 URL (java.net.URL)2 java.util (java.util)2 List (java.util.List)2 Predicate (java.util.function.Predicate)2