Skip to content

Commit

Permalink
Merge pull request #6028 from davidakachaos/time_to_level_stat
Browse files Browse the repository at this point in the history
Added Time Till Level stat
  • Loading branch information
Jcolomar authored Apr 25, 2017
2 parents 8a28795 + a87d819 commit 8e71040
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pokemongo_bot/cell_workers/update_live_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,21 @@ def _get_stats(self, player_stats):
whole_level_xp = next_level_xp - prev_level_xp
level_completion_percentage = int((current_level_xp * 100) / whole_level_xp)
experience_per_hour = int(metrics.xp_per_hour())
# Calculate est time to level
remaining_xp = next_level_xp - current_level_xp
# eample; 30_000 xp remaining 3000 xp/h => 10h till level
if experience_per_hour > 0:
ttl = (float(remaining_xp) / float(experience_per_hour))
hours = int(ttl)
minutes = int((ttl - hours) * 60)
if hours > 24:
days = hours / 24
hours = hours % 24
time_to_level = "%s days %s hours %s minutes" % (days, hours, minutes)
else:
time_to_level = "%s hours %s minutes" % (hours, minutes)
else:
time_to_level = "Unknown"
xp_earned = metrics.xp_earned()
stops_visited = metrics.visits['latest'] - metrics.visits['start']
pokemon_encountered = metrics.num_encounters()
Expand Down Expand Up @@ -292,6 +307,7 @@ def _get_stats(self, player_stats):
'level_completion_percentage': level_completion_percentage,
'xp_per_hour': experience_per_hour,
'xp_earned': xp_earned,
'time_to_level': time_to_level,
'stops_visited': stops_visited,
'pokemon_encountered': pokemon_encountered,
'pokemon_caught': pokemon_caught,
Expand Down Expand Up @@ -337,6 +353,7 @@ def _get_stats_line(self, player_stats):
player_stats['whole_level_xp'], player_stats['level_completion_percentage']),
'xp_per_hour': '{:,} XP/h'.format(player_stats['xp_per_hour']),
'xp_earned': '+{:,} XP'.format(player_stats['xp_earned']),
'time_to_level': 'TTL: {}'.format(player_stats['time_to_level']),
'stops_visited': 'Visited {:,} stops'.format(player_stats['stops_visited']),
'pokemon_encountered': 'Encountered {:,} pokemon'.format(player_stats['pokemon_encountered']),
'pokemon_caught': 'Caught {:,} pokemon'.format(player_stats['pokemon_caught']),
Expand All @@ -351,7 +368,7 @@ def _get_stats_line(self, player_stats):
'pokeballs_thrown': 'Threw {:,} pokeballs'.format(player_stats['pokeballs_thrown']),
'stardust_earned': 'Earned {:,} Stardust'.format(player_stats['stardust_earned']),
'stardust_per_hour': '{:,} Stardust/h'.format(player_stats['stardust_per_hour']),
'total_stardust': 'Total Stardust: {}'.format(player_stats['total_stardust']),
'total_stardust': 'Total Stardust: {:,}'.format(player_stats['total_stardust']),
'highest_cp_pokemon': 'Highest CP pokemon : {}'.format(player_stats['highest_cp_pokemon']),
'most_perfect_pokemon': 'Most perfect pokemon : {}'.format(player_stats['most_perfect_pokemon']),
'location': 'Location : ({}, {})'.format(*player_stats['location']),
Expand Down

0 comments on commit 8e71040

Please sign in to comment.