Search in sources :

Example 1 with Summoner

use of no.stelar7.api.l4j8.pojo.summoner.Summoner 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!");
        }
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)

Example 2 with Summoner

use of no.stelar7.api.l4j8.pojo.summoner.Summoner 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!");
        }
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) SummonerBuilder(no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder) SpectatorBuilder(no.stelar7.api.l4j8.impl.builders.spectator.SpectatorBuilder)

Example 3 with Summoner

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

the class SummonerTest method testByAccount.

@Test
public void testByAccount() {
    for (int i = 0; i < Constants.TEST_ACCOUNT_IDS.length; i++) {
        Summoner optional = new SummonerBuilder().withPlatform(Constants.TEST_PLATFORM[i]).withAccountId(Constants.TEST_ACCOUNT_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 4 with Summoner

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

the class SummonerTest method testByName.

@Test
public void testByName() {
    for (int i = 0; i < Constants.TEST_SUMMONER_NAMES.length; i++) {
        Summoner optional = new SummonerBuilder().withPlatform(Constants.TEST_PLATFORM[i]).withName(Constants.TEST_SUMMONER_NAMES[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 5 with Summoner

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

the class SummonerAPI method getSummonerByName.

/**
 * The response object contains the summoner objects mapped by their username.
 *
 * @param server       the region to execute against
 * @param summonerName summoner name  associated with summoner to retrieve.
 * @return Optional Summoner
 */
public Summoner getSummonerByName(final Platform server, String summonerName) {
    DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.SUMMONER_NAME_PLACEHOLDER, Utils.normalizeSummonerName(summonerName)).withEndpoint(URLEndpoint.V3_SUMMONER_BY_NAME).withPlatform(server);
    Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_SUMMONER_BY_NAME, server, "", "", summonerName);
    if (chl.isPresent()) {
        return (Summoner) chl.get();
    }
    try {
        Summoner summoner = (Summoner) builder.build();
        DataCall.getCacheProvider().store(URLEndpoint.V3_SUMMONER_BY_NAME, summoner, server, "", "", summonerName);
        return summoner;
    } catch (ClassCastException e) {
        return null;
    }
}
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