Skip to content

Commit

Permalink
Merge pull request #4742 from alexyaoyang/improvement-show-current-ca…
Browse files Browse the repository at this point in the history
…ught-last-24

Show current progress + move config into CatchPokemon Task
  • Loading branch information
solderzzc authored Aug 26, 2016
2 parents bc69ca1 + 3831ed3 commit ba424f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 3 additions & 1 deletion pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,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', [])
config.live_config_update = load.get('live_config_update', {})
Expand Down Expand Up @@ -668,6 +667,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
Expand Down
4 changes: 3 additions & 1 deletion pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,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(
Expand Down
14 changes: 7 additions & 7 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -258,9 +259,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):
Expand Down Expand Up @@ -525,7 +523,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),
Expand All @@ -536,7 +534,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
}

)
Expand Down

0 comments on commit ba424f9

Please sign in to comment.