Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use berry again only if capture failed #4501

Merged
merged 2 commits into from
Aug 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
if self.min_ultraball_to_keep >= 0 and self.min_ultraball_to_keep < min_ultraball_to_keep:
min_ultraball_to_keep = self.min_ultraball_to_keep

used_berry = False
while True:

# find lowest available ball
Expand Down Expand Up @@ -367,9 +368,8 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
berries_to_spare = berry_count > 0 if is_vip else berry_count > num_next_balls + 30

# use a berry if we are under our ideal rate and have berries to spare
used_berry = False
changed_ball = False
if catch_rate_by_ball[current_ball] < ideal_catch_rate_before_throw and berries_to_spare:
if catch_rate_by_ball[current_ball] < ideal_catch_rate_before_throw and berries_to_spare and not used_berry:
new_catch_rate_by_ball = self._use_berry(berry_id, berry_count, encounter_id, catch_rate_by_ball, current_ball)
if new_catch_rate_by_ball != catch_rate_by_ball:
catch_rate_by_ball = new_catch_rate_by_ball
Expand Down Expand Up @@ -451,6 +451,7 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
formatted='{pokemon} capture failed.. trying again!',
data={'pokemon': pokemon.name}
)
used_berry = False

# sleep according to flee_count and flee_duration config settings
# randomly chooses a number of times to 'show' wobble animation between 1 and flee_count
Expand Down