Search in sources :

Example 1 with ItemTemplate

use of POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate 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 ItemTemplate

use of POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate in project PokeGOAPI-Java by Grover-c13.

the class FileTemplateProvider method updateTemplates.

@Override
public void updateTemplates(DownloadItemTemplatesResponse response, long time) throws IOException {
    timestamp = time;
    for (ItemTemplate template : response.getItemTemplatesList()) {
        templates.put(template.getTemplateId(), template);
    }
    save();
}
Also used : ItemTemplate(POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate)

Example 3 with ItemTemplate

use of POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate in project PokeGOAPI-Java by Grover-c13.

the class FileTemplateProvider method save.

private void save() throws IOException {
    try (DataOutputStream out = new DataOutputStream(new FileOutputStream(getTimestampFile()))) {
        out.writeLong(timestamp);
    }
    try (DataOutputStream out = new DataOutputStream(new FileOutputStream(getTemplatesFile()))) {
        for (ItemTemplate template : templates.values()) {
            byte[] templateBytes = template.toByteArray();
            out.writeShort(templateBytes.length);
            out.write(templateBytes);
        }
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) ItemTemplate(POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate) FileOutputStream(java.io.FileOutputStream)

Example 4 with ItemTemplate

use of POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate 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 5 with ItemTemplate

use of POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate in project PokeGOAPI-Java by Grover-c13.

the class PokemonCpUtils method initialize.

/**
	 * Initializes this with the given item templates
	 *
	 * @param templates the item templates
	 */
public static void initialize(List<ItemTemplate> templates) {
    for (ItemTemplate template : templates) {
        if (template.hasPlayerLevel()) {
            PlayerLevelSettingsOuterClass.PlayerLevelSettings settings = template.getPlayerLevel();
            List<Float> multipliers = settings.getCpMultiplierList();
            for (int i = 0; i < multipliers.size(); i++) {
                double multiplier = multipliers.get(i);
                LEVEL_CP_MULTIPLIER.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;
                }
                LEVEL_CP_MULTIPLIER.put(i + 1.5F, Math.sqrt((multiplier * multiplier) + step));
            }
        }
    }
}
Also used : PlayerLevelSettingsOuterClass(POGOProtos.Settings.Master.PlayerLevelSettingsOuterClass) ItemTemplate(POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate)

Aggregations

ItemTemplate (POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse.ItemTemplate)7 PokemonSettings (POGOProtos.Settings.Master.PokemonSettingsOuterClass.PokemonSettings)3 BadgeSettings (POGOProtos.Settings.Master.BadgeSettingsOuterClass.BadgeSettings)2 ItemSettings (POGOProtos.Settings.Master.ItemSettingsOuterClass.ItemSettings)2 MoveSettings (POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings)2 FileOutputStream (java.io.FileOutputStream)2 PokemonId (POGOProtos.Enums.PokemonIdOuterClass.PokemonId)1 DownloadItemTemplatesResponse (POGOProtos.Networking.Responses.DownloadItemTemplatesResponseOuterClass.DownloadItemTemplatesResponse)1 PlayerLevelSettingsOuterClass (POGOProtos.Settings.Master.PlayerLevelSettingsOuterClass)1 PlayerLevelSettings (POGOProtos.Settings.Master.PlayerLevelSettingsOuterClass.PlayerLevelSettings)1 Evolutions (com.pokegoapi.api.pokemon.Evolutions)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1