Search in sources :

Example 6 with StaticChampion

use of no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion 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());
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) StaticChampion(no.stelar7.api.l4j8.pojo.staticdata.champion.StaticChampion) FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider) L4J8(no.stelar7.api.l4j8.impl.L4J8) StaticRune(no.stelar7.api.l4j8.pojo.staticdata.rune.StaticRune) ChampionMastery(no.stelar7.api.l4j8.pojo.championmastery.ChampionMastery) StaticMastery(no.stelar7.api.l4j8.pojo.staticdata.mastery.StaticMastery) Test(org.junit.Test)

Example 7 with StaticChampion

use of no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion in project L4J8 by stelar7.

the class StaticTest method testChampionSingle.

@Test
public void testChampionSingle() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    DataCall.setLogLevel(LogLevel.DEBUG);
    EnumSet<ChampDataFlags> dataFlags = EnumSet.of(ChampDataFlags.ALL, ChampDataFlags.IMAGE);
    StaticChampion list = api.getChampion(Platform.EUW1, Constants.TEST_CHAMPION_IDS[0], dataFlags, null, null);
    Assert.assertTrue("ok?", list.getId() == Constants.TEST_CHAMPION_IDS[0]);
}
Also used : StaticChampion(no.stelar7.api.l4j8.pojo.staticdata.champion.StaticChampion) FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)

Example 8 with StaticChampion

use of no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion in project L4J8 by stelar7.

the class DivTests method test.

@Test
public void test() {
    R4J api = new R4J(SecretFile.CREDS);
    String user = "stelar7";
    LeagueShard region = LeagueShard.EUW1;
    Summoner summoner = new SummonerBuilder().withPlatform(region).withName(user).get();
    Map<Integer, StaticChampion> champData = api.getDDragonAPI().getChampions();
    // pfp
    String pfp = ImageAPI.getInstance().getProfileIcon(region, user);
    // name and lv
    int level = summoner.getSummonerLevel();
    String name = summoner.getName();
    // most recent game
    List<String> matches = summoner.getLeagueGames().get();
    LOLMatch match = LOLMatch.get(region, matches.get(0));
    MatchParticipant self = match.getParticipants().stream().filter(p -> p.getPuuid().equals(summoner.getPUUID())).findFirst().get();
    StaticChampion champion = champData.get(self.getChampionId());
    MatchPerks summs = self.getPerks();
    boolean won = self.didWin();
    System.out.println("Profile icon: " + pfp);
    System.out.println(name + ", Level " + level);
    System.out.println();
    System.out.format(name + " %s their most recent game.", won ? "won" : "lost");
    System.out.println();
    System.out.println("They were playing " + self.getChampionSelectLane() + " " + champion.getName());
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) StaticChampion(no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion) R4J(no.stelar7.api.r4j.impl.R4J) LeagueShard(no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard) Test(org.junit.jupiter.api.Test)

Example 9 with StaticChampion

use of no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion in project L4J8 by stelar7.

the class StaticTest method testChampionSingle.

@Test
public void testChampionSingle() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    StaticChampion list = api.getChampion(1);
    double r = list.getSpells().get(0).getRange().get(0);
    System.out.println(r);
    Assertions.assertEquals(list.getId(), 1);
}
Also used : FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)

Aggregations

FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)4 StaticChampion (no.stelar7.api.l4j8.pojo.staticdata.champion.StaticChampion)4 FileSystemCacheProvider (no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)4 java.util (java.util)3 LeagueShard (no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard)3 R4J (no.stelar7.api.r4j.impl.R4J)3 StaticChampion (no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion)3 Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)3 java.awt (java.awt)2 AffineTransform (java.awt.geom.AffineTransform)2 java.awt.image (java.awt.image)2 java.io (java.io)2 URL (java.net.URL)2 List (java.util.List)2 Predicate (java.util.function.Predicate)2 IntStream (java.util.stream.IntStream)2 ImageIO (javax.imageio.ImageIO)2 L4J8 (no.stelar7.api.l4j8.impl.L4J8)2 SummonerBuilder (no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)2 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)2