From 3831ed3804b66bd779157755b79a33d3f82ef7ea Mon Sep 17 00:00:00 2001 From: Alex Yao Date: Thu, 25 Aug 2016 16:10:08 -0700 Subject: [PATCH] Show current progress + move config into CatchPokemon Task --- pokecli.py | 4 +++- pokemongo_bot/__init__.py | 4 +++- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 14 +++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pokecli.py b/pokecli.py index 3930a082db..8e358f606e 100644 --- a/pokecli.py +++ b/pokecli.py @@ -593,7 +593,6 @@ def _json_loader(filename): config.release = load.get('release', {}) config.plugins = load.get('plugins', []) config.raw_tasks = load.get('tasks', []) - config.daily_catch_limit = load.get('daily_catch_limit', 800) config.vips = load.get('vips', {}) config.sleep_schedule = load.get('sleep_schedule', []) @@ -638,6 +637,9 @@ def task_configuration_error(flag_name): if "walk" in load: logger.warning('The walk argument is no longer supported. Please use the walk_max and walk_min variables instead') + if "daily_catch_limit" in load: + logger.warning('The daily_catch_limit argument has been moved into the CatchPokemon Task') + if config.walk_min < 1: parser.error("--walk_min is out of range! (should be >= 1.0)") return None diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 842664d7ef..559ecff3dd 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -400,7 +400,9 @@ def _register_events(self): 'encounter_id', 'latitude', 'longitude', - 'pokemon_id' + 'pokemon_id', + 'daily_catch_limit', + 'caught_last_24_hour', ) ) self.event_manager.register_event( diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index ea62f89f3c..1e4211d5ec 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -60,6 +60,7 @@ def initialize(self): self.berry_threshold = self.config.get('berry_threshold', 0.35) self.vip_berry_threshold = self.config.get('vip_berry_threshold', 0.9) self.treat_unseen_as_vip = self.config.get('treat_unseen_as_vip', DEFAULT_UNSEEN_AS_VIP) + self.daily_catch_limit = self.config.get('daily_catch_limit', 800) self.catch_throw_parameters = self.config.get('catch_throw_parameters', {}) self.catch_throw_parameters_spin_success_rate = self.catch_throw_parameters.get('spin_success_rate', 0.6) @@ -161,10 +162,10 @@ def work(self, response_dict=None): c.execute("SELECT DISTINCT COUNT(encounter_id) FROM catch_log WHERE dated >= datetime('now','-1 day')") result = c.fetchone() + self.caught_last_24_hour = result[0] while True: - max_catch = self.bot.config.daily_catch_limit - if result[0] < max_catch: + if self.caught_last_24_hour < self.daily_catch_limit: # catch that pokemon! encounter_id = self.pokemon['encounter_id'] catch_rate_by_ball = [0] + response['capture_probability']['capture_probability'] # offset so item ids match indces @@ -241,9 +242,6 @@ def _pokemon_matches_config(self, config, pokemon, default_logic='and'): if pokemon.iv > catch_iv: catch_results['iv'] = True - if self.bot.capture_locked: # seems there is another more preferable pokemon, catching is locked - return False - return LOGIC_TO_FUNCTION[pokemon_config.get('logic', default_logic)](*catch_results.values()) def _should_catch_pokemon(self, pokemon): @@ -508,7 +506,7 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): self.emit_event( 'pokemon_caught', - formatted='Captured {pokemon}! [CP {cp}] [NCP {ncp}] [Potential {iv}] [{iv_display}] [+{exp} exp]', + formatted='Captured {pokemon}! [CP {cp}] [NCP {ncp}] [Potential {iv}] [{iv_display}] ({caught_last_24_hour}/{daily_catch_limit}) [+{exp} exp]', data={ 'pokemon': pokemon.name, 'ncp': round(pokemon.cp_percent, 2), @@ -519,7 +517,9 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): 'encounter_id': self.pokemon['encounter_id'], 'latitude': self.pokemon['latitude'], 'longitude': self.pokemon['longitude'], - 'pokemon_id': pokemon.pokemon_id + 'pokemon_id': pokemon.pokemon_id, + 'caught_last_24_hour': self.caught_last_24_hour + 1, + 'daily_catch_limit': self.daily_catch_limit } )