use of no.stelar7.api.l4j8.impl.builders.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.l4j8.impl.builders.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.l4j8.impl.builders.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.l4j8.impl.builders.match.MatchListBuilder in project L4J8 by stelar7.
the class FrameToImageTest method testStuff.
@Test
@Ignore
public void testStuff() {
DataCall.setCacheProvider(new FileSystemCacheProvider());
Summoner sum = new SummonerBuilder().withPlatform(Platform.EUW1).withName("stelar7").get();
LazyList<MatchReference> refs = new MatchListBuilder().withPlatform(sum.getPlatform()).withAccountId(sum.getAccountId()).getLazy();
Match full = refs.get(0).getFullMatch();
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.l4j8.impl.builders.match.MatchListBuilder in project L4J8 by stelar7.
the class MatchListTest method testMatchlistAllLazy.
@Test
public void testMatchlistAllLazy() {
DataCall.setCacheProvider(new FileSystemCacheProvider());
DataCall.getCacheProvider().clear(URLEndpoint.V3_MATCHLIST);
for (int i = 0; i < Constants.TEST_ACCOUNT_IDS.length; i++) {
List<MatchReference> list = new MatchListBuilder().withAccountId(Constants.TEST_ACCOUNT_IDS[i]).withPlatform(Constants.TEST_PLATFORM[i]).getLazy();
Assert.assertTrue("LazyList loaded data?!", list.isEmpty());
list.get(51);
Assert.assertTrue("LazyList didnt load data?!", !list.isEmpty());
}
}
Aggregations