From 36576ad66529eda0458dbca56bd514d64fed0921 Mon Sep 17 00:00:00 2001 From: Glenn Date: Fri, 19 Aug 2016 12:39:57 +0200 Subject: [PATCH 1/2] Hotfix for inventory and pokemon optimizer --- pokemongo_bot/cell_workers/pokemon_optimizer.py | 5 +---- pokemongo_bot/inventory.py | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_optimizer.py b/pokemongo_bot/cell_workers/pokemon_optimizer.py index fdb0ab0f95..4c52ed8b62 100644 --- a/pokemongo_bot/cell_workers/pokemon_optimizer.py +++ b/pokemongo_bot/cell_workers/pokemon_optimizer.py @@ -290,10 +290,7 @@ def transfer_pokemon(self, pokemon): return True def get_candy_gained_count(self, response_dict): - total_candy_gained = 0 - for candy_gained in response_dict['responses']['CATCH_POKEMON']['capture_award']['candy']: - total_candy_gained += candy_gained - return total_candy_gained + return response_dict['responses']['RELEASE_POKEMON']['candy_awarded'] def use_lucky_egg(self): lucky_egg = inventory.items().get(Item.ITEM_LUCKY_EGG.value) # @UndefinedVariable diff --git a/pokemongo_bot/inventory.py b/pokemongo_bot/inventory.py index 525c761317..52bafe7cdc 100644 --- a/pokemongo_bot/inventory.py +++ b/pokemongo_bot/inventory.py @@ -266,7 +266,7 @@ def get_space_used(cls): :return: The space used in pokemon inventory. :rtype: int """ - return len(_inventory.pokemons.all()) + return len(_inventory.pokemons.all_with_eggs()) @classmethod def get_space_left(cls): @@ -322,6 +322,10 @@ def all(self): # makes caller's lives more difficult) return [p for p in super(Pokemons, self).all() if not isinstance(p, Egg)] + def all_with_eggs(self): + # count pokemon AND eggs, since eggs are counted as bag space + return [p for p in super(Pokemons, self).all()] + def add(self, pokemon): if pokemon.unique_id <= 0: raise ValueError("Can't add a pokemon without id") From 8713ee39df7ac007f045d86611f27dbe6432f0be Mon Sep 17 00:00:00 2001 From: Glenn Date: Fri, 19 Aug 2016 13:12:58 +0200 Subject: [PATCH 2/2] Better code --- pokemongo_bot/inventory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemongo_bot/inventory.py b/pokemongo_bot/inventory.py index 52bafe7cdc..26e4e239e7 100644 --- a/pokemongo_bot/inventory.py +++ b/pokemongo_bot/inventory.py @@ -324,7 +324,7 @@ def all(self): def all_with_eggs(self): # count pokemon AND eggs, since eggs are counted as bag space - return [p for p in super(Pokemons, self).all()] + return super(Pokemons, self).all() def add(self, pokemon): if pokemon.unique_id <= 0: