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

CampFort - Check pokeballs before camping #5177

Merged
merged 4 commits into from
Sep 6, 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
14 changes: 14 additions & 0 deletions pokemongo_bot/cell_workers/camp_fort.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from pokemongo_bot.human_behaviour import random_lat_long_delta, random_alt_delta
from pokemongo_bot.walkers.polyline_walker import PolylineWalker
from pokemongo_bot.worker_result import WorkerResult
from pokemongo_bot.item_list import Item
from pokemongo_bot import inventory


class CampFort(BaseTask):
Expand All @@ -32,11 +34,23 @@ def work(self):
if not self.enabled:
return WorkerResult.SUCCESS

self.announced_out_of_balls = False
now = time.time()

if now < self.move_until:
return WorkerResult.SUCCESS

# Let's make sure we have balls before we sit at a lure!
# See also catch_pokemon.py
if sum([inventory.items().get(ball.value).count for ball in
[Item.ITEM_POKE_BALL, Item.ITEM_GREAT_BALL, Item.ITEM_ULTRA_BALL]]) <= 0:
self.logger.info('No pokeballs left, refuse to sit at lure!')
# Move away from lures for a time
self.destination = None
self.stay_until = 0
self.move_until = now + self.config_moving_time
return WorkerResult.SUCCESS

if 0 < self.stay_until < now:
self.destination = None
self.stay_until = 0
Expand Down