Search in sources :

Example 11 with Summoner

use of no.stelar7.api.l4j8.pojo.summoner.Summoner in project L4J8 by stelar7.

the class CurrentGameTest method testCurrentGame.

@Test
public void testCurrentGame() {
    final L4J8 l4j8 = new L4J8(SecretFile.CREDS);
    SpectatorBuilder sb = new SpectatorBuilder().withPlatform(Platform.EUW1);
    // Get a game in progess
    final List<SpectatorGameInfo> game = sb.getFeaturedGames();
    // Get a summoner from that game
    final String name = game.get(0).getParticipants().get(0).getSummonerName();
    final Summoner sum = new SummonerBuilder().withPlatform(Constants.TEST_PLATFORM[0]).withName(name).get();
    // Get game info
    final SpectatorGameInfo currentGame = sb.withSummonerId(sum.getSummonerId()).getCurrentGame();
    if (currentGame != null) {
        doAssertions.accept(currentGame);
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SpectatorGameInfo(no.stelar7.api.l4j8.pojo.spectator.SpectatorGameInfo) L4J8(no.stelar7.api.l4j8.impl.L4J8) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) SpectatorBuilder(no.stelar7.api.l4j8.impl.builders.spectator.SpectatorBuilder)

Example 12 with Summoner

use of no.stelar7.api.l4j8.pojo.summoner.Summoner in project L4J8 by stelar7.

the class SummonerTest method testById.

@Test
public void testById() {
    for (int i = 0; i < Constants.TEST_SUMMONER_IDS.length; i++) {
        Summoner optional = new SummonerBuilder().withPlatform(Constants.TEST_PLATFORM[i]).withSummonerId(Constants.TEST_SUMMONER_IDS[i]).get();
        doAssertions.accept(optional);
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)

Example 13 with Summoner

use of no.stelar7.api.l4j8.pojo.summoner.Summoner in project L4J8 by stelar7.

the class SummonerBuilder method get.

/**
 * gets a summoner based on the parameters passed to the builder
 *
 * @return Summoner
 */
public Summoner get() {
    DataCallBuilder builder = new DataCallBuilder().withPlatform(this.platform);
    URLEndpoint endpoint = null;
    if (accId > 0) {
        builder.withURLParameter(Constants.ACCOUNT_ID_PLACEHOLDER, String.valueOf(this.accId));
        endpoint = URLEndpoint.V3_SUMMONER_BY_ACCOUNT;
    }
    if (sumId > 0) {
        builder.withURLParameter(Constants.SUMMONER_ID_PLACEHOLDER, String.valueOf(this.sumId));
        endpoint = URLEndpoint.V3_SUMMONER_BY_ID;
    }
    if (name.length() > 0) {
        builder.withURLParameter(Constants.SUMMONER_NAME_PLACEHOLDER, Utils.normalizeSummonerName(this.name));
        endpoint = URLEndpoint.V3_SUMMONER_BY_NAME;
    }
    builder.withEndpoint(endpoint);
    Optional chl = DataCall.getCacheProvider().get(endpoint, this.platform, this.accId, this.sumId, this.name);
    if (chl.isPresent()) {
        return (Summoner) chl.get();
    }
    Object sob = builder.build();
    if (sob instanceof Pair) {
        return null;
    }
    DataCall.getCacheProvider().store(endpoint, sob, this.platform, this.accId, this.sumId, this.name);
    return (Summoner) sob;
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) Optional(java.util.Optional)

Aggregations

Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)13 SummonerBuilder (no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)9 Optional (java.util.Optional)4 FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)3 L4J8 (no.stelar7.api.l4j8.impl.L4J8)3 MatchListBuilder (no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)3 SpectatorBuilder (no.stelar7.api.l4j8.impl.builders.spectator.SpectatorBuilder)2 StaticChampion (no.stelar7.api.l4j8.pojo.staticdata.champion.StaticChampion)2 java.awt (java.awt)1 AffineTransform (java.awt.geom.AffineTransform)1 java.awt.image (java.awt.image)1 java.io (java.io)1 URL (java.net.URL)1 java.util (java.util)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 IntStream (java.util.stream.IntStream)1 ImageIO (javax.imageio.ImageIO)1 DataCall (no.stelar7.api.l4j8.basic.calling.DataCall)1 Platform (no.stelar7.api.l4j8.basic.constants.api.Platform)1