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

Move Workers #1600

Merged
merged 1 commit into from
Jul 29, 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
24 changes: 13 additions & 11 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pgoapi.utilities import f2i

import logger
from cell_workers import SpinNearestFortWorker, CatchVisiblePokemonWorker, PokemonCatchWorker, SeenFortWorker, MoveToFortWorker, PokemonTransferWorker, EvolveAllWorker, RecycleItemsWorker, IncubateEggsWorker
import cell_workers
from cell_workers.utils import distance, get_cellid, encode, i2f
from human_behaviour import sleep
from item_list import Item
Expand All @@ -30,6 +30,15 @@

class PokemonGoBot(object):

WORKERS = [
cell_workers.IncubateEggsWorker,
cell_workers.PokemonTransferWorker,
cell_workers.EvolveAllWorker,
cell_workers.RecycleItemsWorker,
cell_workers.CatchVisiblePokemonWorker,
cell_workers.SpinNearestFortWorker
]

@property
def position(self):
return self.api._position_lat, self.api._position_lng, 0
Expand All @@ -45,6 +54,8 @@ def __init__(self, config):
self.recent_forts = [None] * config.max_circle_size
self.tick_count = 0

# Make our own copy of the workers for this instance
self.workers = list(self.WORKERS)

def start(self):
self._setup_logging()
Expand Down Expand Up @@ -76,16 +87,7 @@ def tick(self):
# Check if session token has expired
self.check_session(self.position[0:2])

workers = [
IncubateEggsWorker,
PokemonTransferWorker,
EvolveAllWorker,
RecycleItemsWorker,
CatchVisiblePokemonWorker,
SpinNearestFortWorker
]

for worker in workers:
for worker in self.workers:
if worker(self).work() == WorkerResult.RUNNING:
return

Expand Down