Skip to content

Commit

Permalink
Actually tread them as GER and finishes -> finishers
Browse files Browse the repository at this point in the history
  • Loading branch information
12pm committed Oct 8, 2018
1 parent 969171b commit ac9e48d
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions cogs/profilecard.py
Expand Up @@ -28,7 +28,7 @@ def reload_data():
with open(MSGPACK_FILE_PATH, 'rb') as inp:
unpacker = msgpack.Unpacker(inp, use_list=False)
server_types = unpacker.unpack() # `(type, ..)`
stats_maps = unpacker.unpack() # `{type: ((map, points, finishes), ..), ..}`
stats_maps = unpacker.unpack() # `{type: ((map, points, finishers), ..), ..}`
total_points = unpacker.unpack() # `points`
stats_points = unpacker.unpack() # `((player, points), ..)`
stats_weekly_points = unpacker.unpack() # `((player, points), ..)`
Expand Down Expand Up @@ -176,13 +176,11 @@ def get_player_rank_stats(self, player):
def get_player_flag(self, player):
# AUS, BRA, CAN, CHL, CHN, FRA, GER, GER2, IRN, KSA, RUS, USA, ZAF
locations = self.stats_players[player.encode()][1]
if b'' in locations:
del locations[b'']

if not locations:
return 'UNK'

eur_locations = [b'GER', b'GER2', b'FRA']
# Finishes without country code are actually GER ones
eur_locations = [b'', b'GER', b'GER2', b'FRA']
eur_finishes = 0
for l in eur_locations:
if l in locations:
Expand Down Expand Up @@ -340,9 +338,9 @@ def get_map_details(self, map_name):
map_name_formated = map_name.encode()
similar_names = []
for server_type, data in self.stats_maps.items():
for name, points, finishes in data:
for name, points, finishers in data:
if name == map_name_formated:
return True, (map_name, mapper, release_date, server_type.decode(), points, finishes)
return True, (map_name, mapper, release_date, server_type.decode(), points, finishers)

return None, None

Expand Down Expand Up @@ -400,7 +398,7 @@ def get_map_tiles(self, map_name):

return [*map_tiles_negative, *map_tiles_special, *map_tiles_weapon]

def generate_map_profile(self, map_name, mapper, release_date, server_type, points, finishes, top_teamranks,
def generate_map_profile(self, map_name, mapper, release_date, server_type, points, finishers, top_teamranks,
top_ranks, tiles=None):
def get_stars(difficulty):
return '★' * difficulty + '☆' * max(5 - difficulty, 0)
Expand Down Expand Up @@ -557,9 +555,9 @@ def get_title(map_name, mapper):
title += '</div>'
return title

def get_finish_span(finishes):
text = 'FINISH' if finishes == 1 else 'FINISHES'
return f'<span class="finishes">{finishes}</span><span class="finishes-text"> {text}</span>'
def get_finishers_span(finishers):
text = 'FINISHER' if finishers == 1 else 'FINISHERS'
return f'<span class="finishers">{finishers}</span><span class="finishers-text"> {text}</span>'

def format_release_date(release_date):
date = datetime.strptime(release_date, '%Y-%m-%dT%H:%M:%S')
Expand All @@ -570,7 +568,7 @@ def format_release_date(release_date):
title = get_title(map_name, mapper)
difficulty = self.get_difficulty(server_type, points)
stars = get_stars(difficulty)
finish_span = get_finish_span(finishes)
finish_span = get_finishers_span(finishers)
release_span = format_release_date(release_date) if release_date else ''
tiles_div = get_tiles_div(tiles) if tiles else ''
ranks = get_ranks_table(top_teamranks, top_ranks)
Expand Down

0 comments on commit ac9e48d

Please sign in to comment.