-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Added further release functionality #1472
Changes from all commits
e9be00b
76d122c
8d8cf2c
e6cc405
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from pokemongo_bot.human_behaviour import sleep, action_delay | ||
from pokemongo_bot import logger | ||
|
||
|
||
class PokemonTransferWorker(object): | ||
|
||
def __init__(self, bot): | ||
|
@@ -24,21 +25,31 @@ def work(self): | |
keep_best, keep_best_cp, keep_best_iv = self._validate_keep_best_config(pokemon_name) | ||
|
||
if keep_best: | ||
order_criteria = 'cp' | ||
limit = keep_best_cp | ||
best_pokemon_ids = set() | ||
order_criteria = 'none' | ||
if keep_best_cp >= 1: | ||
cp_limit = keep_best_cp | ||
best_cp_pokemons = sorted(group, key=lambda x: (x['cp'], x['iv']), reverse=True)[:cp_limit] | ||
best_pokemon_ids = set(pokemon['pokemon_data']['id'] for pokemon in best_cp_pokemons) | ||
order_criteria = 'cp' | ||
|
||
if keep_best_iv >= 1: | ||
order_criteria = 'iv' | ||
limit = keep_best_iv | ||
|
||
best_pokemons = sorted(group, key=lambda x: x[order_criteria], reverse=True)[:limit] | ||
iv_limit = keep_best_iv | ||
best_iv_pokemons = sorted(group, key=lambda x: (x['iv'], x['cp']), reverse=True)[:iv_limit] | ||
best_pokemon_ids |= set(pokemon['pokemon_data']['id'] for pokemon in best_iv_pokemons) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with the operator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://docs.python.org/2/library/sets.html#set-objects it seems to be standard set operator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In this context |
||
if order_criteria == 'cp': | ||
order_criteria = 'cp and iv' | ||
else: | ||
order_criteria = 'iv' | ||
|
||
# remove best pokemons from all pokemons array | ||
all_pokemons = group | ||
for best_pokemon in best_pokemons: | ||
best_pokemons = [] | ||
for best_pokemon_id in best_pokemon_ids: | ||
for pokemon in all_pokemons: | ||
if best_pokemon['pokemon_data']['id'] == pokemon['pokemon_data']['id']: | ||
if best_pokemon_id == pokemon['pokemon_data']['id']: | ||
all_pokemons.remove(pokemon) | ||
best_pokemons.append(pokemon) | ||
|
||
if best_pokemons and all_pokemons: | ||
logger.log("Keep {} best {}, based on {}".format(len(best_pokemons), | ||
|
@@ -190,10 +201,6 @@ def _validate_keep_best_config(self, pokemon_name): | |
except ValueError: | ||
keep_best_iv = 0 | ||
|
||
if keep_best_cp > 1 and keep_best_iv > 1: | ||
logger.log("keep_best_cp and keep_best_iv can't be > 0 at the same time. Ignore it.", "red") | ||
keep_best = False | ||
|
||
if keep_best_cp < 0 or keep_best_iv < 0: | ||
logger.log("Keep best can't be < 0. Ignore it.", "red") | ||
keep_best = False | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this say
3 strongest
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to 2.