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

List Pokemon bag at bot start #4189

Merged
merged 6 commits into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions configs/config.json.cluster.example
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@
"max_circle_size": 50,
"cache_recent_forts": true
},
"pokemon_bag": {
"// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
"show_at_start": true,
"// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
"show_count": false,
"// 'pokemon_info' parameter define which info to show for each pokemon": {},
"// the available options are": {},
"// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
"pokemon_info": ["cp", "iv_pct"]
},
"walk_max": 4.16,
"walk_min": 2.16,
"debug": false,
Expand Down
10 changes: 10 additions & 0 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@
"max_circle_size": 50,
"cache_recent_forts": true
},
"pokemon_bag": {
"// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
"show_at_start": true,
Copy link
Contributor

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,

Copy link
Contributor Author

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.

"// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
"show_count": false,
"// 'pokemon_info' parameter define which info to show for each pokemon": {},
"// the available options are": {},
"// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
"pokemon_info": ["cp", "iv_pct"]
},
"walk_max": 4.16,
"walk_min": 2.16,
"debug": false,
Expand Down
10 changes: 10 additions & 0 deletions configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,16 @@
"max_circle_size": 50,
"cache_recent_forts": true
},
"pokemon_bag": {
"// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
"show_at_start": true,
"// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
"show_count": false,
"// 'pokemon_info' parameter define which info to show for each pokemon": {},
"// the available options are": {},
"// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
"pokemon_info": ["cp", "iv_pct"]
},
"walk_max": 4.16,
"walk_min": 2.16,
"debug": false,
Expand Down
10 changes: 10 additions & 0 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@
"max_circle_size": 50,
"cache_recent_forts": true
},
"pokemon_bag": {
"// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
"show_at_start": true,
"// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
"show_count": false,
"// 'pokemon_info' parameter define which info to show for each pokemon": {},
"// the available options are": {},
"// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
"pokemon_info": ["cp", "iv_pct"]
},
"walk_max": 4.16,
"walk_min": 2.16,
"debug": false,
Expand Down
10 changes: 10 additions & 0 deletions configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@
"avoid_circles": true,
"max_circle_size": 50
},
"pokemon_bag": {
"// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
"show_at_start": true,
"// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
"show_count": false,
"// 'pokemon_info' parameter define which info to show for each pokemon": {},
"// the available options are": {},
"// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
"pokemon_info": ["cp", "iv_pct"]
},
"walk_max": 4.16,
"walk_min": 2.16,
"debug": false,
Expand Down
10 changes: 10 additions & 0 deletions configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@
"max_circle_size": 50,
"cache_recent_forts": true
},
"pokemon_bag": {
"// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
"show_at_start": true,
"// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
"show_count": false,
"// 'pokemon_info' parameter define which info to show for each pokemon": {},
"// the available options are": {},
"// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
"pokemon_info": ["cp", "iv_pct"]
},
"walk_max": 4.16,
"walk_min": 2.16,
"debug": false,
Expand Down
24 changes: 24 additions & 0 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,30 @@ def _json_loader(filename):
type=int,
default=10
)
add_config(
parser,
load,
long_flag="--pokemon_bag.show_at_start",
help="Logs all pokemon in the bag at bot start",
type=bool,
default=False
)
add_config(
parser,
load,
long_flag="--pokemon_bag.show_count",
help="Shows the amount of which pokemon (minimum 1)",
type=bool,
default=False
)
add_config(
parser,
load,
long_flag="--pokemon_bag.pokemon_info",
help="List with the info to show for each pokemon",
type=bool,
default=[]
)
# Start to parse other attrs
config = parser.parse_args()
if not config.username and 'username' not in load:
Expand Down
50 changes: 50 additions & 0 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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()
Expand Down Expand Up @@ -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)

Expand Down