Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for inventory and pokemon optimizer #4258

Merged
merged 2 commits into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [p for p in super(Pokemons, self).all()]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be only
return super(Pokemons, self).all()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, you're right. should hit myself in the head for that one xD


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