-
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
Make initial_transfer use release config #1023
Make initial_transfer use release config #1023
Conversation
would be good to update the documentation as well: https://github.com/PokemonGoF/PokemonGo-Bot/blob/dev/README.md#advance-configuration |
The feature is good, README need modified as @VictorChen mentioned. |
@alvarogzp please fix readme because I love this PR. |
@solderzzc @douglascamata done! I have also set initial_transfer to false in config examples |
I have also added me to contributors :P |
@alvarogzp try to reuse this code from def should_release_pokemon(self, pokemon_name, cp, iv, response_dict):
release_config = self._get_release_config_for(pokemon_name)
cp_iv_logic = release_config.get('logic')
if not cp_iv_logic:
cp_iv_logic = self._get_release_config_for('any').get('logic', 'and')
release_results = {
'cp': False,
'iv': False,
}
if release_config.get('never_release', False):
return False
if release_config.get('always_release', False):
return True
release_cp = release_config.get('release_below_cp', 0)
if cp < release_cp:
release_results['cp'] = True
release_iv = release_config.get('release_below_iv', 0)
if iv < release_iv:
release_results['iv'] = True
logic_to_function = {
'or': lambda x, y: x or y,
'and': lambda x, y: x and y
}
#logger.log(
# "Release config for {}: CP {} {} IV {}".format(
# pokemon_name,
# min_cp,
# cp_iv_logic,
# min_iv
# ), 'yellow'
#)
return logic_to_function[cp_iv_logic](*release_results.values())
def _get_release_config_for(self, pokemon):
release_config = self.config.release.get(pokemon)
if not release_config:
release_config = self.config.release.get('any')
if not release_config:
release_config = {}
return release_config |
@douglascamata the problem is that the IV has to be calculated, and that logic is buried inside pokemon_catch_worker, but I will try :) |
@alvarogzp oh crap, I forgot that. Maybe you can extract that logic too. I would be great! |
@douglascamata I think it is completed now |
@Zgrkaralar please put your release config to see if it does not released because of it. Also, please update to last commit (as now it uses also IV to decide if exchange or not). |
Please test this a lot, guys. It's very important for release code to not have bugs. Very good job tho! |
I have code that removes initial transfer entirely in favor of a worker that checks every loop what needs to be released. We can merge this, but my PR if accepted will just delete it. :) |
@SteffanLong where is you PR, dude? Someone did this too and PR is open, just want to merge this first |
@douglascamata It was closed because diff was too large. I haven't had time to merge upstream, fix the conflicts, and then create multiple PRs yet. Go ahead and merge this, least it will help for the time being. |
* Modify initial_transfer_worker.py to use release CP config * Update README to inidicate initial_transfer new meaning * Update config examples to set initial_transfer to false instead of 0 * Add myself to contributors * Take into account also the iv to release a pokemon in the initial_transfer * Update README and log messages * Improve Exchange message
Modify the initial_transfer feature so that instead of releasing all pokemons below a certain CP, use the release config to decide whether release the pokemon or not.