use of POGOProtos.Enums.PokemonIdOuterClass.PokemonId in project PokeGOAPI-Java by Grover-c13.
the class Evolutions method initialize.
/**
* Initializes these evolutions from PokemonSettings
*
* @param templates the templates to initialize from
*/
public static void initialize(List<ItemTemplate> templates) {
EVOLUTIONS.clear();
for (ItemTemplate template : templates) {
if (template.hasPokemonSettings()) {
PokemonSettings settings = template.getPokemonSettings();
PokemonId pokemon = settings.getPokemonId();
if (!EVOLUTIONS.containsKey(pokemon)) {
addEvolution(null, pokemon);
}
}
}
}
use of POGOProtos.Enums.PokemonIdOuterClass.PokemonId 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);
}
}
use of POGOProtos.Enums.PokemonIdOuterClass.PokemonId in project PokeGOAPI-Java by Grover-c13.
the class TransferMultiplePokemon method main.
/**
* Transfers all bad pokemon from the player's inventory.
*/
public static void main(String[] args) {
OkHttpClient http = new OkHttpClient();
PokemonGo api = new PokemonGo(http);
try {
HashProvider hasher = ExampleConstants.getHashProvider();
api.login(new PtcCredentialProvider(http, ExampleConstants.LOGIN, ExampleConstants.PASSWORD), hasher);
api.setLocation(ExampleConstants.LATITUDE, ExampleConstants.LONGITUDE, ExampleConstants.ALTITUDE);
PokeBank pokebank = api.inventories.pokebank;
List<Pokemon> pokemons = pokebank.pokemons;
List<Pokemon> transferPokemons = new ArrayList<>();
// Find all pokemon of bad types or with IV less than 25%
for (Pokemon pokemon : pokemons) {
PokemonId id = pokemon.getPokemonId();
double iv = pokemon.getIvInPercentage();
if (iv < 90) {
if (id == PokemonId.RATTATA || id == PokemonId.PIDGEY || id == PokemonId.CATERPIE || id == PokemonId.WEEDLE || id == PokemonId.MAGIKARP || id == PokemonId.ZUBAT || iv < 25) {
transferPokemons.add(pokemon);
}
}
}
System.out.println("Releasing " + transferPokemons.size() + " pokemon.");
Pokemon[] transferArray = transferPokemons.toArray(new Pokemon[transferPokemons.size()]);
Map<PokemonFamilyId, Integer> responses = pokebank.releasePokemon(transferArray);
// Loop through all responses and find the total amount of candies earned for each family
Map<PokemonFamilyId, Integer> candies = new HashMap<>();
for (Map.Entry<PokemonFamilyId, Integer> entry : responses.entrySet()) {
int candyAwarded = entry.getValue();
PokemonFamilyId family = entry.getKey();
Integer candy = candies.get(family);
if (candy == null) {
// candies map does not yet contain the amount if null, so set it to 0
candy = 0;
}
// Add the awarded candies from this request
candy += candyAwarded;
candies.put(family, candy);
}
for (Map.Entry<PokemonFamilyId, Integer> entry : candies.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue() + " candies awarded");
}
} catch (RequestFailedException e) {
// failed to login, invalid credentials, auth issue or server issue.
Log.e("Main", "Failed to login. Invalid credentials, captcha or server issue: ", e);
}
}
use of POGOProtos.Enums.PokemonIdOuterClass.PokemonId in project PokeGOAPI-Java by Grover-c13.
the class Evolutions method getHighest.
/**
* Gets the highest evolution pokemon in the given evolution chain.
*
* @param pokemon the pokemon to find the highest evolution for
* @return the highest evolution for the given pokemon
*/
public List<PokemonId> getHighest(PokemonId pokemon) {
List<PokemonId> highest = new ArrayList<>();
Evolution evolution = getEvolution(pokemon);
if (evolution != null) {
if (evolution.evolutions != null && evolution.evolutions.size() > 0) {
for (PokemonId child : evolution.evolutions) {
highest.addAll(getHighest(child));
}
} else {
highest.add(pokemon);
}
return highest;
} else {
highest.add(pokemon);
return highest;
}
}
use of POGOProtos.Enums.PokemonIdOuterClass.PokemonId in project PokeGOAPI-Java by Grover-c13.
the class Evolutions method addEvolution.
/**
* Auxiliar method to add the evolution by recursion in the EVOLUTIONS Map
*
* @param parent the parent of this pokemon
* @param pokemon the pokemon that evolution will be added
*/
private void addEvolution(PokemonId parent, PokemonId pokemon) {
Evolution evolution = new Evolution(itemTemplates, parent, pokemon);
evolutions.put(pokemon, evolution);
for (PokemonId poke : evolution.evolutions) {
addEvolution(pokemon, poke);
}
}
Aggregations