Skip to content

Commit

Permalink
Allow to use berry again only if capture failed (#4501)
Browse files Browse the repository at this point in the history
* Allow to use berry again only if capture failed

* Fixes bug on berry
  • Loading branch information
congito authored and solderzzc committed Aug 21, 2016
1 parent 664d741 commit abed749
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit abed749

Please sign in to comment.