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

Remove the "evolve_captured" flag in favor of the EvolveTask #3530

Merged
merged 4 commits into from
Aug 11, 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
1 change: 0 additions & 1 deletion configs/config.json.cluster.example
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"location_cache": true,
"distance_unit": "km",
"reconnecting_timeout": 15,
"evolve_captured": "NONE",
"catch_randomize_reticle_factor": 1.0,
"catch_randomize_spin_factor": 1.0,
"logging_color": true,
Expand Down
1 change: 0 additions & 1 deletion configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"location_cache": true,
"distance_unit": "km",
"reconnecting_timeout": 15,
"evolve_captured": "NONE",
"catch_randomize_reticle_factor": 1.0,
"catch_randomize_spin_factor": 1.0,
"logging_color": true,
Expand Down
1 change: 0 additions & 1 deletion configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@
"location_cache": true,
"distance_unit": "km",
"reconnecting_timeout": 15,
"evolve_captured": "NONE",
"catch_randomize_reticle_factor": 1.0,
"catch_randomize_spin_factor": 1.0,
"logging_color": true,
Expand Down
1 change: 0 additions & 1 deletion configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"location_cache": true,
"distance_unit": "km",
"reconnecting_timeout": 15,
"evolve_captured": "NONE",
"catch_randomize_reticle_factor": 1.0,
"catch_randomize_spin_factor": 1.0,
"logging_color": true,
Expand Down
1 change: 0 additions & 1 deletion configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"location_cache": true,
"distance_unit": "km",
"reconnecting_timeout": 15,
"evolve_captured": "NONE",
"catch_randomize_reticle_factor": 1.0,
"catch_randomize_spin_factor": 1.0,
"logging_color": true,
Expand Down
20 changes: 2 additions & 18 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,6 @@ def _json_loader(filename):
type=str,
default='km'
)
add_config(
parser,
load,
short_flag="-ec",
long_flag="--evolve_captured",
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,
load,
Expand Down Expand Up @@ -453,12 +444,8 @@ def task_configuration_error(flag_name):
task_configuration_error('{}.{}'.format(outer, inner))
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 "evolve_captured" in load:
logger.warning('The evolve_captured argument is no longer supported. Please use the EvolvePokemon task instead')

if not (config.location or config.location_cache):
parser.error("Needs either --use-location-cache or --location.")
Expand All @@ -483,9 +470,6 @@ def task_configuration_error(flag_name):
if not os.path.isdir(web_dir):
raise

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

fix_nested_config(config)
return config

Expand Down
4 changes: 0 additions & 4 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,6 @@ def _register_events(self):
'pokemon_evolved',
parameters=('pokemon', 'iv', 'cp')
)
self.event_manager.register_event(
'pokemon_evolve_fail',
parameters=('pokemon',)
)
self.event_manager.register_event('skip_evolve')
self.event_manager.register_event('threw_berry_failed', parameters=('status_code',))
self.event_manager.register_event('vip_pokemon')
Expand Down
54 changes: 0 additions & 54 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,30 +191,6 @@ def _is_vip_pokemon(self, pokemon):
return True
return self._pokemon_matches_config(self.config.vips, pokemon, default_logic='or')

def _get_current_pokemon_ids(self):
# don't use cached bot.get_inventory() here because we need to have actual information in capture logic
response_dict = self.api.get_inventory()

try:
inventory_items = response_dict['responses']['GET_INVENTORY']['inventory_delta']['inventory_items']
except KeyError:
return [] # no items

id_list = []
for item in inventory_items:
try:
pokemon = item['inventory_item_data']['pokemon_data']
except KeyError:
continue

# ignore eggs
if pokemon.get('is_egg'):
continue

id_list.append(pokemon['id'])

return id_list

def _pct(self, rate_by_ball):
return '{0:.2f}'.format(rate_by_ball * 100)

Expand Down Expand Up @@ -326,9 +302,6 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
catch_rate_by_ball = self._use_berry(berry_id, berry_count, encounter_id, catch_rate_by_ball, current_ball)
berry_count -= 1

# get current pokemon list before catch
pokemon_before_catch = self._get_current_pokemon_ids()

# try to catch pokemon!
items_stock[current_ball] -= 1
self.emit_event(
Expand Down Expand Up @@ -418,31 +391,4 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):

self.bot.softban = False

# evolve pokemon if necessary
if self.config.evolve_captured and (self.config.evolve_captured[0] == 'all' or pokemon.name in self.config.evolve_captured):
pokemon_after_catch = self._get_current_pokemon_ids()
pokemon_to_evolve = list(set(pokemon_after_catch) - set(pokemon_before_catch))

if len(pokemon_to_evolve) == 0:
break

self._do_evolve(pokemon, pokemon_to_evolve[0])

break

def _do_evolve(self, pokemon, new_pokemon_id):
response_dict = self.api.evolve_pokemon(pokemon_id=new_pokemon_id)
catch_pokemon_status = response_dict['responses']['EVOLVE_POKEMON']['result']

if catch_pokemon_status == 1:
self.emit_event(
'pokemon_evolved',
formatted='{pokemon} evolved!',
data={'pokemon': pokemon.name}
)
else:
self.emit_event(
'pokemon_evolve_fail',
formatted='Failed to evolve {pokemon}!',
data={'pokemon': pokemon.name}
)
1 change: 0 additions & 1 deletion pokemongo_bot/event_handlers/colored_logging_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class ColoredLoggingHandler(EventHandler):
'moving_to_fort': 'white',
'moving_to_lured_fort': 'white',
'pokemon_catch_rate': 'white',
'pokemon_evolve_fail': 'white',
'pokestop_on_cooldown': 'white',
'pokestop_out_of_range': 'white',
'polyline_request': 'white',
Expand Down