[Feature Request] Releasing all pokemon in bag except X best ones
Short Description
Currently it is possible to release all pokemon of some type except N best ones based on some criteria:
"release": { "any": {"keep_best_iv": N} }
Ability to always keep N best pokemon in bag would be useful. For example, player may want to keep 150 best CP and 50 best IV pokemon always in his bag and to release everyone else.
Possible solution
Implement new "pokemon name" all which is executed after all other rules (first we discard pokemon based on specific rules, than in what remains we keep best 150 pokemon):
"release": { "all": { "keep_best_custom": "iv, cp, hp_max", "amount": 150 } }
This may be a naive implementation which ignores application order:
- In
_release_pokemon_get_groupswe always return one extra fake group with pokemon_id = 10000. This group containa all pokemons from other groups (just fav/fort-filteredinventory.pokemons().all()). - On line 28 in
transfer_pokemon.pywe replace getting pokemon name withpokemon_name = Pokemons.name_for(pokemon_id) if pokemon_id > 0 else 'all' - Everything else works as expected.
If we want application order to be correct, things are more difficult (I don't know bot well enough to propose good solution). As far as I can see:
- Refactor lines 29-87 (contents of
forloop except the first line) intransfer_pokemon.pyin a separate function_release_pokemon_group(pokemon_list, pokemon_name)to launch it later below the for loop with pokemon name equals to'all'. - After the end of
forloop:group = [p for p in inventory.pokemons().all() if p.in_fort is False and p.is_favourite is False]. - Call
_release_pokemon_group(group, 'all'). - Done.
How it would help others
Well, first of all -- it would be quite nice feature on its own. Also it can solve problems like #4468 quite easily and it would prevent exceeding pokemon bag (which is possible with current configuration options) limits and some other nice features.
Recent dev merge adds this feature. Please elaborate if it does not meet your needs.