PokeGOAPI-Java icon indicating copy to clipboard operation
PokeGOAPI-Java copied to clipboard

[Feature Request] Add a method to get how many times a pokemonId has been caught

Open spbisya opened this issue 10 years ago • 8 comments

How should I get how many times certain Pokemon was caught?

spbisya avatar Jul 29 '16 10:07 spbisya

You mean something like this?

        List<Pokemon> pokebank = //Get pokemons from your PokemonGo instance
        Map<Integer, List<Pokemon>> pokemons = new HashMap<>();

        pokebank.forEach((pokemon) -> {
            int id = pokemon.getPokemonId().ordinal();

            if (pokemons.containsKey(id)) {
                pokemons.get(id).add(pokemon);
            } else {
                List<Pokemon> list = new ArrayList<>();
                list.add(pokemon);
                pokemons.put(id, list);
            }
        });

        List<Pokemon> pidgeys = pokemons.get(PokemonIdOuterClass.PokemonId.PIDGEY_VALUE);
        System.out.println("You have" + pidgeys.size() + " pidgeys");

navopw avatar Jul 29 '16 11:07 navopw

@NAAVOO amount of certain pokemon you have in the inventory does not necessarily has to tell how many times you have caught that pokemon, namely due to transferring them.

I see that the API exposes following method: api.getPlayerProfile().getStats().getPokemonCaughtByType(); however the result would need to be further processed.

thejavatar avatar Jul 29 '16 12:07 thejavatar

@NAAVOO no, but something like this playerProfile.getStats().getSmallRattataCaught(). And I'd like to have a method getPokemonByType(int type) which returns pokemon of certain type count.

spbisya avatar Jul 29 '16 12:07 spbisya

getPokebank().getPokemonByType(PokemonId).size()

Grover-c13 avatar Jul 29 '16 12:07 Grover-c13

And for the other stats, the only stats you can get are defined here, so cant really know how many ratata you have caught.

Closed since its resolved. (dont hesitate to re-ask question within this issue)

vmarchaud avatar Jul 29 '16 14:07 vmarchaud

My bad, actually there is a field to get those, but its seems the protos are not tested to get them, someone should change the type of the field to know if its actually possible to get them.

If someone is willing to help : we are talking about this field.

vmarchaud avatar Jul 29 '16 14:07 vmarchaud

@thejavatar sorry i completely misread your question too, i think this info is available in the pokedex, getInventories().getPokedex().getPokedexEntry(id).getTimesCaptured(),

i dont think this is tested though.

Grover-c13 avatar Aug 01 '16 14:08 Grover-c13

@Grover-c13 ah nice, I didn't notice that one before. Thanks!

thejavatar avatar Aug 03 '16 07:08 thejavatar