Skip to content

Commit

Permalink
Remove the "evolve_captured" flag in favor of the EvolveTask (#3530)
Browse files Browse the repository at this point in the history
* Remove the "evolve_captured" flag in favor of the EvolveTask

* Remove unused event

* Warn the user instead of stopping the bot
  • Loading branch information
achretien authored and douglascamata committed Aug 11, 2016
1 parent 651c909 commit 0292c2f
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 82 deletions.
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

5 comments on commit 0292c2f

@Foulwerp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevented Pokémon from being transferred before they evolved.

Pokémon get transferred before EvolvePokemon task can evolve them.

@douglascamata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Foulwerp you just need to put EvolvePokemon before ReleasePokemon and guess what will happen?

@Foulwerp
Copy link

@Foulwerp Foulwerp commented on 0292c2f Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        {
            "type": "EvolvePokemon",
            "config": {
                "evolve_all": "Mankey,Rattata,Pidgey,Meowth,Growlithe,Geodude,Cubone,Zubat,Sandshrew,Ekans,Nidoran F,Nidoran M,Doduo,Caterpie,Weedle,Machop,Paras",
                "first_evolve_by": "cp",
                "evolve_above_cp": 0,
                "evolve_above_iv": 0,
                "logic": "and",
                "evolve_speed": 20,
                "use_lucky_egg": false
            }
        },
        {
            "type": "TransferPokemon"
        },

You mean like this. Yeah that doesn't work for me unless I'm doing it wrong.

2016-08-11 20:47:33,854 [PokemonCatchWorker] [INFO] [pokemon_appeared] A wild Zubat appeared! [CP 185] [Potential 0.56] [A/D/S 2/15/8]
2016-08-11 20:47:36,381 [PokemonCatchWorker] [INFO] [threw_pokeball] Used Pokeball, with chance 43.22 (65 left)
2016-08-11 20:47:36,627 [PokemonCatchWorker] [INFO] [pokemon_caught] Captured Zubat! [CP 185] [Potential 0.56] [2/15/8] [+160 exp]
2016-08-11 20:47:36,630 [PokemonCatchWorker] [INFO] [gained_candy] You now have 1354 Zubat candy!
2016-08-11 20:47:41,900 [TransferPokemon] [INFO] [future_pokemon_release] Releasing Zubat [CP 185] [IV 0.56] based on rule: CP < 375 OR IV < 0.8
2016-08-11 20:47:42,233 [TransferPokemon] [INFO] [pokemon_release] Exchanged Zubat [CP 185] [IV 0.56] for candy.
2016-08-11 20:47:48,026 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop Mini Drinking Fountain - 665.65ft
2016-08-11 20:47:50,339 [PokemonCatchWorker] [INFO] [pokemon_appeared] A wild Ponyta appeared! [CP 861] [Potential 0.49] [A/D/S 13/9/0]
2016-08-11 20:47:53,289 [PokemonCatchWorker] [INFO] [threw_pokeball] Used Greatball, with chance 35.74 (19 left)
2016-08-11 20:47:53,535 [PokemonCatchWorker] [INFO] [pokemon_caught] Captured Ponyta! [CP 861] [Potential 0.49] [13/9/0] [+150 exp]
2016-08-11 20:47:53,536 [PokemonCatchWorker] [INFO] [gained_candy] You now have 315 Ponyta candy!
2016-08-11 20:47:58,835 [TransferPokemon] [INFO] [future_pokemon_release] Releasing Ponyta [CP 861] [IV 0.49] based on rule: CP < 850 OR IV < 0.8
2016-08-11 20:47:59,165 [TransferPokemon] [INFO] [pokemon_release] Exchanged Ponyta [CP 861] [IV 0.49] for candy.

Using the logic from above.

@douglascamata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course it works, I use it all the time. Both these tasks need to run in the beginning of the tick and before CatchPokemon.

@Foulwerp
Copy link

@Foulwerp Foulwerp commented on 0292c2f Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh let me try to put them before catch pokemon.

2016-08-11 20:50:28,170 [PokemonCatchWorker] [INFO] [threw_pokeball] Used Greatball, with chance 47.08 (16 left)
2016-08-11 20:50:28,450 [PokemonCatchWorker] [INFO] [pokemon_caught] Captured Ponyta! [CP 453] [Potential 0.29] [11/2/0] [+150 exp]
2016-08-11 20:50:28,453 [PokemonCatchWorker] [INFO] [gained_candy] You now have 319 Ponyta candy!
2016-08-11 20:50:33,664 [MoveToFort] [INFO] [moving_to_lured_fort] Moving towards pokestop Disneyland Fire Department - 195.38ft (attraction of lure 195.38ft)
2016-08-11 20:50:35,779 [TransferPokemon] [INFO] [future_pokemon_release] Releasing Ponyta [CP 453] [IV 0.29] based on rule: CP < 850 OR IV < 0.8
2016-08-11 20:50:36,101 [TransferPokemon] [INFO] [pokemon_release] Exchanged Ponyta [CP 453] [IV 0.29] for candy.

Put before catch Pokémon same results. Just to clarify I added Ponyta to the evolve list...

Okay I stand corrected it was only the first pokemon I caught did not evolve the rest are now doing it as they are supposed to.

Thank you for your time and advice.

Please sign in to comment.