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 ");
}
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);
}
}
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));
}
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);
}
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);
}
Aggregations