Slightly better required keys displaying (now required keys are always shown).
authorSimon Cross <hodgestar@gmail.com>
Sat, 17 May 2014 19:17:25 +0000 (21:17 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 17 May 2014 19:17:32 +0000 (21:17 +0200)
naja/widgets/info_area.py
naja/widgets/tile.py

index 34bbec746df01e9756ae092e31d1a9811922b96c..d8e77b9b8103bbbfc6df76f0672b8b8b579ac006 100644 (file)
@@ -7,7 +7,7 @@ import pygame.locals as pgl
 from naja.constants import (
     INFO_SIZE, ACT, KEYS, EXAMINE, PALETTE,
     ACTION_TEXT_OFFSET, INFO_LEFT_PADDING,
-    INFO_RIGHT_PADDING, BIT_SIZE)
+    INFO_RIGHT_PADDING, BIT_SIZE, BITS)
 from naja.events import finish_event
 from naja.resources import resources
 from naja.resources.mutators import EIGHT_BIT, blender
@@ -138,8 +138,10 @@ class InfoAreaWidget(Widget):
                               [(x_offset, y_offset), (right, y_offset),
                                (right, bottom), (x_offset, bottom)], 4)
 
-        if action.required_bits in BIT_MAP:
-            img_name = BIT_MAP[action.required_bits].replace(
+        required_keys = action.required_bits & frozenset([
+            BITS.RED, BITS.GREEN, BITS.BLUE])
+        if required_keys in BIT_MAP:
+            img_name = BIT_MAP[required_keys].replace(
                 '.png', '_small.png')
             img = resources.get_image(img_name,
                                       transforms=(EIGHT_BIT,))
index 9e8fe8508056dae9bc61a4e93ccd547c772514d9..b8985551318b5a369a90e166a33a04afaee6b517 100644 (file)
@@ -94,10 +94,12 @@ class TileWidget(Widget):
         self.surface.blit(img, (TILE_SIZE[0] - 20, 0))
 
     def _prepare_lock(self, action, y_offset):
-        if action.required_bits not in BIT_MAP:
+        required_keys = action.required_bits & frozenset([
+            BITS.RED, BITS.GREEN, BITS.BLUE])
+        if required_keys not in BIT_MAP:
             return 4
 
-        img_name = BIT_MAP[action.required_bits]
+        img_name = BIT_MAP[required_keys]
 
         if self.board_pos != self.state.player.position:
             x_offset = 0