Search in sources :

Example 11 with R4J

use of no.stelar7.api.r4j.impl.R4J in project L4J8 by stelar7.

the class CurrentGameTest method testCurrentGameFame.

@Test
public void testCurrentGameFame() {
    final R4J r4J = new R4J(SecretFile.CREDS);
    Summoner s = Summoner.byName(LeagueShard.EUW1, "Klospülautomat");
    SpectatorGameInfo game = s.getCurrentGame();
    System.out.format("%s is %sin game%n", s.getName(), game != null ? "" : "not ");
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SpectatorGameInfo(no.stelar7.api.r4j.pojo.lol.spectator.SpectatorGameInfo) R4J(no.stelar7.api.r4j.impl.R4J)

Example 12 with R4J

use of no.stelar7.api.r4j.impl.R4J 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 13 with R4J

use of no.stelar7.api.r4j.impl.R4J in project L4J8 by stelar7.

the class GenerateDataTest method generateStuff.

@Test
@Disabled
public void generateStuff() throws IOException {
    R4J api = new R4J(SecretFile.CREDS);
    Summoner self = Summoner.byName(LeagueShard.EUW1, "stelar7");
    MatchIterator iterator = self.getLeagueGames().getMatchIterator();
    int i = 0;
    List<InternalMatchData> matchData = new ArrayList<>();
    for (LOLMatch m : iterator) {
        MatchParticipant lookup = m.getParticipants().stream().filter(p -> p.getPuuid().equals(self.getPUUID())).findFirst().get();
        InternalMatchData data = new InternalMatchData();
        data.queue = m.getQueue().commonName();
        data.win = lookup.didWin();
        data.startTime = m.getMatchCreationAsDate().toInstant().toEpochMilli();
        Map<String, InternalMatchSummoner> sums = new HashMap<>();
        for (MatchParticipant p : m.getParticipants()) {
            InternalMatchSummoner sum = new InternalMatchSummoner();
            sum.name = p.getSummonerName();
            sum.champion = p.getChampionId();
            sum.summoner1 = p.getSummoner1Id();
            sum.summoner2 = p.getSummoner2Id();
            sum.perks = generatePerkList(p.getPerks());
            sum.kills = p.getKills();
            sum.deaths = p.getDeaths();
            sum.assists = p.getAssists();
            sum.level = p.getChampionLevel();
            sum.cs = p.getTotalMinionsKilled();
            List<Integer> items = Arrays.asList(p.getItem0(), p.getItem1(), p.getItem2(), p.getItem3(), p.getItem4(), p.getItem5(), p.getItem6());
            Collections.sort(items);
            sum.items = items;
            if (lookup.getTeam() == p.getTeam()) {
                data.team.add(sum);
            } else {
                data.enemy.add(sum);
            }
            if (p.equals(lookup)) {
                data.lookup = sum;
            }
        }
        matchData.add(data);
        if (i++ > 10) {
            break;
        }
    }
    Files.write(Paths.get("C:\\Users\\Steffen\\Desktop\\output.json"), Utils.getGson().toJson(matchData).getBytes(StandardCharsets.UTF_8));
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) R4J(no.stelar7.api.r4j.impl.R4J)

Example 14 with R4J

use of no.stelar7.api.r4j.impl.R4J in project L4J8 by stelar7.

the class TestTimeout method getShards.

@Test
public void getShards() {
    R4J api = new R4J(SecretFile.CREDS);
    DataCall.setCacheProvider(null);
    DataCall.setGlobalTimeout(1);
    Assertions.assertThrows(APIResponseException.class, () -> {
        Summoner.byName(LeagueShard.EUW1, "stelar7");
    });
    DataCall.setGlobalTimeout(0);
}
Also used : R4J(no.stelar7.api.r4j.impl.R4J)

Example 15 with R4J

use of no.stelar7.api.r4j.impl.R4J in project L4J8 by stelar7.

the class TestVALMatch method getSingle.

@Test
public void getSingle() throws IOException {
    R4J api = new R4J(SecretFile.CREDS);
    VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
    RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "Coup De Graçe", "EUNE");
    List<MatchReference> matchlist = matchAPI.getMatchList(ValorantShard.EU, account.getPUUID());
    VALMatch match = matchAPI.getMatch(ValorantShard.EU, matchlist.get(0).getMatchId());
    Files.write(Paths.get(System.getProperty("user.home") + "\\Desktop\\game.json"), Utils.getGson().toJson(match).getBytes(StandardCharsets.UTF_8));
    System.out.println(match);
}
Also used : RiotAccount(no.stelar7.api.r4j.pojo.shared.RiotAccount) VALMatchAPI(no.stelar7.api.r4j.impl.val.VALMatchAPI) R4J(no.stelar7.api.r4j.impl.R4J)

Aggregations

R4J (no.stelar7.api.r4j.impl.R4J)20 VALMatchAPI (no.stelar7.api.r4j.impl.val.VALMatchAPI)6 Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)6 Test (org.junit.jupiter.api.Test)5 RiotAccount (no.stelar7.api.r4j.pojo.shared.RiotAccount)4 SpectatorBuilder (no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)3 SummonerBuilder (no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder)3 SpectatorGameInfo (no.stelar7.api.r4j.pojo.lol.spectator.SpectatorGameInfo)3 FileSystemCacheProvider (no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)2 LeagueShard (no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard)2 StaticChampion (no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion)2 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 DataCall (no.stelar7.api.r4j.basic.calling.DataCall)1 URLEndpoint (no.stelar7.api.r4j.basic.constants.api.URLEndpoint)1 VALContentAPI (no.stelar7.api.r4j.impl.val.VALContentAPI)1 VALRankedAPI (no.stelar7.api.r4j.impl.val.VALRankedAPI)1 ChampionMastery (no.stelar7.api.r4j.pojo.lol.championmastery.ChampionMastery)1 no.stelar7.api.r4j.pojo.lol.match.v5 (no.stelar7.api.r4j.pojo.lol.match.v5)1 StaticMastery (no.stelar7.api.r4j.pojo.lol.staticdata.mastery.StaticMastery)1