use of POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings 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.Settings.Master.PokemonSettingsOuterClass.PokemonSettings 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;
}
use of POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings in project PokeGOAPI-Java by Grover-c13.
the class PokemonCpUtils method getAbsoluteMaxCp.
/**
* Get the absolute maximum CP for pokemons with their PokemonId.
*
* @param api the current api
* @param id The {@link PokemonId} of the Pokemon to get CP for.
* @return The absolute maximum CP
* @throws NoSuchItemException If the PokemonId value cannot be found in the {@link ItemTemplates}.
*/
public static int getAbsoluteMaxCp(PokemonGo api, PokemonId id) throws NoSuchItemException {
PokemonSettings settings = api.itemTemplates.getPokemonSettings(id);
if (settings == null) {
throw new NoSuchItemException("Cannot find meta data for " + id);
}
StatsAttributes stats = settings.getStats();
int attack = 15 + stats.getBaseAttack();
int defense = 15 + stats.getBaseDefense();
int stamina = 15 + stats.getBaseStamina();
return getMaxCpForPlayer(api, attack, defense, stamina, 40);
}
use of POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings in project PokeGOAPI-Java by Grover-c13.
the class PokemonMeta method update.
/**
* Updates the PokemonMeta from the response to DownloadItemTemplatesResponse and caches it
*
* @param data the data from the response
* @param write if this should write the data to the cache
* @throws IOException if writing fails
*/
public static void update(ByteString data, boolean write) throws IOException {
DownloadItemTemplatesResponse templatesResponse = DownloadItemTemplatesResponse.parseFrom(data);
if (write) {
data.writeTo(new FileOutputStream(Utils.createTempFile("templates")));
}
List<ItemTemplate> templates = templatesResponse.getItemTemplatesList();
PokemonMeta.templates.clear();
PokemonMeta.templates.addAll(templates);
for (ItemTemplate template : templates) {
if (template.hasPokemonSettings()) {
PokemonSettings pokemonSettings = template.getPokemonSettings();
PokemonMeta.pokemonSettings.put(pokemonSettings.getPokemonId(), pokemonSettings);
} else if (template.hasMoveSettings()) {
MoveSettings moveSettings = template.getMoveSettings();
PokemonMeta.moveSettings.put(moveSettings.getMovementId(), moveSettings);
} else if (template.hasBadgeSettings()) {
BadgeSettings badgeSettings = template.getBadgeSettings();
PokemonMeta.badgeSettings.put(badgeSettings.getBadgeType(), badgeSettings);
} else if (template.hasItemSettings()) {
ItemSettings itemSettings = template.getItemSettings();
PokemonMeta.itemSettings.put(itemSettings.getItemId(), itemSettings);
} else if (template.hasBattleSettings()) {
battleSettings = template.getBattleSettings();
} else if (template.hasPokemonUpgrades()) {
upgradeSettings = template.getPokemonUpgrades();
}
}
Evolutions.initialize(templates);
PokemonCpUtils.initialize(templates);
}
use of POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings in project PokeGOAPI-Java by Grover-c13.
the class PokemonDetails method getCpAfterFullEvolve.
/**
* Calculate the CP after fully evolving this Pokemon
*
* @param highestEvolution the pokemon at the top of the evolution chain being evolved into
* @return New CP after evolve
*/
public int getCpAfterFullEvolve(PokemonId highestEvolution) {
PokemonSettings settings = api.itemTemplates.getPokemonSettings(highestEvolution);
StatsAttributes stats = settings.getStats();
int attack = getIndividualAttack() + stats.getBaseAttack();
int defense = getIndividualDefense() + stats.getBaseDefense();
int stamina = getIndividualStamina() + stats.getBaseStamina();
return PokemonCpUtils.getCp(attack, defense, stamina, getCombinedCpMultiplier());
}
Aggregations