Skip to content

Commit

Permalink
[BUGFIX] Catch Pokemon while walking to fort
Browse files Browse the repository at this point in the history
Resolves: PokemonGoF#821
  • Loading branch information
binarydepartment committed Jul 26, 2016
1 parent 4555466 commit 79165fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ def start(self):

def take_step(self):
location = self.navigator.take_step()
cells = self.find_close_cells(*location[0:2])
self.work_cells(1, self.position[0:2])

for cell in cells:
self.work_on_cell(cell, location)
def work_cells(self, work_on_forts=1, location=None):
if (location is None):
location = self.position[0:2]

cells = self.find_close_cells(*location)
for cell in cells:
self.work_on_cell(cell, location, work_on_forts)

def update_web_location(self, cells=[], lat=None, lng=None, alt=None):
# we can call the function with no arguments and still get the position and map_cells
Expand Down Expand Up @@ -119,7 +124,7 @@ def find_close_cells(self, lat, lng):
self.update_web_location(map_cells,lat,lng)
return map_cells

def work_on_cell(self, cell, position):
def work_on_cell(self, cell, position, work_on_forts=1):
# Check if session token has expired
self.check_session(position)

Expand Down Expand Up @@ -189,8 +194,8 @@ def work_on_cell(self, cell, position):
for pokemon in cell['wild_pokemons']:
if self.catch_pokemon(pokemon) == PokemonCatchWorker.NO_POKEBALLS:
break
if (self.config.mode == "all" or
self.config.mode == "farm"):
if ((self.config.mode == "all" or
self.config.mode == "farm") and work_on_forts):
if 'forts' in cell:
# Only include those with a lat/long
forts = [fort
Expand Down
2 changes: 2 additions & 0 deletions pokemongo_bot/cell_workers/move_to_fort_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def work(self):
while True:
if step_walker.step():
break
else:
self.bot.work_cells(0)

else:
self.api.set_position(*position)
Expand Down

0 comments on commit 79165fa

Please sign in to comment.