Search in sources :

Example 1 with MatchListBuilder

use of no.stelar7.api.r4j.impl.lol.builders.matchv5.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.r4j.impl.lol.builders.matchv5.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.r4j.impl.lol.builders.matchv5.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.r4j.impl.lol.builders.matchv5.match.MatchListBuilder in project L4J8 by stelar7.

the class FrameToImageTest method testStuff.

@Test
@Disabled
public void testStuff() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    Summoner sum = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName("stelar7").get();
    LazyList<String> refs = new MatchListBuilder().withPlatform(sum.getPlatform()).withPuuid(sum.getAccountId()).getLazy();
    LOLMatch full = LOLMatch.get(sum.getPlatform(), refs.get(0));
    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.r4j.pojo.lol.summoner.Summoner) IntStream(java.util.stream.IntStream) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider) java.awt.image(java.awt.image) java.util(java.util) URL(java.net.URL) R4J(no.stelar7.api.r4j.impl.R4J) MatchListBuilder(no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder) DataCall(no.stelar7.api.r4j.basic.calling.DataCall) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) no.stelar7.api.r4j.pojo.lol.match.v5(no.stelar7.api.r4j.pojo.lol.match.v5) ImageIO(javax.imageio.ImageIO) Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) Predicate(java.util.function.Predicate) AffineTransform(java.awt.geom.AffineTransform) Rectangle(no.stelar7.api.r4j.basic.utils.Rectangle) StaticChampion(no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion) java.awt(java.awt) List(java.util.List) LeagueShard(no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard) java.io(java.io) SecretFile(no.stelar7.api.r4j.tests.SecretFile) org.junit.jupiter.api(org.junit.jupiter.api) Item(no.stelar7.api.r4j.pojo.lol.staticdata.item.Item) no.stelar7.api.r4j.basic.constants.types.lol(no.stelar7.api.r4j.basic.constants.types.lol) no.stelar7.api.r4j.basic.utils(no.stelar7.api.r4j.basic.utils) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)

Example 5 with MatchListBuilder

use of no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder in project L4J8 by stelar7.

the class MatchListV5Test method testMatchListParams.

@Test
@Disabled
public void testMatchListParams() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    Summoner sum = Summoner.byName(LeagueShard.EUW1, "rufen03");
    MatchListBuilder builder = new MatchListBuilder();
    builder = builder.withPuuid(sum.getPUUID()).withPlatform(LeagueShard.EUW1);
    List<String> strings1 = builder.withCount(100).get();
    List<String> strings = builder.withQueue(GameQueueType.TEAM_BUILDER_RANKED_SOLO).get();
    List<String> strings2 = builder.withType(MatchlistMatchType.RANKED).get();
    System.out.println();
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)

Aggregations

Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)6 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.r4j.basic.cache.impl.FileSystemCacheProvider)4 FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)3 MatchListBuilder (no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder)3 SummonerBuilder (no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder)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 java.util (java.util)2 List (java.util.List)2 Predicate (java.util.function.Predicate)2 IntStream (java.util.stream.IntStream)2 ImageIO (javax.imageio.ImageIO)2 JsonParser (com.google.gson.JsonParser)1 JsonWriter (com.google.gson.stream.JsonWriter)1