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

Adding the navigator to the list of workers #1950

Merged
merged 1 commit into from
Jul 31, 2016
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ def __init__(self, config):
def start(self):
self._setup_logging()
self._setup_api()
self._setup_workers()

if self.config.navigator_type == 'spiral':
self.navigator=cell_workers.FollowSpiral(self)
self.navigator = cell_workers.FollowSpiral
elif self.config.navigator_type == 'path':
self.navigator=cell_workers.FollowPath(self)
self.navigator = cell_workers.FollowPath

self._setup_workers()

random.seed()

Expand Down Expand Up @@ -90,8 +91,6 @@ def tick(self):
if worker.work() == WorkerResult.RUNNING:
return

self.navigator.take_step()

def get_meta_cell(self):
location = self.position[0:2]
cells = self.find_close_cells(*location)
Expand Down Expand Up @@ -308,7 +307,8 @@ def _setup_workers(self):
cell_workers.SpinFort(self),
cell_workers.MoveToFort(self),
cell_workers.CatchLuredPokemon(self),
cell_workers.SpinFort(self)
cell_workers.SpinFort(self),
self.navigator(self)
]

def _print_character_info(self):
Expand Down
2 changes: 1 addition & 1 deletion pokemongo_bot/cell_workers/follow_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def load_gpx(self, file):

return points;

def take_step(self):
def work(self):
point = self.points[self.ptr]
lat = float(point['lat'])
lng = float(point['lng'])
Expand Down
2 changes: 1 addition & 1 deletion pokemongo_bot/cell_workers/follow_spiral.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _generate_spiral(starting_lat, starting_lng, step_size, step_limit):
m += 1
return coords

def take_step(self):
def work(self):
point = self.points[self.ptr]
self.cnt += 1

Expand Down