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

CatchVisiblePokemonWorker now catches pokemon from lures #1591

Merged
merged 2 commits 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
28 changes: 27 additions & 1 deletion pokemongo_bot/cell_workers/catch_visible_pokemon_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,34 @@ def work(self):
lambda x: distance(self.position[0], self.position[1], x['latitude'], x['longitude']))
return self.catch_pokemon(self.cell['wild_pokemons'][0])

lured_pokemon = self.get_lured_pokemon()
if lured_pokemon:
self.catch_pokemon(lured_pokemon)

def get_lured_pokemon(self):
forts = self.bot.get_forts(order_by_distance=True)
fort = forts[0]

self.api.fort_details(fort_id=fort['id'],
latitude=fort['latitude'],
longitude=fort['longitude'])
response_dict = self.api.call()
fort_details = response_dict.get('responses', {}).get('FORT_DETAILS', {})
fort_name = fort_details.get('name', 'Unknown').encode('utf8', 'replace')

encounter_id = fort.get('lure_info', {}).get('encounter_id', None)

pokemon = {
'encounter_id': encounter_id,
'fort_id': fort['id'],
'latitude': fort['latitude'],
'longitude': fort['longitude']
}

return pokemon

def catch_pokemon(self, pokemon):
worker = PokemonCatchWorker(pokemon, self.bot)
return_value = worker.work()

return return_value
return return_value