Search in sources :

Example 1 with Evolutions

use of com.pokegoapi.api.pokemon.Evolutions in project PokeGOAPI-Java by Grover-c13.

the class CheckEvolutionExample method main.

/**
 * Displays pokemon evolutions
 *
 * @param args Not used
 */
public static void main(String[] args) {
    OkHttpClient http = new OkHttpClient();
    final PokemonGo api = new PokemonGo(http);
    try {
        // Login and set location
        HashProvider hasher = ExampleConstants.getHashProvider();
        api.setLocation(ExampleConstants.LATITUDE, ExampleConstants.LONGITUDE, ExampleConstants.ALTITUDE);
        api.login(new PtcCredentialProvider(http, ExampleConstants.LOGIN, ExampleConstants.PASSWORD), hasher);
        // Get the evolution meta from the item templates received from the game server
        Evolutions evolutionMeta = api.itemTemplates.evolutions;
        System.out.println("Evolutions: ");
        for (PokemonId pokemon : PokemonId.values()) {
            List<PokemonId> evolutions = evolutionMeta.getEvolutions(pokemon);
            if (evolutions.size() > 0) {
                System.out.println(pokemon + " -> " + evolutions);
            }
        }
        System.out.println();
        System.out.println("Most basic: ");
        for (PokemonId pokemon : PokemonId.values()) {
            List<PokemonId> basic = evolutionMeta.getBasic(pokemon);
            if (basic.size() > 0) {
                // Check this is not the most basic pokemon
                if (!(basic.size() == 1 && basic.contains(pokemon))) {
                    System.out.println(pokemon + " -> " + basic);
                }
            }
        }
        System.out.println();
        System.out.println("Highest: ");
        for (PokemonId pokemon : PokemonId.values()) {
            List<PokemonId> highest = evolutionMeta.getHighest(pokemon);
            if (highest.size() > 0) {
                // Check this is not the highest pokemon
                if (!(highest.size() == 1 && highest.contains(pokemon))) {
                    System.out.println(pokemon + " -> " + highest);
                }
            }
        }
    } catch (RequestFailedException e) {
        // failed to login, invalid credentials, auth issue or server issue.
        Log.e("Main", "Failed to login, captcha or server issue: ", e);
    }
}
Also used : PtcCredentialProvider(com.pokegoapi.auth.PtcCredentialProvider) OkHttpClient(okhttp3.OkHttpClient) PokemonId(POGOProtos.Enums.PokemonIdOuterClass.PokemonId) RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) PokemonGo(com.pokegoapi.api.PokemonGo) HashProvider(com.pokegoapi.util.hash.HashProvider) Evolutions(com.pokegoapi.api.pokemon.Evolutions)

Example 2 with Evolutions

use of com.pokegoapi.api.pokemon.Evolutions in project PokeGOAPI-Java by Grover-c13.

the class ItemTemplates method reloadTemplates.

private void reloadTemplates() {
    templates.clear();
    pokemonSettings.clear();
    moveSettings.clear();
    badgeSettings.clear();
    itemSettings.clear();
    for (ItemTemplate template : provider.getTemplates().values()) {
        if (template.hasPokemonSettings()) {
            PokemonSettings pokemonSettings = template.getPokemonSettings();
            this.pokemonSettings.put(pokemonSettings.getPokemonId(), pokemonSettings);
        } else if (template.hasMoveSettings()) {
            MoveSettings moveSettings = template.getMoveSettings();
            this.moveSettings.put(moveSettings.getMovementId(), moveSettings);
        } else if (template.hasBadgeSettings()) {
            BadgeSettings badgeSettings = template.getBadgeSettings();
            this.badgeSettings.put(badgeSettings.getBadgeType(), badgeSettings);
        } else if (template.hasItemSettings()) {
            ItemSettings itemSettings = template.getItemSettings();
            this.itemSettings.put(itemSettings.getItemId(), itemSettings);
        } else if (template.hasBattleSettings()) {
            battleSettings = template.getBattleSettings();
        } else if (template.hasPokemonUpgrades()) {
            upgradeSettings = template.getPokemonUpgrades();
        } else if (template.hasPlayerLevel()) {
            PlayerLevelSettings settings = template.getPlayerLevel();
            List<Float> multipliers = settings.getCpMultiplierList();
            for (int i = 0; i < multipliers.size(); i++) {
                double multiplier = multipliers.get(i);
                levelCpMultiplier.put(i + 1.0F, multiplier);
                double nextMultiplier = multipliers.get(Math.min(multipliers.size() - 1, i + 1));
                double step = ((nextMultiplier * nextMultiplier) - (multiplier * multiplier)) / 2.0F;
                if (i >= 30) {
                    step /= 2.0;
                }
                levelCpMultiplier.put(i + 1.5F, Math.sqrt((multiplier * multiplier) + step));
            }
        }
        templates.add(template);
    }
    evolutions = new Evolutions(this);
    loaded = true;
}
Also used : BadgeSettings(POGOProtos.Settings.Master.BadgeSettingsOuterClass.BadgeSettings) PokemonSettings(POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings) ItemSettings(POGOProtos.Settings.Master.ItemSettingsOuterClass.ItemSettings) ItemTemplate(POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate) MoveSettings(POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings) Evolutions(com.pokegoapi.api.pokemon.Evolutions) PlayerLevelSettings(POGOProtos.Settings.Master.PlayerLevelSettingsOuterClass.PlayerLevelSettings)

Aggregations

Evolutions (com.pokegoapi.api.pokemon.Evolutions)2 PokemonId (POGOProtos.Enums.PokemonIdOuterClass.PokemonId)1 ItemTemplate (POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate)1 BadgeSettings (POGOProtos.Settings.Master.BadgeSettingsOuterClass.BadgeSettings)1 ItemSettings (POGOProtos.Settings.Master.ItemSettingsOuterClass.ItemSettings)1 MoveSettings (POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings)1 PlayerLevelSettings (POGOProtos.Settings.Master.PlayerLevelSettingsOuterClass.PlayerLevelSettings)1 PokemonSettings (POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings)1 PokemonGo (com.pokegoapi.api.PokemonGo)1 PtcCredentialProvider (com.pokegoapi.auth.PtcCredentialProvider)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 HashProvider (com.pokegoapi.util.hash.HashProvider)1 OkHttpClient (okhttp3.OkHttpClient)1