use of no.stelar7.api.l4j8.pojo.summoner.Summoner in project L4J8 by stelar7.
the class SummonerAPI method getSummonerByAccount.
/**
* The response object contains the summoner objects mapped by their username.
*
* @param server the region to execute against
* @param accountId accountId associated with summoner to retrieve.
* @return Optional Summoner
*/
public Summoner getSummonerByAccount(final Platform server, long accountId) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.ACCOUNT_ID_PLACEHOLDER, String.valueOf(accountId)).withEndpoint(URLEndpoint.V3_SUMMONER_BY_ACCOUNT).withPlatform(server);
Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_SUMMONER_BY_ACCOUNT, server, accountId);
if (chl.isPresent()) {
return (Summoner) chl.get();
}
try {
Summoner summoner = (Summoner) builder.build();
DataCall.getCacheProvider().store(URLEndpoint.V3_SUMMONER_BY_ACCOUNT, summoner, server, accountId);
return summoner;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.l4j8.pojo.summoner.Summoner in project L4J8 by stelar7.
the class SummonerAPI method getSummonerById.
/**
* The response object contains the summoner objects mapped by their user id.
*
* @param server the region to execute against
* @param summonerId summonerId associated with summoners to retrieve.
* @return Optional Summoner
*/
public Summoner getSummonerById(final Platform server, long summonerId) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.SUMMONER_ID_PLACEHOLDER, String.valueOf(summonerId)).withEndpoint(URLEndpoint.V3_SUMMONER_BY_ID).withPlatform(server);
Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_SUMMONER_BY_ID, server, "", summonerId);
if (chl.isPresent()) {
return (Summoner) chl.get();
}
try {
Summoner summoner = (Summoner) builder.build();
DataCall.getCacheProvider().store(URLEndpoint.V3_SUMMONER_BY_ID, summoner, server, "", summonerId);
return summoner;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.l4j8.pojo.summoner.Summoner 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.pojo.summoner.Summoner in project L4J8 by stelar7.
the class UseageTest method testUseage.
@Test
public void testUseage() {
L4J8 api = new L4J8(SecretFile.CREDS);
DataCall.setLogLevel(LogLevel.DEBUG);
DataCall.setCacheProvider(new FileSystemCacheProvider());
Map<Integer, StaticRune> runeData = api.getStaticAPI().getRunes(Platform.EUW1, null, null, null);
Map<Integer, StaticMastery> masteriesData = api.getStaticAPI().getMasteries(Platform.EUW1, null, null, null);
Map<Integer, StaticChampion> championData = api.getStaticAPI().getChampions(Platform.EUW1, null, null, null);
Summoner stelar7 = new SummonerBuilder().withPlatform(Platform.EUW1).withName("stelar7").get();
List<MatchReference> some = stelar7.getGames().get();
MatchReference mostRecentGame = some.stream().max(Comparator.comparing(MatchReference::getTimestamp)).get();
Match match = mostRecentGame.getFullMatch();
Participant self = match.getParticipantFromSummonerId(stelar7.getSummonerId());
List<MatchRune> runes = self.getRunes();
List<MatchMastery> masteries = self.getMasteries();
StaticChampion champion = championData.get(mostRecentGame.getChampionId());
ChampionMastery mastery = stelar7.getChampionMastery(champion.getId());
boolean didWin = match.didWin(self);
ParticipantIdentity opponentIdentity = match.getLaneOpponentIdentity(self);
Participant opponent = match.getParticipantFromParticipantId(opponentIdentity.getParticipantId());
StaticChampion opponentChampion = championData.get(opponent.getChampionId());
System.out.format("Player '%s' played their latest game as '%s'%n", stelar7.getName(), champion.getName());
System.out.format("They have a masteryscore of %s on that champion%n", mastery.getChampionPoints());
System.out.format("They played in %s, their role was: %s%n", self.getTimeline().getLane(), self.getTimeline().getRole());
System.out.format("They %s that game%n", didWin ? "won" : "lost");
System.out.format("They laned against '%s' as '%s'%n", opponentIdentity.getPlayer().getSummonerName(), opponentChampion.getName());
System.out.format("%nThey used the following runes:%n");
for (MatchRune rune : runes) {
String name = runeData.get(rune.getRuneId()).getName();
System.out.format("Name: '%-45s' Count: %s%n", name, rune.getRank());
}
System.out.format("%nThey used the following masteries:%n");
for (MatchMastery matchMastery : masteries) {
String name = masteriesData.get(matchMastery.getMasteryId()).getName();
System.out.format("Name: '%-45s' Level: %s%n", name, matchMastery.getRank());
}
}
use of no.stelar7.api.l4j8.pojo.summoner.Summoner in project L4J8 by stelar7.
the class MatchListTest method testMatchAndMatchList.
@Test
@Ignore
public void testMatchAndMatchList() {
DataCall.setCacheProvider(new FileSystemCacheProvider());
DataCall.setLogLevel(LogLevel.INFO);
// EnumSet.of(GameQueueType.TEAM_BUILDER_RANKED_SOLO);
Set<GameQueueType> queue = null;
// EnumSet.of(SeasonType.SEASON_2018);
Set<SeasonType> season = null;
// new HashSet<>(Collections.singletonList(40));
Set<Integer> champ = null;
// LocalDateTime.now().withHour(0).toEpochSecond(ZoneOffset.UTC) * 1000;//1481108400000L; // start of season 2017
Long beginTime = null;
// LocalDateTime.now().withHour(0).plusWeeks(1).toEpochSecond(ZoneOffset.UTC) * 1000; // 604800000 is one week in ms
Long endTime = null;
// 0;
Long beginIndex = null;
// 100;
Long endIndex = null;
MatchListBuilder builder = new MatchListBuilder();
Summoner sum = new SummonerBuilder().withPlatform(Platform.EUW1).withName("stelar7").get();
builder = builder.withPlatform(sum.getPlatform()).withAccountId(sum.getAccountId());
builder = builder.withBeginTime(beginTime).withEndTime(endTime);
builder = builder.withBeginIndex(beginIndex).withEndIndex(endIndex);
builder = builder.withQueues(queue).withSeasons(season).withChampions(champ);
LazyList<MatchReference> all = builder.getLazy();
MatchBuilder mb = new MatchBuilder();
TimelineBuilder tb = new TimelineBuilder();
for (MatchReference reference : all) {
Match detail = reference.getFullMatch();
}
}
Aggregations