diff --git a/pokecli.py b/pokecli.py index d6ee2adaff..3930a082db 100644 --- a/pokecli.py +++ b/pokecli.py @@ -224,9 +224,9 @@ def report_summary(bot): logger.info('Total XP Earned: {} Average: {:.2f}/h'.format(metrics.xp_earned(), metrics.xp_per_hour())) logger.info('Travelled {:.2f}km'.format(metrics.distance_travelled())) logger.info('Visited {} stops'.format(metrics.visits['latest'] - metrics.visits['start'])) - logger.info('Encountered {} pokemon, {} caught, {} released, {} evolved, {} never seen before' + logger.info('Encountered {} pokemon, {} caught, {} released, {} evolved, {} never seen before ({})' .format(metrics.num_encounters(), metrics.num_captures(), metrics.releases, - metrics.num_evolutions(), metrics.num_new_mons())) + metrics.num_evolutions(), metrics.num_new_mons(), metrics.uniq_caught())) logger.info('Threw {} pokeball{}'.format(metrics.num_throws(), '' if metrics.num_throws() == 1 else 's')) logger.info('Earned {} Stardust'.format(metrics.earned_dust())) logger.info('Hatched eggs {}'.format(metrics.hatched_eggs(0))) diff --git a/pokemongo_bot/metrics.py b/pokemongo_bot/metrics.py index 76faeb0728..3e5d479857 100644 --- a/pokemongo_bot/metrics.py +++ b/pokemongo_bot/metrics.py @@ -1,6 +1,6 @@ import time from datetime import timedelta - +from pokemongo_bot.inventory import Pokemons class Metrics(object): @@ -20,9 +20,11 @@ def __init__(self, bot): self.releases = 0 self.highest_cp = {'cp': 0, 'desc': ''} self.most_perfect = {'potential': 0, 'desc': ''} - self.eggs = {'hatched': 0, 'next_hatching_km': 0} + self.uniq_pokemons_caught = None + self.uniq_pokemons_list = None + def runtime(self): return timedelta(seconds=round(time.time() - self.start_time)) @@ -44,6 +46,10 @@ def num_throws(self): def num_captures(self): return self.captures['latest'] - self.captures['start'] + def uniq_caught(self): + # generate pokemon string 'Snorlax, Pikachu' from list of ids + return ', '.join([Pokemons.name_for(pok_id) for pok_id in self.uniq_pokemons_caught]) or '' + def captures_per_hour(self): """ Returns an estimated number of pokemon caught per hour. @@ -95,6 +101,8 @@ def capture_stats(self): request.get_player() response_dict = request.call() try: + uniq_pokemon_list = set() + self.dust['latest'] = response_dict['responses']['GET_PLAYER']['player_data']['currencies'][1]['amount'] if self.dust['start'] < 0: self.dust['start'] = self.dust['latest'] for item in response_dict['responses']['GET_INVENTORY']['inventory_delta']['inventory_items']: @@ -128,6 +136,16 @@ def capture_stats(self): self.evolutions['latest'] = playerdata.get('evolutions', 0) if self.evolutions['start'] < 0: self.evolutions['start'] = self.evolutions['latest'] + elif 'pokedex_entry' in item['inventory_item_data']: + entry = item['inventory_item_data']['pokedex_entry'].get('pokemon_id') + if entry: uniq_pokemon_list.add(entry) + + if not self.uniq_pokemons_list: # make set from pokedex entries on first run + self.uniq_pokemons_list = uniq_pokemon_list + else: + # generate new entries for current bot session + self.uniq_pokemons_caught = uniq_pokemon_list - self.uniq_pokemons_list + except KeyError: # Nothing we can do if there's no player info. return