SwipeX / PokeMate

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

Catch only the first catchable pokemon instead all of them #228

Closed gsisso closed 8 years ago

gsisso commented 8 years ago

at

                List<CatchablePokemon> pokemon = context.getApi().getMap().getCatchablePokemon().stream()
                    .filter(this::shouldIgnore)
                    .collect(Collectors.toList());

we get a list of all the catch-able pokemons in our area but for some reason the code only fetch the first pokemon instead all of them.

CatchablePokemon target = pokemon.get(0);

what I did for now is -

                for (CatchablePokemon target : pokemon) {
                    if (target == null) {
                        continue;
                    }

                    if (ball != null && ball.getCount() > 0) {
                        pokeball = getBallForId(Config.getPreferredBall());
                    } else {
                        //find any pokeball we can.
                        for (Pokeball pb : Pokeball.values()) {
                            ball = itemBag().getItem(pb.getBallType());
                            if (ball != null && ball.getCount() > 0) {
                                pokeball = pb;
                                break;
                            }
                        }
                    }

                    if (pokeball == null) {
                        log("Tried to catch a pokemon but you don't have any pokeballs");
                        break;
                    }
                    EncounterResult encounterResult = target.encounterPokemon();
                    if (!encounterResult.wasSuccessful()) {
                        continue;
                    }

                    CatchResult catchResult = target.catchPokemon(pokeball);
                    if (catchResult.getStatus() == CATCH_SUCCESS) {
                        log(target.getPokemonId() + " Caught.");
                        continue;
                    } else {
                        log("Pokemon : " + target.getPokemonId() + " STATUS " + catchResult.getStatus().toString());
                        continue;
                    }

                }

Dont have much time to improve it this days so maybe someone else could take over it

SippieCup commented 8 years ago

I believe the current work was intentional as to better emulate human behavior.

That being said it's pretty obvious that we are botting so it might be good to merge.

Thanks!

gsisso commented 8 years ago

I dont know if it makes it more human but it surely makes it better,there's no reason to keep walking around searching for pokemons when there are some right next to you. making it more human basically means need to add more sleep in most of the tasks like the evolving part. theres no way you can evolve pokemon and less then a second later catch another one, just the animation part is about 3-4 seconds.

SippieCup commented 8 years ago

This has been implemented.