-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
List Pokemon bag at bot start #4189
Changes from all commits
e2e7145
41e0579
919a7fc
1ef50c5
79ca5b3
2799d12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -732,6 +732,8 @@ def _setup_api(self): | |
# chain subrequests (methods) into one RPC call | ||
|
||
self._print_character_info() | ||
if self.config.pokemon_bag_show_at_start and self.config.pokemon_bag_pokemon_info: | ||
self._print_list_pokemon() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not clear what will happen if "show_at_start" is not set in config. Perhaps it would be best to set it to default false unless True is passed in by the config. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value for "show_at_start" is defined as False at pokecli.py. |
||
self.api.activate_signature(self.get_encryption_lib()) | ||
self.logger.info('') | ||
self.update_inventory() | ||
|
@@ -823,6 +825,54 @@ def _print_character_info(self): | |
|
||
self.logger.info('') | ||
|
||
def _print_list_pokemon(self): | ||
init_inventory(self) | ||
|
||
# get pokemon list | ||
pokemon_list = inventory.pokemons().all() | ||
pokemon_list = sorted(pokemon_list, key=lambda k: k.pokemon_id) | ||
|
||
show_count = self.config.pokemon_bag_show_count | ||
poke_info_displayed = self.config.pokemon_bag_pokemon_info | ||
|
||
def get_poke_info(info, pokemon): | ||
poke_info = { | ||
'cp': 'CP {}'.format(pokemon.cp), | ||
'iv_ads': 'A/D/S {}/{}/{}'.format(pokemon.iv_attack, pokemon.iv_defense, pokemon.iv_stamina), | ||
'iv_pct': 'IV {}'.format(pokemon.iv), | ||
'ivcp': 'IVCP {}'.format(round(pokemon.ivcp,2)), | ||
'ncp': 'NCP {}'.format(round(pokemon.cp_percent,2)), | ||
'level': "Level {}".format(pokemon.level), | ||
'hp': 'HP {}/{}'.format(pokemon.hp, pokemon.hp_max), | ||
'moveset': 'Moves: {}'.format(pokemon.moveset), | ||
'dps': 'DPS {}'.format(round(pokemon.moveset.dps, 2)) | ||
} | ||
if info not in poke_info: | ||
raise ConfigException("info '{}' isn't available for displaying".format(info)) | ||
return poke_info[info] | ||
|
||
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 | ||
|
||
self.logger.info('') | ||
|
||
def use_lucky_egg(self): | ||
return self.api.use_item_xp_boost(item_id=301) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be useful, but will print a great deal of spam if unwanted. Please set default value in all configs as "show_at_start": False,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, my bad. I'll fix it asap.