Skip to content

Commit

Permalink
"evolve_captured" is now using a list instead of a boolean (#1532)
Browse files Browse the repository at this point in the history
* "evolve_captured" is now using a list instead of a boolean, working the same way as "evolve_all"

* parse error with format details when "evolve_captured" is not a string, or is the string "true" or "false"
  • Loading branch information
valerian authored and douglascamata committed Jul 29, 2016
1 parent dfa4f78 commit 9bc0abe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"use_lucky_egg": false,
"hatch_eggs": true,
"longer_eggs_first": true,
"evolve_captured": false,
"evolve_captured": "NONE",
"release_pokemon": true,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
Expand Down
2 changes: 1 addition & 1 deletion configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"use_lucky_egg": false,
"hatch_eggs": true,
"longer_eggs_first": true,
"evolve_captured": false,
"evolve_captured": "NONE",
"release_pokemon": true,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or" },
Expand Down
15 changes: 12 additions & 3 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ def init_config():
load,
short_flag="-ec",
long_flag="--evolve_captured",
help="(Ad-hoc mode) Bot will attempt to evolve all the pokemon captured!",
type=bool,
default=False
help="(Ad-hoc mode) Pass \"all\" or a list of pokemon to evolve (e.g., \"Pidgey,Weedle,Caterpie\"). Bot will attempt to evolve all the pokemon captured!",
type=str,
default=[]
)
add_config(
parser,
Expand Down Expand Up @@ -350,6 +350,13 @@ def init_config():
' Set these to true or false and remove "mode" from your configuration')
return None

if (config.evolve_captured
and (not isinstance(config.evolve_captured, str)
or str(config.evolve_captured).lower() in ["true", "false"])):
parser.error('"evolve_captured" should be list of pokemons: use "all" or "none" to match all ' +
'or none of the pokemons, or use a comma separated list such as "Pidgey,Weedle,Caterpie"')
return None

if not (config.location or config.location_cache):
parser.error("Needs either --use-location-cache or --location.")
return None
Expand All @@ -363,6 +370,8 @@ def init_config():

if config.evolve_all and isinstance(config.evolve_all, str):
config.evolve_all = [str(pokemon_name) for pokemon_name in config.evolve_all.split(',')]
if config.evolve_captured and isinstance(config.evolve_captured, str):
config.evolve_captured = [str(pokemon_name) for pokemon_name in config.evolve_captured.split(',')]

fix_nested_config(config)
return config
Expand Down
4 changes: 3 additions & 1 deletion pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ def work(self):
iv_display
), 'blue')

if self.config.evolve_captured:
if (self.config.evolve_captured
and (self.config.evolve_captured[0] == 'all'
or pokemon_name in self.config.evolve_captured)):
id_list2 = self.count_pokemon_inventory()
# No need to capture this even for metrics, player stats includes it.
pokemon_to_transfer = list(Set(id_list2) - Set(id_list1))
Expand Down

0 comments on commit 9bc0abe

Please sign in to comment.