Search in sources :

Example 6 with LOLMatch

use of no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch in project L4J8 by stelar7.

the class TournamentTest method testAllRegistrations.

@Test
@Disabled
public void testAllRegistrations() {
    final ProviderRegistrationParameters params = new ProviderRegistrationParameters(LeagueShard.EUW1, "http://stelar7.no/loltest/provider.php");
    final long providerId = this.api.registerAsProvider(params);
    final TournamentRegistrationParameters trparams = new TournamentRegistrationParameters("THE BEST TOURNAMENT EVER", providerId);
    final long tournamentId = this.api.registerTournament(trparams);
    final int teamSize = 5;
    SpectatorBuilder spectatorBuilder = new SpectatorBuilder().withPlatform(LeagueShard.EUW1);
    final SpectatorGameInfo game = spectatorBuilder.getFeaturedGames().get(0);
    List<String> names = game.getParticipants().stream().map(SpectatorParticipant::getSummonerName).collect(Collectors.toList());
    List<String> ids = new ArrayList<>();
    SummonerBuilder sb = new SummonerBuilder().withPlatform(LeagueShard.EUW1);
    for (String name : names) {
        ids.add(sb.withName(name).get().getSummonerId());
    }
    final TournamentCodeUpdateParameters tcinner = new TournamentCodeUpdateParameters(ids, TournamentMapType.SUMMONERS_RIFT, TournamentPickType.TOURNAMENT_DRAFT, TournamentSpectatorType.ALL);
    final TournamentCodeParameters tcparams = new TournamentCodeParameters(tcinner, "THIS IS METADATA YOOO", teamSize);
    final List<String> codes = this.api.generateTournamentCodes(tcparams, tournamentId, 1);
    final TournamentCodeUpdateParameters tcuparams = new TournamentCodeUpdateParameters(ids, TournamentMapType.TWISTED_TREELINE, TournamentPickType.TOURNAMENT_DRAFT, TournamentSpectatorType.ALL);
    final List<LobbyEvent> events = this.api.getTournamentLobbyInfo(codes.get(0));
    if (!api.isStub()) {
        this.api.updateTournament(codes.get(0), tcuparams);
        final TournamentCode id = this.api.getTournamentInfo(codes.get(0));
        final List<Long> tournamentCodeMatchIds = this.api.getMatchIds(LeagueShard.EUW1, codes.get(0));
        final LOLMatch matchDetail = this.api.getMatchInfo(LeagueShard.EUW1, codes.get(0), tournamentCodeMatchIds.get(0));
    }
}
Also used : SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) LOLMatch(no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Example 7 with LOLMatch

use of no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch 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 8 with LOLMatch

use of no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch in project L4J8 by stelar7.

the class GenerateDataTest method generateStuff.

@Test
@Disabled
public void generateStuff() throws IOException {
    R4J api = new R4J(SecretFile.CREDS);
    Summoner self = Summoner.byName(LeagueShard.EUW1, "stelar7");
    MatchIterator iterator = self.getLeagueGames().getMatchIterator();
    int i = 0;
    List<InternalMatchData> matchData = new ArrayList<>();
    for (LOLMatch m : iterator) {
        MatchParticipant lookup = m.getParticipants().stream().filter(p -> p.getPuuid().equals(self.getPUUID())).findFirst().get();
        InternalMatchData data = new InternalMatchData();
        data.queue = m.getQueue().commonName();
        data.win = lookup.didWin();
        data.startTime = m.getMatchCreationAsDate().toInstant().toEpochMilli();
        Map<String, InternalMatchSummoner> sums = new HashMap<>();
        for (MatchParticipant p : m.getParticipants()) {
            InternalMatchSummoner sum = new InternalMatchSummoner();
            sum.name = p.getSummonerName();
            sum.champion = p.getChampionId();
            sum.summoner1 = p.getSummoner1Id();
            sum.summoner2 = p.getSummoner2Id();
            sum.perks = generatePerkList(p.getPerks());
            sum.kills = p.getKills();
            sum.deaths = p.getDeaths();
            sum.assists = p.getAssists();
            sum.level = p.getChampionLevel();
            sum.cs = p.getTotalMinionsKilled();
            List<Integer> items = Arrays.asList(p.getItem0(), p.getItem1(), p.getItem2(), p.getItem3(), p.getItem4(), p.getItem5(), p.getItem6());
            Collections.sort(items);
            sum.items = items;
            if (lookup.getTeam() == p.getTeam()) {
                data.team.add(sum);
            } else {
                data.enemy.add(sum);
            }
            if (p.equals(lookup)) {
                data.lookup = sum;
            }
        }
        matchData.add(data);
        if (i++ > 10) {
            break;
        }
    }
    Files.write(Paths.get("C:\\Users\\Steffen\\Desktop\\output.json"), Utils.getGson().toJson(matchData).getBytes(StandardCharsets.UTF_8));
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) R4J(no.stelar7.api.r4j.impl.R4J)

Example 9 with LOLMatch

use of no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch in project L4J8 by stelar7.

the class MatchListV5Test method testForMissingAttributes.

@Test
public void testForMissingAttributes() {
    LeagueAPI leagueAPI = r4J.getLoLAPI().getLeagueAPI();
    List<LeagueEntry> divis = leagueAPI.getLeagueByTierDivision(LeagueShard.EUW1, GameQueueType.RANKED_SOLO_5X5, TierDivisionType.GOLD_I, 1);
    for (LeagueEntry entry : divis) {
        Summoner summoner = Summoner.bySummonerId(LeagueShard.EUW1, entry.getSummonerId());
        List<String> lazy = summoner.getLeagueGames().get();
        for (int i = 0; i < lazy.size() && i < 5; i++) {
            String match = lazy.get(i);
            LOLMatch lolMatch = LOLMatch.get(LeagueShard.EUW1, match);
            lolMatch.getTimeline();
        }
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) LeagueEntry(no.stelar7.api.r4j.pojo.lol.league.LeagueEntry) LeagueAPI(no.stelar7.api.r4j.impl.lol.raw.LeagueAPI)

Example 10 with LOLMatch

use of no.stelar7.api.r4j.pojo.lol.match.v5.LOLMatch 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)

Aggregations

Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)10 SummonerBuilder (no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder)6 FileSystemCacheProvider (no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)5 R4J (no.stelar7.api.r4j.impl.R4J)5 LeagueShard (no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard)4 MatchListBuilder (no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder)4 StaticChampion (no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion)4 java.util (java.util)3 DataCall (no.stelar7.api.r4j.basic.calling.DataCall)3 no.stelar7.api.r4j.pojo.lol.match.v5 (no.stelar7.api.r4j.pojo.lol.match.v5)3 SecretFile (no.stelar7.api.r4j.tests.SecretFile)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