smartness indicator on keypads
[koperkapel.git] / koperkapel / gamelib / keypad.py
index 4667fcde95924490158653a8cc3355a61e19a6c7..5658db4d6253a04baa3db42f298ab04037e3fdff 100644 (file)
@@ -2,19 +2,28 @@
 
 import os
 from pgzero.loaders import images
+from pgzero.ptext import getsurf
 from ..actors.orientatedsurf import SurfActor
 from ..constants import TILE_SIZE
+from ..serums import SERUM_OVERLAY_COLORS
 
 
 class Keypad(SurfActor):
 
-    def __init__(self, x, y, doors):
+    def __init__(self, x, y, doors, required_smart=0):
         self._doors = doors
         self.game_pos = (x, y)
-        surf = images.load(os.path.join('fixtures', 'keypad'))
-        super().__init__(surf, anchor=(0, 0))
+        self.required_smart = required_smart
+        surf = images.load(os.path.join('fixtures', 'keypad')).copy()
+        surf.blit(getsurf(str(required_smart), owidth=2, ocolor=SERUM_OVERLAY_COLORS["smart"], color="black"), (0, 0))
+        super().__init__(surf, anchor=(1, 1))
 
-    def activate(self):
-        # FIXME: Check stats
-        for door in self._doors:
-            door.open()
+    def activate(self, smart):
+        if smart >= self.required_smart:
+            for door in self._doors:
+                if door.is_closed():
+                    door.open()
+                else:
+                    door.close()
+        else:
+            print("You are not smart enough for this keypad.")