From 39a697b6eed7298e0f96ceb99636838d4026f1ab Mon Sep 17 00:00:00 2001 From: David Westerink Date: Sat, 29 Jul 2017 18:05:23 +0200 Subject: [PATCH 1/3] Added only_catch_better_iv and only_catch_better_cp --- docs/configuration_files.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/configuration_files.md b/docs/configuration_files.md index ea4ee13a00..54f6b626b7 100644 --- a/docs/configuration_files.md +++ b/docs/configuration_files.md @@ -423,6 +423,19 @@ For example: ``` will stop catching Pidgey entirely. +You can set a rule to only catch better IV or CP Pokemon by setting the only_catch_better_cp or only_catch_better_iv flags. + + +For example: +``` +"Pidgey": { + "only_catch_better_iv": true +}, +"Gloom": { + "only_catch_better_cp": true +} +``` + ## Release Configuration [[back to top](#table-of-contents)] From 422348cb6e597d678b17e172dd02ab2d1e292ab3 Mon Sep 17 00:00:00 2001 From: David Westerink Date: Sat, 29 Jul 2017 18:10:27 +0200 Subject: [PATCH 2/3] Added only_catch_better_iv and only_catch_better_cp --- .../cell_workers/pokemon_catch_worker.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 1bd6feaefe..94b543b664 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -312,6 +312,35 @@ def _pokemon_matches_config(self, config, pokemon, default_logic='and'): if pokemon_config.get('always_catch', False): return True + if pokemon_config.get('only_catch_better_cp', False): + # If we don't have the Pokemon, this always returns true + if len(current_owned) == 0: + return True + # Catch only if better CP + current_owned.sort(key=lambda p: p.cp) + if pokemon.cp > current_owned[0].cp: + return True + else: + return False + + if pokemon_config.get('only_catch_better_iv', False): + # If we don't have the Pokemon, this always returns true + if len(current_owned) == 0: + return True + # Catch only if better CP + current_owned.sort(key=lambda p: p.iv) + if current_owned[0].iv == 1: + # Already have a perfect Pokemon, checking CP + if pokemon.cp > current_owned[0].cp: + return True + else: + return False + # Check the IV + if pokemon.iv > current_owned[0].iv: + return True + else: + return False + if pokemon_config.get('catch_above_ncp',-1) >= 0: if pokemon.cp_percent >= pokemon_config.get('catch_above_ncp'): catch_results['ncp'] = True From 1770805b72a0667bac4f16966e776876c0bea73d Mon Sep 17 00:00:00 2001 From: David Westerink Date: Sat, 29 Jul 2017 18:12:16 +0200 Subject: [PATCH 3/3] Get the current pokemon --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 94b543b664..f3de99c143 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -301,6 +301,7 @@ def _pokemon_matches_config(self, config, pokemon, default_logic='and'): catch_logic = pokemon_config.get('logic', default_logic) + current_owned = [p for p in inventory.pokemons().all() if p.name == pokemon.name] candies = inventory.candies().get(pokemon.pokemon_id).quantity threshold = pokemon_config.get('candy_threshold', -1) if threshold > 0 and candies >= threshold: # Got enough candies