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/alt circle avoidance #1553

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 3 additions & 3 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"gmapkey": "GOOGLE_MAPS_API_KEY",
"max_steps": 5,
"catch_pokemon": true,
"spin_forts": true,
"walk": 4.16,
"action_wait_min": 1,
"action_wait_max": 4,
Expand All @@ -32,8 +31,9 @@
"longer_eggs_first": true,
"evolve_captured": false,
"release_pokemon": true,
"spin_forts": {
"avoid_circles": false,
"forts": {
"spin_forts": true,
"avoid_circles": true,
"max_circle_size": 10
},
"catch": {
Expand Down
6 changes: 3 additions & 3 deletions configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"gmapkey": "GOOGLE_MAPS_API_KEY",
"max_steps": 5,
"catch_pokemon": true,
"spin_forts": true,
"walk": 4.16,
"action_wait_min": 1,
"action_wait_max": 4,
Expand All @@ -32,8 +31,9 @@
"longer_eggs_first": true,
"evolve_captured": false,
"release_pokemon": true,
"spin_forts": {
"avoid_circles": false,
"forts": {
"spin_forts": true,
"avoid_circles": true,
"max_circle_size": 10
},
"catch": {
Expand Down
16 changes: 14 additions & 2 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,25 @@ def add_config(parser, json_config, short_flag=None, long_flag=None, **kwargs):
raise Exception('add_config calls requires long_flag parameter!')
if 'default' in kwargs:
attribute_name = long_flag.split('--')[1]
kwargs['default'] = json_config.get(attribute_name, kwargs['default'])
val = _search_nested_dict(json_config, attribute_name)
if val is not None:
kwargs['default'] = val
if short_flag:
args = (short_flag, long_flag)
else:
args = (long_flag,)
parser.add_argument(*args, **kwargs)



def _search_nested_dict(dict_, key):
if key in dict_:
return dict_[key]
for k, v in dict_.items():
if isinstance(v, dict):
val = _search_nested_dict(v, key)
if val is not None:
return val

def parse_unicode_str(string):
try:
return string.decode('utf8')
Expand Down