use of no.stelar7.api.r4j.impl.R4J in project L4J8 by stelar7.
the class UseageTest method testUseage.
@Test
public void testUseage() {
R4J api = new R4J(SecretFile.CREDS);
DataCall.setCacheProvider(new FileSystemCacheProvider());
Map<Integer, StaticRune> runeData = api.getDDragonAPI().getRunes();
Map<Integer, StaticMastery> masteriesData = api.getDDragonAPI().getMasteries();
Map<Integer, StaticChampion> championData = api.getDDragonAPI().getChampions();
Map<Integer, StaticPerk> perkData = api.getDDragonAPI().getPerks();
Summoner summoner = Summoner.byName(LeagueShard.EUW1, "stelar7");
List<String> some = summoner.getLeagueGames().get();
LOLMatch match = LOLMatch.get(summoner.getPlatform(), some.get(0));
MatchParticipant self = match.getParticipants().stream().filter(p -> p.getPuuid().equals(summoner.getPUUID())).findFirst().get();
StaticChampion champion = championData.get(self.getChampionId());
ChampionMastery mastery = summoner.getChampionMastery(champion.getId());
boolean didWin = self.didWin();
System.out.format("Player '%s' played their latest game as '%s'%n", summoner.getName(), champion.getName());
System.out.format("They have a masteryscore of %s on that champion%n", mastery.getChampionPoints());
System.out.format("They played in %s, their role was: %s%n", self.getChampionSelectLane(), self.getRole());
System.out.format("They %s that game%n", didWin ? "won" : "lost");
System.out.format("%nThey used the following perks:%n");
List<PerkSelection> perks = self.getPerks().getPerkStyles().stream().flatMap(s -> s.getSelections().stream()).collect(Collectors.toList());
for (PerkSelection perk : perks) {
StaticPerk perkInfo = perkData.get(perk.getPerk());
String name = perkInfo.getName();
System.out.format("Name: '%-20s' variables: %-5s, %-5s, %-5s%n", name, perk.getVar1(), perk.getVar2(), perk.getVar3());
}
}
use of no.stelar7.api.r4j.impl.R4J 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);
}
use of no.stelar7.api.r4j.impl.R4J in project L4J8 by stelar7.
the class TestVALMatch method getRecent.
@Test
public void getRecent() {
R4J api = new R4J(SecretFile.CREDS);
VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
RecentMatchList recentMatches = matchAPI.getRecentMatches(ValorantShard.EU, GameQueueType.COMPETITIVE);
System.out.println(recentMatches);
}
use of no.stelar7.api.r4j.impl.R4J in project L4J8 by stelar7.
the class TestVALMatch method testGetSingleById.
@Test
public void testGetSingleById() {
R4J api = new R4J(SecretFile.CREDS);
VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
VALMatch match = matchAPI.getMatch(ValorantShard.AP, "c4eb3e3d-d175-4b73-b7d4-279374d1b19b");
System.out.println();
}
use of no.stelar7.api.r4j.impl.R4J 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));
}
}
Aggregations