From 7b6cdbc48848a80973d9d1eef3d650357e2a0ae2 Mon Sep 17 00:00:00 2001 From: reddivision Date: Sat, 30 Jul 2016 01:08:38 -0700 Subject: [PATCH] added temp lists for duplication mitigation --- .../cell_workers/incubate_eggs_worker.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pokemongo_bot/cell_workers/incubate_eggs_worker.py b/pokemongo_bot/cell_workers/incubate_eggs_worker.py index d9890a6aa2..4de0fd6251 100644 --- a/pokemongo_bot/cell_workers/incubate_eggs_worker.py +++ b/pokemongo_bot/cell_workers/incubate_eggs_worker.py @@ -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"], @@ -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 @@ -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):