From: Jan Behrens Date: Thu, 11 Apr 2013 07:50:24 +0000 (+0200) Subject: Allowing elos to be shown even for less than 32 games X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonstat.git;a=commitdiff_plain;h=8333892a3f46de91e4cb1225f24da964ee69f619 Allowing elos to be shown even for less than 32 games Since ranks are not defined if this is the case, the notice "preliminary" is shown below these elos. --- diff --git a/xonstat/batch/badges/playerdata.py b/xonstat/batch/badges/playerdata.py index e5b4046..ed4fca4 100644 --- a/xonstat/batch/badges/playerdata.py +++ b/xonstat/batch/badges/playerdata.py @@ -46,7 +46,7 @@ class PlayerData: elos_dict = {} for gt,elo in elos.items(): - if elo.games >= 32: + if elo.games > 0: elos_dict[gt] = elo.elo self.data = { diff --git a/xonstat/batch/badges/skin.py b/xonstat/batch/badges/skin.py index 740b442..982512e 100644 --- a/xonstat/batch/badges/skin.py +++ b/xonstat/batch/badges/skin.py @@ -298,7 +298,7 @@ class Skin: space_w -= tw # this hilarious code should determine the spacing between characters - sep_w = 0.25*space_w + sep_w = 0.2*space_w if sep_w <= 0: sep_w = 1 @@ -341,14 +341,14 @@ class Skin: ctx.show_text(txt.encode("utf-8")) tw += (len(txt)-len(txt.strip())) * space_w # account for lost whitespaces - xoffset += tw + sep_w + xoffset += int(tw + sep_w) ## print elos and ranks xoffset, yoffset = 0, 0 count = 0 for gt in game_types[:self.num_gametypes]: - if not elos.has_key(gt) or not ranks.has_key(gt): + if not elos.has_key(gt): continue count += 1 @@ -365,7 +365,7 @@ class Skin: # show a number gametypes the player has participated in for gt in game_types[:self.num_gametypes]: - if not elos.has_key(gt) or not ranks.has_key(gt): + if not elos.has_key(gt): # should not happen continue offset = (xoffset, yoffset) @@ -382,7 +382,10 @@ class Skin: self.set_font(self.elo_fontsize, self.elo_color) self.show_text(txt, self.elo_pos, self.elo_align, offset=offset) if self.rank_pos: - txt = self.rank_text % ranks[gt] + if ranks.has_key(gt): + txt = self.rank_text % ranks[gt] + else: + txt = "(preliminary)" self.set_font(self.rank_fontsize, self.rank_color) self.show_text(txt, self.rank_pos, self.rank_align, offset=offset)