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));
}
}
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 :("));
}
}
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));
}
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();
}
}
}
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));
}
Aggregations