It isn't always a 4/4 split
authorStefano Rivera <stefano@rivera.za.net>
Mon, 12 May 2014 19:10:02 +0000 (21:10 +0200)
committerStefano Rivera <stefano@rivera.za.net>
Mon, 12 May 2014 19:10:02 +0000 (21:10 +0200)
naja/widgets/game_bits.py

index 973c2b80f20abd80f524d002554b173995977088..de6c6be04608abc7cd5992ef3fafa777e7de6be8 100644 (file)
@@ -20,19 +20,20 @@ class GameBitsWidget(Widget):
 
     def prepare(self):
         self.surface = pygame.Surface(BIT_SIZE)
+
         health = self.state.gameboard.health
+        max_health = self.state.gameboard.max_health
         wins = self.state.gameboard.wins
+        wins_required = self.state.gameboard.wins_required
 
         bits = []
-        bits.extend(
-            (i < health, 'health', (EIGHT_BIT,)) for i in range(4))
-        bits.extend(
-            (i < wins, 'win', (EIGHT_BIT,)) for i in range(4))
+        bits.extend((i < health, 'health') for i in range(max_health))
+        bits.extend((i < wins, 'win') for i in range(wins_required))
 
-        for pos, (is_set, image, transforms) in enumerate(bits):
+        for pos, (is_set, image) in enumerate(bits):
             img = resources.get_image(
                 'bits', '%s_%s.png' % (image, 'on' if is_set else 'off'),
-                transforms=transforms)
+                transforms=(EIGHT_BIT,))
             self.surface.blit(img, (img.get_width() * pos, 0))
 
     def draw(self, surface):