diff --git a/configs/config.json.cluster.example b/configs/config.json.cluster.example index c9cc3b3ca3..1bedbcbab9 100644 --- a/configs/config.json.cluster.example +++ b/configs/config.json.cluster.example @@ -100,6 +100,7 @@ "reconnecting_timeout": 15, "catch_randomize_reticle_factor": 1.0, "catch_randomize_spin_factor": 1.0, + "min_ultraball_to_keep": 10, "logging_color": true, "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, diff --git a/configs/config.json.example b/configs/config.json.example index 2cf5a0f737..f306d3a920 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -113,6 +113,9 @@ "location_cache": true, "distance_unit": "km", "reconnecting_timeout": 15, + "catch_randomize_reticle_factor": 1.0, + "catch_randomize_spin_factor": 1.0, + "min_ultraball_to_keep": 10, "logging_color": true, "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, diff --git a/configs/config.json.map.example b/configs/config.json.map.example index ff2b8a69e2..6051e063cc 100644 --- a/configs/config.json.map.example +++ b/configs/config.json.map.example @@ -342,6 +342,7 @@ "reconnecting_timeout": 15, "catch_randomize_reticle_factor": 1.0, "catch_randomize_spin_factor": 1.0, + "min_ultraball_to_keep": 10, "logging_color": true, "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, diff --git a/configs/config.json.path.example b/configs/config.json.path.example index 23578f8125..2581862b31 100644 --- a/configs/config.json.path.example +++ b/configs/config.json.path.example @@ -102,6 +102,7 @@ "reconnecting_timeout": 15, "catch_randomize_reticle_factor": 1.0, "catch_randomize_spin_factor": 1.0, + "min_ultraball_to_keep": 10, "logging_color": true, "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, diff --git a/configs/config.json.pokemon.example b/configs/config.json.pokemon.example index a2d5d96a2b..2ad81a7369 100644 --- a/configs/config.json.pokemon.example +++ b/configs/config.json.pokemon.example @@ -108,6 +108,7 @@ "reconnecting_timeout": 15, "catch_randomize_reticle_factor": 1.0, "catch_randomize_spin_factor": 1.0, + "min_ultraball_to_keep": 10, "logging_color": true, "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or" }, diff --git a/pokecli.py b/pokecli.py index 2cd5553ba5..4ccedb5fa6 100644 --- a/pokecli.py +++ b/pokecli.py @@ -454,6 +454,7 @@ def _json_loader(filename): config.action_wait_min = load.get('action_wait_min', 1) config.plugins = load.get('plugins', []) config.raw_tasks = load.get('tasks', []) + config.min_ultraball_to_keep = load.get('min_ultraball_to_keep', None) config.vips = load.get('vips', {}) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index d28f3f58fd..edd5db567e 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -264,6 +264,12 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): berry_count = self.bot.item_inventory_count(berry_id) items_stock = self.bot.current_inventory() + # use `min_ultraball_to_keep` from config if is not None + min_ultraball_to_keep = items_stock[ITEM_ULTRABALL] + if self.config.min_ultraball_to_keep is not None: + if self.config.min_ultraball_to_keep >= 0 and self.config.min_ultraball_to_keep < min_ultraball_to_keep: + min_ultraball_to_keep = self.config.min_ultraball_to_keep + while True: # find lowest available ball @@ -272,7 +278,13 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): current_ball += 1 if items_stock[current_ball] == 0: self.emit_event('no_pokeballs', formatted='No usable pokeballs found!') - break + + # use untraball if there is no other balls with constraint to `min_ultraball_to_keep` + if maximum_ball != ITEM_ULTRABALL and items_stock[ITEM_ULTRABALL] > min_ultraball_to_keep: + maximum_ball = ITEM_ULTRABALL + continue + else: + break # check future ball count num_next_balls = 0