Search in sources :

Example 1 with MatchListBuilder

use of no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder in project L4J8 by stelar7.

the class CheckNormalGameForWinTest method testFindSelfInNormalGame.

@Test
@Ignore
public void testFindSelfInNormalGame() {
    Summoner dev = new SummonerBuilder().withPlatform(Platform.NA1).withName("devitgg").get();
    List<MatchReference> refs = new MatchListBuilder().withPlatform(Platform.NA1).withAccountId(dev.getAccountId()).get();
    for (MatchReference current : refs) {
        Match fullGame = current.getFullMatch();
        List<Participant> candidates = new ArrayList<>();
        for (Participant participant : fullGame.getParticipants()) {
            if (participant.getChampionId() == current.getChampionId()) {
                candidates.add(participant);
            }
        }
        candidates.removeIf(candidate -> candidate.getTimeline().getLane() != current.getLane());
        candidates.removeIf(candidate -> candidate.getTimeline().getRole() != current.getRole());
        if (candidates.size() == 1) {
            Participant self = candidates.get(0);
            System.out.println("I " + (self.getStats().isWinner() ? "won!" : "lost :("));
        } else {
            System.out.println("Unable to find self!");
        }
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)

Example 2 with MatchListBuilder

use of no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder in project L4J8 by stelar7.

the class CheckNormalGameForWinTest method testFindSelfAfterNormalGame.

@Test
@Ignore
public void testFindSelfAfterNormalGame() {
    Summoner dev = new SummonerBuilder().withPlatform(Platform.NA1).withName("devitgg").get();
    while (new SpectatorBuilder().withPlatform(Platform.NA1).withSummonerId(dev.getSummonerId()).getCurrentGame() != null) {
        try {
            Thread.sleep(30000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    List<MatchReference> refs = new MatchListBuilder().withPlatform(Platform.NA1).withAccountId(dev.getAccountId()).get();
    for (MatchReference current : refs) {
        Match fullGame = current.getFullMatch();
        List<Participant> candidates = new ArrayList<>();
        for (Participant participant : fullGame.getParticipants()) {
            if (participant.getChampionId() == current.getChampionId()) {
                candidates.add(participant);
            }
        }
        candidates.removeIf(candidate -> candidate.getTimeline().getLane() != current.getLane());
        candidates.removeIf(candidate -> candidate.getTimeline().getRole() != current.getRole());
        if (candidates.size() == 1) {
            Participant self = candidates.get(0);
            System.out.println("I " + (self.getStats().isWinner() ? "won!" : "lost :("));
        } else {
            System.out.println("Unable to find self!");
        }
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder) SpectatorBuilder(no.stelar7.api.l4j8.impl.builders.spectator.SpectatorBuilder)

Example 3 with MatchListBuilder

use of no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder in project L4J8 by stelar7.

the class CacheTest method doCacheStuff.

private void doCacheStuff() throws InterruptedException {
    List<MatchReference> recents = new MatchListBuilder().withPlatform(Constants.TEST_PLATFORM[0]).withAccountId(Constants.TEST_ACCOUNT_IDS[0]).get();
    if (recents.isEmpty()) {
        return;
    }
    MatchReference ref = recents.get(0);
    System.out.println("Starting timer");
    long start = stopwatch.runtime(TimeUnit.NANOSECONDS);
    Match url = ref.getFullMatch();
    System.out.printf("1x url fetch time: %dns%n", stopwatch.runtime(TimeUnit.NANOSECONDS) - start);
    start = stopwatch.runtime(TimeUnit.NANOSECONDS);
    Match cached = ref.getFullMatch();
    System.out.printf("1x cache fetch time: %dns%n", stopwatch.runtime(TimeUnit.NANOSECONDS) - start);
    if (!url.equals(cached)) {
        throw new RuntimeException("CACHE IS BROKEN!!!!");
    }
    start = stopwatch.runtime(TimeUnit.NANOSECONDS);
    for (int i = 0; i < 10; i++) {
        ref.getFullMatch();
    }
    System.out.printf("10x cache fetch time: %dns%n", stopwatch.runtime(TimeUnit.NANOSECONDS) - start);
    System.out.println();
    start = stopwatch.runtime(TimeUnit.NANOSECONDS);
    ref.getFullMatch();
    System.out.printf("1x cache fetch time: %dns%n", stopwatch.runtime(TimeUnit.NANOSECONDS) - start);
    System.out.println();
    System.out.println("clearing cache");
    System.out.println();
    DataCall.getCacheProvider().clear(URLEndpoint.V3_MATCH);
    start = stopwatch.runtime(TimeUnit.NANOSECONDS);
    ref.getFullMatch();
    System.out.printf("1x url fetch time: %dns%n", stopwatch.runtime(TimeUnit.NANOSECONDS) - start);
    start = stopwatch.runtime(TimeUnit.NANOSECONDS);
    for (int i = 0; i < 10; i++) {
        ref.getFullMatch();
    }
    System.out.printf("10x cache fetch time: %dns%n", stopwatch.runtime(TimeUnit.NANOSECONDS) - start);
    System.out.println();
    System.out.println("Fetching 3 aditional matches");
    recents.get(1).getFullMatch();
    recents.get(2).getFullMatch();
    recents.get(3).getFullMatch();
    System.out.printf("Cache size: %d%n", DataCall.getCacheProvider().getSize(URLEndpoint.V3_MATCH));
    System.out.println("Waiting for cache timeout");
    TimeUnit.SECONDS.sleep(5);
    System.out.printf("Cache size: %d%n", DataCall.getCacheProvider().getSize(URLEndpoint.V3_MATCH));
    System.out.println("Re-fetching cached items");
    start = stopwatch.runtime(TimeUnit.NANOSECONDS);
    recents.get(0).getFullMatch();
    recents.get(1).getFullMatch();
    recents.get(2).getFullMatch();
    recents.get(3).getFullMatch();
    System.out.printf("4x fetches took: %dns%n", stopwatch.runtime(TimeUnit.NANOSECONDS) - start);
    System.out.printf("Cache size: %d%n", DataCall.getCacheProvider().getSize(URLEndpoint.V3_MATCH));
    System.out.println();
}
Also used : MatchListBuilder(no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)

Example 4 with MatchListBuilder

use of no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder in project L4J8 by stelar7.

the class FrameToImageTest method testStuff.

@Test
@Ignore
public void testStuff() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    Summoner sum = new SummonerBuilder().withPlatform(Platform.EUW1).withName("stelar7").get();
    LazyList<MatchReference> refs = new MatchListBuilder().withPlatform(sum.getPlatform()).withAccountId(sum.getAccountId()).getLazy();
    Match full = refs.get(0).getFullMatch();
    TowerLocationType.getTowersMap(MapType.SUMMONERS_RIFT).forEach((k, v) -> v.forEach((k2, v2) -> v2.forEach((t, p) -> turretTeam.put(p, t))));
    turretTeam.forEach((k, v) -> turrets.add(k));
    InhibitorLocationType.getInhibMap(MapType.SUMMONERS_RIFT).forEach((k, v) -> v.forEach((t, p) -> inhibTeam.put(p, t)));
    inhibTeam.forEach((k, v) -> inhib.add(k));
    generateMinimap(full);
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) IntStream(java.util.stream.IntStream) Platform(no.stelar7.api.l4j8.basic.constants.api.Platform) no.stelar7.api.l4j8.basic.utils(no.stelar7.api.l4j8.basic.utils) java.awt.image(java.awt.image) java.util(java.util) Item(no.stelar7.api.l4j8.pojo.staticdata.item.Item) no.stelar7.api.l4j8.basic.constants.types(no.stelar7.api.l4j8.basic.constants.types) URL(java.net.URL) Predicate(java.util.function.Predicate) no.stelar7.api.l4j8.pojo.match(no.stelar7.api.l4j8.pojo.match) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) AffineTransform(java.awt.geom.AffineTransform) L4J8(no.stelar7.api.l4j8.impl.L4J8) FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider) java.awt(java.awt) List(java.util.List) Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) java.io(java.io) MatchListBuilder(no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder) SecretFile(no.stelar7.api.l4j8.tests.SecretFile) ImageIO(javax.imageio.ImageIO) org.junit(org.junit) StaticChampion(no.stelar7.api.l4j8.pojo.staticdata.champion.StaticChampion) DataCall(no.stelar7.api.l4j8.basic.calling.DataCall) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder) FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)

Example 5 with MatchListBuilder

use of no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder 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)

Aggregations

MatchListBuilder (no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)5 SummonerBuilder (no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)5 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)4 FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)3 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 CompletableFuture (java.util.concurrent.CompletableFuture)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 no.stelar7.api.l4j8.basic.constants.types (no.stelar7.api.l4j8.basic.constants.types)1 no.stelar7.api.l4j8.basic.utils (no.stelar7.api.l4j8.basic.utils)1 L4J8 (no.stelar7.api.l4j8.impl.L4J8)1