SwipeX / PokeMate

Automated PokemonGo Application
GNU General Public License v3.0
111 stars 45 forks source link

Iterate over all pokemons #256

Closed ghost closed 8 years ago

ghost commented 8 years ago

Allows to recover all the Pokemon in one place. Currently, only the first Pokemon is recovered

gsisso commented 8 years ago
                    pokemons().stream()
                        .filter(pkmn -> pkmn.getPokemonId().name().equals(targetId))
                        .sorted((a, b) -> Long.compare(b.getCreationTimeMs(), a.getCreationTimeMs()))
                        .findFirst()
                        .ifPresent(p -> {
                            String output = null;
                            try {
                                output = String.format("Caught a %s [CP: %d] [Candy: %d]", StringConverter.titleCase(targetId), p.getCp(), p.getCandy());
                            } catch (LoginFailedException e) {
                                e.printStackTrace();
                            } catch (RemoteServerException e) {
                                e.printStackTrace();
                            }

                            if (p.getCp() > Config.getMinimumCPForMessage()) {
                                PokeMateUI.toast(output, Config.POKE + "mon caught!", "icons/" + target.getPokemonId().getNumber() + ".png");
                            } else {
                                log(output + " [IV: " + getIvRatio(p) + "%]");
                            }
                        });

this could be done outside the loop ,keep a list of pokemons that was captured and then instead of equals use contains.

SippieCup commented 8 years ago

Can you please fix the conflicts so that it can be merged?

If not, I can update it, but its a real pita to resolve merge reqs.