Skip to content

Commit

Permalink
Better enforce rules about Pokemons to retain. (#2073)
Browse files Browse the repository at this point in the history
Rules about maximum CP and IV to transfer Pokemons are applied
also when keeping the best ones.
  • Loading branch information
giomasce authored and solderzzc committed Aug 1, 2016
1 parent 248ac53 commit ff62273
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pokemongo_bot/cell_workers/transfer_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def work(self):
all_pokemons.remove(pokemon)
best_pokemons.append(pokemon)

if best_pokemons and all_pokemons:
transfer_pokemons = [pokemon for pokemon in all_pokemons
if self.should_release_pokemon(pokemon_name,
pokemon['cp'],
pokemon['iv'])]

if transfer_pokemons:
logger.log("Keep {} best {}, based on {}".format(len(best_pokemons),
pokemon_name,
order_criteria), "green")
Expand All @@ -50,10 +55,10 @@ def work(self):
best_pokemon['cp'],
best_pokemon['iv']), 'green')

logger.log("Transferring {} pokemon".format(len(all_pokemons)), "green")
logger.log("Transferring {} pokemon".format(len(transfer_pokemons)), "green")

for pokemon in all_pokemons:
self.release_pokemon(pokemon_name, pokemon['cp'], pokemon['iv'], pokemon['pokemon_data']['id'])
for pokemon in transfer_pokemons:
self.release_pokemon(pokemon_name, pokemon['cp'], pokemon['iv'], pokemon['pokemon_data']['id'])
else:
group = sorted(group, key=lambda x: x['cp'], reverse=True)
for item in group:
Expand Down

0 comments on commit ff62273

Please sign in to comment.