Search in sources :

Example 16 with FileSystemCacheProvider

use of no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider 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 17 with FileSystemCacheProvider

use of no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider in project L4J8 by stelar7.

the class MatchListTest method testMatchlistAllLazy.

@Test
public void testMatchlistAllLazy() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    DataCall.getCacheProvider().clear(URLEndpoint.V3_MATCHLIST);
    for (int i = 0; i < Constants.TEST_ACCOUNT_IDS.length; i++) {
        List<MatchReference> list = new MatchListBuilder().withAccountId(Constants.TEST_ACCOUNT_IDS[i]).withPlatform(Constants.TEST_PLATFORM[i]).getLazy();
        Assert.assertTrue("LazyList loaded data?!", list.isEmpty());
        list.get(51);
        Assert.assertTrue("LazyList didnt load data?!", !list.isEmpty());
    }
}
Also used : FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)

Example 18 with FileSystemCacheProvider

use of no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider in project L4J8 by stelar7.

the class MatchListTest method testMatchAndMatchList.

@Test
@Ignore
public void testMatchAndMatchList() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    DataCall.setLogLevel(LogLevel.INFO);
    // EnumSet.of(GameQueueType.TEAM_BUILDER_RANKED_SOLO);
    Set<GameQueueType> queue = null;
    // EnumSet.of(SeasonType.SEASON_2018);
    Set<SeasonType> season = null;
    // new HashSet<>(Collections.singletonList(40));
    Set<Integer> champ = null;
    // LocalDateTime.now().withHour(0).toEpochSecond(ZoneOffset.UTC) * 1000;//1481108400000L; // start of season 2017
    Long beginTime = null;
    // LocalDateTime.now().withHour(0).plusWeeks(1).toEpochSecond(ZoneOffset.UTC) * 1000; // 604800000 is one week in ms
    Long endTime = null;
    // 0;
    Long beginIndex = null;
    // 100;
    Long endIndex = null;
    MatchListBuilder builder = new MatchListBuilder();
    Summoner sum = new SummonerBuilder().withPlatform(Platform.EUW1).withName("stelar7").get();
    builder = builder.withPlatform(sum.getPlatform()).withAccountId(sum.getAccountId());
    builder = builder.withBeginTime(beginTime).withEndTime(endTime);
    builder = builder.withBeginIndex(beginIndex).withEndIndex(endIndex);
    builder = builder.withQueues(queue).withSeasons(season).withChampions(champ);
    LazyList<MatchReference> all = builder.getLazy();
    MatchBuilder mb = new MatchBuilder();
    TimelineBuilder tb = new TimelineBuilder();
    for (MatchReference reference : all) {
        Match detail = reference.getFullMatch();
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)

Example 19 with FileSystemCacheProvider

use of no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider in project L4J8 by stelar7.

the class StaticTest method testLanguageStrings.

@Test
public void testLanguageStrings() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    DataCall.setLogLevel(LogLevel.DEBUG);
    Map<String, String> strings = api.getLanguageStrings(Platform.EUW1, null, null);
}
Also used : FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)

Example 20 with FileSystemCacheProvider

use of no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider in project L4J8 by stelar7.

the class StaticTest method testRuneSingle.

@Test
public void testRuneSingle() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    DataCall.setLogLevel(LogLevel.DEBUG);
    EnumSet<RuneDataFlags> dataFlags = EnumSet.of(RuneDataFlags.ALL, RuneDataFlags.IMAGE);
    StaticRune rune = api.getRune(Platform.EUW1, 5023, dataFlags, null, null);
    Assert.assertTrue("missing id?", rune.getId() == 5023);
    Assert.assertTrue("missing stats?", rune.getStats() != null);
    Assert.assertTrue("missing desc?", rune.getDescription() != null);
    Assert.assertTrue("missing tags?", rune.getTags() != null);
    Assert.assertTrue("missing image?", rune.getImage() != null);
    Assert.assertTrue("missing sandesc?", rune.getSanitizedDescription() != null);
    Assert.assertTrue("missing rune?", rune.getRune() != null);
    Assert.assertTrue("missing name?", rune.getName() != null);
}
Also used : StaticRune(no.stelar7.api.l4j8.pojo.staticdata.rune.StaticRune) FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)

Aggregations

FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)28 StaticMastery (no.stelar7.api.l4j8.pojo.staticdata.mastery.StaticMastery)5 SummonerBuilder (no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)4 StaticChampion (no.stelar7.api.l4j8.pojo.staticdata.champion.StaticChampion)4 StaticRune (no.stelar7.api.l4j8.pojo.staticdata.rune.StaticRune)3 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)3 L4J8 (no.stelar7.api.l4j8.impl.L4J8)2 StaticSummonerSpell (no.stelar7.api.l4j8.pojo.staticdata.summonerspell.StaticSummonerSpell)2 java.awt (java.awt)1 AffineTransform (java.awt.geom.AffineTransform)1 java.awt.image (java.awt.image)1 java.io (java.io)1 URL (java.net.URL)1 java.util (java.util)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 IntStream (java.util.stream.IntStream)1 ImageIO (javax.imageio.ImageIO)1 DataCall (no.stelar7.api.l4j8.basic.calling.DataCall)1 Platform (no.stelar7.api.l4j8.basic.constants.api.Platform)1