Use EIGHT_BIT for game bits.
[naja.git] / naja / widgets / game_bits.py
index 78f1ab91f488ef7ff275e7041ded574bc933f808..973c2b80f20abd80f524d002554b173995977088 100644 (file)
@@ -4,8 +4,9 @@ Widget that holds the games's bits.
 
 import pygame
 
-from naja.constants import BIT_SIZE, BITS
+from naja.constants import BIT_SIZE
 from naja.resources import resources
+from naja.resources.mutators import EIGHT_BIT
 from naja.widgets.base import Widget
 
 
@@ -19,18 +20,16 @@ class GameBitsWidget(Widget):
 
     def prepare(self):
         self.surface = pygame.Surface(BIT_SIZE)
-        bits = (
-            (BITS.MSB, 'msb', ()),
-            (BITS.YELLOW, 'yellow', ()),
-            (BITS.MAGENTA, 'magenta', ()),
-            (BITS.CYAN, 'cyan', ()),
-            (BITS.WEST, 'arrow', ()),
-            (BITS.EAST, 'arrow', ()),
-            (BITS.SOUTH, 'arrow', ()),
-            (BITS.NORTH, 'arrow', ()),
-        )
-        for pos, (bit, image, transforms) in enumerate(bits):
-            is_set = self.state.player.bits.check_bit(bit)
+        health = self.state.gameboard.health
+        wins = self.state.gameboard.wins
+
+        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))
+
+        for pos, (is_set, image, transforms) in enumerate(bits):
             img = resources.get_image(
                 'bits', '%s_%s.png' % (image, 'on' if is_set else 'off'),
                 transforms=transforms)