Skip to content

Commit

Permalink
added temp lists for duplication mitigation
Browse files Browse the repository at this point in the history
  • Loading branch information
reddivision committed Jul 30, 2016
1 parent 892d73b commit 7b6cdbc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pokemongo_bot/cell_workers/incubate_eggs_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def _check_inventory(self, lookup_ids=[]):
inv = {}
response_dict = self.bot.get_inventory()
matched_pokemon = []
temp_eggs = []
inv = reduce(
dict.__getitem__,
["responses", "GET_INVENTORY", "inventory_delta", "inventory_items"],
Expand All @@ -76,24 +77,26 @@ def _check_inventory(self, lookup_ids=[]):
for inv_data in inv:
inv_data = inv_data.get("inventory_item_data", {})
if "egg_incubators" in inv_data:
temp_used_incubators = []
temp_ready_incubators = []
incubators = inv_data.get("egg_incubators", {}).get("egg_incubator",[])
if isinstance(incubators, basestring): # checking for old response
incubators = [incubators]
for incubator in incubators:
if 'pokemon_id' in incubator:
self.used_incubators.append({
temp_used_incubators.append({
"id": incubator.get('id', -1),
"km": incubator.get('target_km_walked', 9001)
})
else:
self.ready_incubators.append({
temp_ready_incubators.append({
"id": incubator.get('id', -1)
})
continue
if "pokemon_data" in inv_data:
pokemon = inv_data.get("pokemon_data", {})
if pokemon.get("is_egg", False) and "egg_incubator_id" not in pokemon:
self.eggs.append({
temp_eggs.append({
"id": pokemon.get("id", -1),
"km": pokemon.get("egg_km_walked_target", -1),
"used": False
Expand All @@ -111,6 +114,12 @@ def _check_inventory(self, lookup_ids=[]):
continue
if "player_stats" in inv_data:
self.km_walked = inv_data.get("player_stats", {}).get("km_walked", 0)
if temp_used_incubators:
self.used_incubators = temp_used_incubators
if temp_ready_incubators:
self.ready_incubators = temp_ready_incubators
if temp_eggs:
self.eggs = temp_eggs
return matched_pokemon

def _hatch_eggs(self):
Expand Down

0 comments on commit 7b6cdbc

Please sign in to comment.