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