Skip to content

Commit

Permalink
Better edge case output on catcher worker (#4567)
Browse files Browse the repository at this point in the history
* Ultraball try emit_event

* Output change

* Change emit_events

* register_event(enough_ultraballs)

* Altered no_pokeballs output
  • Loading branch information
mjmadsen authored Aug 22, 2016
1 parent c2911bc commit c9e317f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def _register_events(self):
)
)
self.event_manager.register_event('no_pokeballs')
self.event_manager.register_event('enough_ultraballs')
self.event_manager.register_event(
'pokemon_catch_rate',
parameters=(
Expand Down
4 changes: 2 additions & 2 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
while ball_count[current_ball] == 0 and current_ball < maximum_ball:
current_ball += 1
if ball_count[current_ball] == 0:
self.emit_event('no_pokeballs', formatted='No usable pokeballs found!')

# use untraball if there is no other balls with constraint to `min_ultraball_to_keep`
if maximum_ball != ITEM_ULTRABALL and ball_count[ITEM_ULTRABALL] > min_ultraball_to_keep:
maximum_ball = ITEM_ULTRABALL
self.emit_event('enough_ultraballs', formatted='No regular balls left! Trying ultraball.')
continue
else:
self.emit_event('no_pokeballs', formatted='No pokeballs left! Fleeing...')
return WorkerResult.ERROR

# check future ball count
Expand Down

0 comments on commit c9e317f

Please sign in to comment.