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

fixed "keep_best" which didn't work alone anymore #2215

Merged
merged 1 commit into from
Aug 1, 2016
Merged
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
13 changes: 11 additions & 2 deletions pokemongo_bot/cell_workers/transfer_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def work(self):
transfer_pokemons = [pokemon for pokemon in all_pokemons
if self.should_release_pokemon(pokemon_name,
pokemon['cp'],
pokemon['iv'])]
pokemon['iv'],
True)]

if transfer_pokemons:
logger.log("Keep {} best {}, based on {}".format(len(best_pokemons),
Expand Down Expand Up @@ -125,8 +126,16 @@ def get_pokemon_potential(self, pokemon_data):
continue
return round((total_iv / 45.0), 2)

def should_release_pokemon(self, pokemon_name, cp, iv):
def should_release_pokemon(self, pokemon_name, cp, iv, keep_best_mode = False):
release_config = self._get_release_config_for(pokemon_name)

if (keep_best_mode
and not release_config.has_key('never_release')
and not release_config.has_key('always_release')
and not release_config.has_key('release_below_cp')
and not release_config.has_key('release_below_iv')):
return True

cp_iv_logic = release_config.get('logic')
if not cp_iv_logic:
cp_iv_logic = self._get_release_config_for('any').get('logic', 'and')
Expand Down