use of no.stelar7.api.l4j8.impl.L4J8 in project L4J8 by stelar7.
the class FeaturedGameTest method testCurrentGame.
@Test
public void testCurrentGame() {
final L4J8 l4j8 = new L4J8(SecretFile.CREDS);
SpectatorBuilder sb = new SpectatorBuilder().withPlatform(Platform.EUW1);
final List<SpectatorGameInfo> game = sb.getFeaturedGames();
doAssertions.accept(game);
}
use of no.stelar7.api.l4j8.impl.L4J8 in project L4J8 by stelar7.
the class UseageTest method testUseage.
@Test
public void testUseage() {
L4J8 api = new L4J8(SecretFile.CREDS);
DataCall.setLogLevel(LogLevel.DEBUG);
DataCall.setCacheProvider(new FileSystemCacheProvider());
Map<Integer, StaticRune> runeData = api.getStaticAPI().getRunes(Platform.EUW1, null, null, null);
Map<Integer, StaticMastery> masteriesData = api.getStaticAPI().getMasteries(Platform.EUW1, null, null, null);
Map<Integer, StaticChampion> championData = api.getStaticAPI().getChampions(Platform.EUW1, null, null, null);
Summoner stelar7 = new SummonerBuilder().withPlatform(Platform.EUW1).withName("stelar7").get();
List<MatchReference> some = stelar7.getGames().get();
MatchReference mostRecentGame = some.stream().max(Comparator.comparing(MatchReference::getTimestamp)).get();
Match match = mostRecentGame.getFullMatch();
Participant self = match.getParticipantFromSummonerId(stelar7.getSummonerId());
List<MatchRune> runes = self.getRunes();
List<MatchMastery> masteries = self.getMasteries();
StaticChampion champion = championData.get(mostRecentGame.getChampionId());
ChampionMastery mastery = stelar7.getChampionMastery(champion.getId());
boolean didWin = match.didWin(self);
ParticipantIdentity opponentIdentity = match.getLaneOpponentIdentity(self);
Participant opponent = match.getParticipantFromParticipantId(opponentIdentity.getParticipantId());
StaticChampion opponentChampion = championData.get(opponent.getChampionId());
System.out.format("Player '%s' played their latest game as '%s'%n", stelar7.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.getTimeline().getLane(), self.getTimeline().getRole());
System.out.format("They %s that game%n", didWin ? "won" : "lost");
System.out.format("They laned against '%s' as '%s'%n", opponentIdentity.getPlayer().getSummonerName(), opponentChampion.getName());
System.out.format("%nThey used the following runes:%n");
for (MatchRune rune : runes) {
String name = runeData.get(rune.getRuneId()).getName();
System.out.format("Name: '%-45s' Count: %s%n", name, rune.getRank());
}
System.out.format("%nThey used the following masteries:%n");
for (MatchMastery matchMastery : masteries) {
String name = masteriesData.get(matchMastery.getMasteryId()).getName();
System.out.format("Name: '%-45s' Level: %s%n", name, matchMastery.getRank());
}
}
use of no.stelar7.api.l4j8.impl.L4J8 in project L4J8 by stelar7.
the class CurrentGameTest method testCurrentGame.
@Test
public void testCurrentGame() {
final L4J8 l4j8 = new L4J8(SecretFile.CREDS);
SpectatorBuilder sb = new SpectatorBuilder().withPlatform(Platform.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(Constants.TEST_PLATFORM[0]).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.l4j8.impl.L4J8 in project L4J8 by stelar7.
the class CurrentGameTest method testCurrentlyNotInGame.
@Test
public void testCurrentlyNotInGame() {
final L4J8 l4j8 = new L4J8(SecretFile.CREDS);
SpectatorBuilder sb = new SpectatorBuilder().withPlatform(Constants.TEST_PLATFORM[0]).withSummonerId(Constants.TEST_SUMMONER_IDS[0]);
SpectatorGameInfo game = sb.getCurrentGame();
System.out.format("%s is %sin game%n", Constants.TEST_SUMMONER_NAMES[0], game != null ? "" : "not ");
}
Aggregations