Search in sources :

Example 1 with MoveSettings

use of POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings 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 2 with MoveSettings

use of POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings 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 3 with MoveSettings

use of POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings in project PokeGOAPI-Java by Grover-c13.

the class FightGymExample method handleAttack.

private static void handleAttack(PokemonGo api, Battle battle) throws InterruptedException {
    int duration;
    PokemonMove specialMove = battle.activeAttacker.pokemon.getMove2();
    MoveSettings moveSettings = api.itemTemplates.getMoveSettings(specialMove);
    // Check if we have sufficient energy to perform a special attack
    int energy = battle.activeAttacker.energy;
    int desiredEnergy = -moveSettings.getEnergyDelta();
    if (energy <= desiredEnergy) {
        duration = battle.attack();
    } else {
        duration = battle.attackSpecial();
    }
    // Attack and sleep for the duration of the attack + some extra time
    Thread.sleep(duration + (long) (Math.random() * 10));
}
Also used : PokemonMove(POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove) MoveSettings(POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings) Point(com.pokegoapi.api.map.Point)

Aggregations

MoveSettings (POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings)3 ItemTemplate (POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate)2 BadgeSettings (POGOProtos.Settings.Master.BadgeSettingsOuterClass.BadgeSettings)2 ItemSettings (POGOProtos.Settings.Master.ItemSettingsOuterClass.ItemSettings)2 PokemonSettings (POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings)2 PokemonMove (POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove)1 DownloadItemTemplatesResponse (POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse)1 PlayerLevelSettings (POGOProtos.Settings.Master.PlayerLevelSettingsOuterClass.PlayerLevelSettings)1 Point (com.pokegoapi.api.map.Point)1 Evolutions (com.pokegoapi.api.pokemon.Evolutions)1 FileOutputStream (java.io.FileOutputStream)1