Search in sources :

Example 1 with PokemonSettings

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);
            }
        }
    }
}
Also used : PokemonId(POGOProtos.Enums.PokemonIdOuterClass.PokemonId) PokemonSettings(POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings) ItemTemplate(POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate)

Example 2 with PokemonSettings

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;
}
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)

Example 3 with PokemonSettings

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);
}
Also used : PokemonSettings(POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings) StatsAttributes(POGOProtos.Settings.Master.Pokemon.StatsAttributesOuterClass.StatsAttributes) NoSuchItemException(com.pokegoapi.exceptions.NoSuchItemException)

Example 4 with PokemonSettings

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);
}
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) FileOutputStream(java.io.FileOutputStream) DownloadItemTemplatesResponse(POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse) MoveSettings(POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings)

Example 5 with PokemonSettings

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());
}
Also used : PokemonSettings(POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings) StatsAttributes(POGOProtos.Settings.Master.Pokemon.StatsAttributesOuterClass.StatsAttributes)

Aggregations

PokemonSettings (POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings)7 StatsAttributes (POGOProtos.Settings.Master.Pokemon.StatsAttributesOuterClass.StatsAttributes)4 ItemTemplate (POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate)3 BadgeSettings (POGOProtos.Settings.Master.BadgeSettingsOuterClass.BadgeSettings)2 ItemSettings (POGOProtos.Settings.Master.ItemSettingsOuterClass.ItemSettings)2 MoveSettings (POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings)2 PokemonId (POGOProtos.Enums.PokemonIdOuterClass.PokemonId)1 DownloadItemTemplatesResponse (POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse)1 PlayerLevelSettings (POGOProtos.Settings.Master.PlayerLevelSettingsOuterClass.PlayerLevelSettings)1 Evolutions (com.pokegoapi.api.pokemon.Evolutions)1 NoSuchItemException (com.pokegoapi.exceptions.NoSuchItemException)1 FileOutputStream (java.io.FileOutputStream)1