smartness now required for keypads
[koperkapel.git] / koperkapel / gamelib / keypad.py
index 6c6d1c8cadeef2c4df1697bbdb92e0925aeb73ed..bf9e084e0d23319d841a27088656f72b34ff4cb9 100644 (file)
@@ -3,17 +3,24 @@
 import os
 from pgzero.loaders import images
 from ..actors.orientatedsurf import SurfActor
+from ..constants import TILE_SIZE
 
 
 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)
+        self.required_smart = required_smart
         surf = images.load(os.path.join('fixtures', 'keypad'))
-        super().__init__(surf)
+        super().__init__(surf, anchor=(0, 0))
 
-    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.")