Search in sources :

Example 1 with RiotAccount

use of no.stelar7.api.r4j.pojo.shared.RiotAccount in project L4J8 by stelar7.

the class TestVALMatch method getList.

@Test
public void getList() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    DataCall.getCacheProvider().clear(URLEndpoint.V1_VAL_MATCHLIST_BY_PUUID, new HashMap<>());
    R4J api = new R4J(SecretFile.CREDS);
    VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
    RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "stl7");
    List<MatchReference> matchlist = matchAPI.getMatchList(ValorantShard.EU, account.getPUUID());
    System.out.println(matchlist);
}
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) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)

Example 2 with RiotAccount

use of no.stelar7.api.r4j.pojo.shared.RiotAccount in project L4J8 by stelar7.

the class TestVALMatch method generateRecentGamesData.

@Test
@Disabled
public void generateRecentGamesData() throws IOException {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    loggerContext.getLogger("no.stelar7.api.r4j.basic.calling.DataCallBuilder").setLevel(Level.INFO);
    loggerContext.getLogger("no.stelar7.api.r4j.basic.ratelimiting.BurstRateLimiter").setLevel(Level.INFO);
    while (true) {
        DataCall.getCacheProvider().clear(URLEndpoint.V1_VAL_MATCH_BY_ID, new HashMap<>());
        Map<String, JsonElement> matches = new HashMap<>();
        Map<String, JsonElement> players = new HashMap<>();
        R4J api = new R4J(SecretFile.CREDS);
        VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
        RecentMatchList recentMatches = matchAPI.getRecentMatches(ValorantShard.EU, GameQueueType.COMPETITIVE);
        List<String> matchIds = recentMatches.getMatchIds().stream().limit(100).collect(Collectors.toList());
        int max = matchIds.size();
        int current = 0;
        for (String matchId : matchIds) {
            System.out.println("Working on match " + (++current) + "/" + max);
            VALMatch match = matchAPI.getMatch(ValorantShard.EU, matchId);
            JsonElement matchJson = Utils.getGson().toJsonTree(match);
            matches.put(matchId, matchJson);
            for (Player player : match.getPlayers()) {
                RiotAccount account = api.getAccountAPI().getAccountByPUUID(RegionShard.EUROPE, player.getPUUID());
                JsonElement accountJson = Utils.getGson().toJsonTree(account);
                players.put(account.getPUUID(), accountJson);
            }
        }
        JsonArray matchJson = new JsonArray();
        for (JsonElement value : matches.values()) {
            matchJson.add(value);
        }
        JsonArray playerJson = new JsonArray();
        for (JsonElement value : players.values()) {
            playerJson.add(value);
        }
        JsonObject obj = new JsonObject();
        obj.add("players", playerJson);
        obj.add("matches", matchJson);
        Path outputPath = Paths.get("C:\\cdragon\\valorant\\" + recentMatches.getGeneratedAt() + ".json");
        Files.createDirectories(outputPath.getParent());
        Files.write(outputPath, Utils.getGson().toJson(obj).getBytes(StandardCharsets.UTF_8));
    }
}
Also used : VALMatchAPI(no.stelar7.api.r4j.impl.val.VALMatchAPI) R4J(no.stelar7.api.r4j.impl.R4J) URLEndpoint(no.stelar7.api.r4j.basic.constants.api.URLEndpoint) RiotAccount(no.stelar7.api.r4j.pojo.shared.RiotAccount)

Example 3 with RiotAccount

use of no.stelar7.api.r4j.pojo.shared.RiotAccount in project L4J8 by stelar7.

the class TestSharedAccount method getShards.

@Test
@Order(3)
public void getShards() {
    R4J api = new R4J(SecretFile.CREDS);
    RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "STL7");
    RiotAccountShard shard = api.getAccountAPI().getActiveShard(RegionShard.AMERICAS, ShardableGame.LOR, account.getPUUID());
    System.out.println(shard);
    System.out.println(shard.getShardAsEnum());
}
Also used : R4J(no.stelar7.api.r4j.impl.R4J)

Example 4 with RiotAccount

use of no.stelar7.api.r4j.pojo.shared.RiotAccount 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)

Example 5 with RiotAccount

use of no.stelar7.api.r4j.pojo.shared.RiotAccount in project L4J8 by stelar7.

the class TestVALMatch method getDeep.

@Test
public void getDeep() {
    R4J api = new R4J(SecretFile.CREDS);
    VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
    RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "Jbzz", "EUW");
    List<String> ids = new ArrayList<>();
    ids.add(account.getPUUID());
    List<MatchReference> matchlist = matchAPI.getMatchList(ValorantShard.EU, account.getPUUID());
    matchlist.forEach(m -> {
        VALMatch match = matchAPI.getMatch(ValorantShard.EU, m.getMatchId());
        match.getRoundResults().forEach(r -> {
            if (match.getPlayers().stream().anyMatch(p -> p.getCharacter() == null)) {
                System.out.println();
            }
            r.getPlayerStats().forEach(s -> {
                if (s.getAbility().getGrenadeEffects() != null && !s.getAbility().getGrenadeEffects().equals("null")) {
                    System.out.println();
                }
            });
        });
        match.getPlayers().forEach(p -> ids.add(p.getPUUID()));
    });
    ids.forEach(puuid -> {
        List<MatchReference> matches = matchAPI.getMatchList(ValorantShard.EU, puuid);
        matches.forEach(m -> {
            VALMatch match = matchAPI.getMatch(ValorantShard.EU, m.getMatchId());
            match.getRoundResults().forEach(r -> {
                r.getPlayerStats().forEach(s -> {
                    if (s.getAbility().getGrenadeEffects() != null && !s.getAbility().getGrenadeEffects().equals("null")) {
                        System.out.println();
                    }
                });
            });
        });
    });
}
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)7 VALMatchAPI (no.stelar7.api.r4j.impl.val.VALMatchAPI)4 RiotAccount (no.stelar7.api.r4j.pojo.shared.RiotAccount)4 FileSystemCacheProvider (no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)1 URLEndpoint (no.stelar7.api.r4j.basic.constants.api.URLEndpoint)1