Implement game bits.
authorSimon Cross <hodgestar@gmail.com>
Sun, 11 May 2014 21:59:19 +0000 (23:59 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 11 May 2014 22:01:48 +0000 (00:01 +0200)
naja/widgets/game_bits.py

index 78f1ab91f488ef7ff275e7041ded574bc933f808..a5dbeae604c0a576faba7d87d71286b829eda92a 100644 (file)
@@ -19,18 +19,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', ()) for i in range(4))
+        bits.extend(
+            (i < wins, 'win', ()) 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)