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

Fix pokemon bag list #4384

Merged
merged 4 commits into from
Aug 20, 2016
Merged
Changes from all commits
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
31 changes: 12 additions & 19 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,10 @@ def _print_character_info(self):

def _print_list_pokemon(self):
# get pokemon list
pokemon_list = inventory.pokemons().all()
pokemon_list = sorted(pokemon_list, key=lambda k: k.pokemon_id)
bag = inventory.pokemons().all()
id_list =list(set(map(lambda x: x.pokemon_id, bag)))
id_list.sort()
pokemon_list = [filter(lambda x: x.pokemon_id == y, bag) for y in id_list]

show_count = self.config.pokemon_bag_show_count
poke_info_displayed = self.config.pokemon_bag_pokemon_info
Expand All @@ -899,23 +901,14 @@ def get_poke_info(info, pokemon):

self.logger.info('Pokemon:')

last_id = -1
line_start = str()
line_p = []
count = 0
for poke in pokemon_list:
if last_id != -1 and last_id != poke.pokemon_id:
if show_count:
line_start += '[{}]'.format(count)
self.logger.info(line_start + ': ' + ' | '.join(line_p))
line_p = []
last_id = -1
count = 0
if last_id == -1:
last_id = poke.pokemon_id
line_start = '#{} {}'.format(last_id, poke.name)
line_p.append('({})'.format(', '.join([get_poke_info(x, poke) for x in poke_info_displayed])))
count += 1
for pokes in pokemon_list:
line_p = '#{} {}'.format(pokes[0].pokemon_id, pokes[0].name)
if show_count:
line_p += '[{}]'.format(len(pokes))
line_p += ': '

poke_info = ['({})'.format(', '.join([get_poke_info(x, p) for x in poke_info_displayed])) for p in pokes]
self.logger.info(line_p + ' | '.join(poke_info))

self.logger.info('')

Expand Down