Skip to content

Commit

Permalink
Merge pull request #5 from PokemonGoF/dev
Browse files Browse the repository at this point in the history
Merge Main into my project
  • Loading branch information
Reaver01 authored Jul 22, 2016
2 parents 642f31c + b7ef874 commit 04fe2a1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def work(self):
# TODO: Begin searching for pokestops.
break
print('[x] Using {}...'.format(self.item_list[str(pokeball)]))
id_list1 = self.count_pokemon_inventory()
self.api.catch_pokemon(encounter_id = encounter_id,
pokeball = pokeball,
normalized_reticle_size = 1.950,
Expand All @@ -83,7 +84,10 @@ def work(self):
print_green('[x] Captured {}! [CP {}] - exchanging for candy'.format(pokemon_name, cp))
id_list2 = self.count_pokemon_inventory()
# Transfering Pokemon
self.transfer_pokemon(list(Set(id_list2) - Set(id_list1)))
pokemon_to_transfer = list(Set(id_list2) - Set(id_list1))
if len(pokemon_to_transfer) == 0:
raise RuntimeError('Trying to transfer 0 pokemons!')
self.transfer_pokemon(pokemon_to_transfer)
print_green('[#] {} has been exchanged for candy!'.format(pokemon_name))
else:
print_green('[x] Captured {}! [CP {}]'.format(pokemon_name, cp))
Expand Down Expand Up @@ -134,11 +138,13 @@ def counting_pokemon(self, response_dict, id_list):
else:
for item in response_dict['responses']['GET_INVENTORY']['inventory_delta']['inventory_items']:
try:
reduce(dict.__getitem__, ["inventory_item_data", "pokemon"], item)
reduce(dict.__getitem__, ["inventory_item_data", "pokemon_data"], item)
except KeyError:
pass
else:
pokemon = item['inventory_item_data']['pokemon']
pokemon = item['inventory_item_data']['pokemon_data']
if pokemon.get('is_egg', False):
continue
id_list.append(pokemon['id'])

return id_list

0 comments on commit 04fe2a1

Please sign in to comment.