Search in sources :

Example 11 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
@Disabled
public void testFindSelfInNormalGame() {
    Summoner summoner = new SummonerBuilder().withPlatform(LeagueShard.NA1).withName("devitgg").get();
    List<String> refs = new MatchListBuilder().withPlatform(LeagueShard.NA1).withPuuid(summoner.getPUUID()).get();
    for (String current : refs) {
        LOLMatch match = LOLMatch.get(LeagueShard.NA1, current);
        MatchParticipant self = match.getParticipants().stream().filter(p -> p.getPuuid().equals(summoner.getPUUID())).findFirst().get();
        System.out.println("I " + (self.didWin() ? "won!" : "lost :("));
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder)

Example 12 with MatchListBuilder

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

the class MatchListV5Test method testMatchInvalidSpellSlots.

@Test
@Disabled
public void testMatchInvalidSpellSlots() throws IOException {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    MatchListBuilder builder = new MatchListBuilder();
    Summoner sum = Summoner.byName(LeagueShard.EUW1, "stelar7");
    LazyList<String> all = sum.getLeagueGames().getLazy();
    MatchBuilder mb = new MatchBuilder(sum.getPlatform());
    TimelineBuilder tb = new TimelineBuilder(sum.getPlatform());
    StringWriter sw = new StringWriter();
    JsonWriter sb = new JsonWriter(sw);
    sb.beginObject();
    int i = 0;
    for (String matchid : all) {
        if (i++ > 10)
            break;
        tb = tb.withId(matchid);
        mb = mb.withId(matchid);
        LOLMatch match = mb.getMatch();
        LOLTimeline lolTimeline = tb.getTimeline();
        List<TimelineDamageData> wierdEntries = new ArrayList<>();
        lolTimeline.getFrames().forEach(frame -> {
            frame.getEvents().forEach(event -> {
                if (event.getType() == EventType.CHAMPION_KILL) {
                    event.getVictimDamageReceived().forEach(d -> {
                        if (d.getSpellSlot() == SpellSlotType.INVALID || d.getSpellSlot() == SpellSlotType.UNDOCUMENTED || d.getSpellSlot() == SpellSlotType.UNUSED || d.getSpellSlot() == SpellSlotType.OUT_OF_BOUNDS) {
                            wierdEntries.add(d);
                        }
                    });
                    event.getVictimDamageDealt().forEach(d -> {
                        if (d.getSpellSlot() == SpellSlotType.INVALID || d.getSpellSlot() == SpellSlotType.UNDOCUMENTED || d.getSpellSlot() == SpellSlotType.UNUSED || d.getSpellSlot() == SpellSlotType.OUT_OF_BOUNDS) {
                            wierdEntries.add(d);
                        }
                    });
                }
            });
        });
        if (wierdEntries.size() > 0) {
            sb.name(tb.getID());
            sb.beginArray();
            for (TimelineDamageData wierdEntry : wierdEntries) {
                sb.jsonValue(Utils.getGson().toJson(wierdEntry));
            }
            sb.endArray();
        }
    }
    sb.endObject();
    sb.flush();
    String output = Utils.getGson().toJson(new JsonParser().parse(sw.toString()));
    Files.write(Paths.get("C:\\Users\\stelar7\\Desktop\\errors.json"), output.getBytes(StandardCharsets.UTF_8));
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider) JsonWriter(com.google.gson.stream.JsonWriter) JsonParser(com.google.gson.JsonParser)

Example 13 with MatchListBuilder

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

the class MatchListV5Test method testMatchParticipantIds.

@Test
@Disabled
public void testMatchParticipantIds() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    MatchListBuilder builder = new MatchListBuilder();
    Summoner sum = Summoner.byName(LeagueShard.EUW1, "fckmuffin");
    LazyList<String> all = sum.getLeagueGames().getLazy();
    MatchBuilder mb = new MatchBuilder(sum.getPlatform());
    TimelineBuilder tb = new TimelineBuilder(sum.getPlatform());
    for (String matchid : all) {
        tb = tb.withId(matchid);
        mb = mb.withId(matchid);
        LOLMatch match = mb.getMatch();
        LOLTimeline lolTimeline = tb.getTimeline();
        List<TimelineDamageData> wierdEntries = new ArrayList<>();
        lolTimeline.getFrames().forEach(frame -> {
            frame.getParticipantFrames().forEach((k, v) -> {
                if (!k.equals(String.valueOf(v.getParticipantId()))) {
                    System.out.println(matchid + " has mismatched participantid and key");
                }
            });
        });
    }
}
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