Skip to content

Commit

Permalink
Hotfix for inventory and pokemon optimizer (#4258)
Browse files Browse the repository at this point in the history
* Hotfix for inventory and pokemon optimizer

* Better code
  • Loading branch information
Calcyfer authored and solderzzc committed Aug 19, 2016
1 parent 4a316e5 commit ca92336
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions pokemongo_bot/cell_workers/pokemon_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion pokemongo_bot/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 super(Pokemons, self).all()

def add(self, pokemon):
if pokemon.unique_id <= 0:
raise ValueError("Can't add a pokemon without id")
Expand Down

0 comments on commit ca92336

Please sign in to comment.