]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/batch/badges/skin.py
fix missing gametypes in some player badges
[xonotic/xonstat.git] / xonstat / batch / badges / skin.py
index 982512edb83c9653c48a8d7355c594b5ee61691d..edcb2eb4acde76cff706f71b9008abac03d05e73 100644 (file)
@@ -204,18 +204,16 @@ class Skin:
 
         # make sorted list of gametypes
         game_types = []
-        num_games  = 0
-        for gt,info in data['games_played'].items():
-            if gt == "overall":
+        for gt in data['games_played'].keys():
+            if gt == 'overall':
                 continue
-            if info.games > num_games:
-                game_types.insert(0, gt)
-            else:
-                game_types.append(gt)
-        
-        # make sure gametypes list if sorted correctly (number of games, descending)
-        game_types = sorted(game_types, key=lambda x: data['games_played'][x].games, reverse=True)
+            if elos.has_key(gt):
+                game_types.append(gt)  # only uses gametypes with elo values (needed later on)
 
+        ## make sure gametypes list if sorted correctly (number of games, descending)
+        ##game_types = sorted(game_types, key=lambda x: data['games_played'][x].games, reverse=True)
+        # make sure gametypes list if sorted correctly (total playing time per game type, descending)
+        game_types = sorted(game_types, key=lambda x: data['overall_stats'][x].total_playing_time, reverse=True)
 
 
         # build image
@@ -351,7 +349,7 @@ class Skin:
             if not elos.has_key(gt):
                 continue
             count += 1
-            
+
         # re-align segments if less than max. gametypes are shown
         if count > 0:
             if count < self.num_gametypes:
@@ -413,16 +411,16 @@ class Skin:
         try:
             txt = "%.2f%%" % round(win_pct, 2)
         except:
-            win_pct = 0
+            win_pct = 0.
 
         if self.winp_pos:
-            if win_pct >= 0.5:
-                nr = 2*(win_pct-0.5)
+            if win_pct >= 50.0:
+                nr = 2*(win_pct/100-0.5)
                 r = nr*self.winp_colortop[0] + (1-nr)*self.winp_colormid[0]
                 g = nr*self.winp_colortop[1] + (1-nr)*self.winp_colormid[1]
                 b = nr*self.winp_colortop[2] + (1-nr)*self.winp_colormid[2]
             else:
-                nr = 2*win_pct
+                nr = 2*(win_pct/100)
                 r = nr*self.winp_colormid[0] + (1-nr)*self.winp_colorbot[0]
                 g = nr*self.winp_colormid[1] + (1-nr)*self.winp_colorbot[1]
                 b = nr*self.winp_colormid[2] + (1-nr)*self.winp_colorbot[2]