smartness now required for keypads
authoradrianna <adrianna.pinska@gmail.com>
Sat, 5 Mar 2016 22:46:57 +0000 (00:46 +0200)
committeradrianna <adrianna.pinska@gmail.com>
Sat, 5 Mar 2016 22:47:11 +0000 (00:47 +0200)
koperkapel/gamelib/keypad.py
koperkapel/gamelib/level.py
koperkapel/levels/level1.json
koperkapel/loaders/levelloader.py
koperkapel/scenes/level.py

index b328f3965e54b3af1ed0b4997ae5bd739c246f3a..bf9e084e0d23319d841a27088656f72b34ff4cb9 100644 (file)
@@ -8,16 +8,19 @@ 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, anchor=(0, 0))
 
-    def activate(self, roaches):
-        # FIXME: Check stats
-        for door in self._doors:
-            if door.is_closed():
-                door.open()
-            else:
-                door.close()
+    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.")
index cfbf45e1118c824f63cddac3294a09c9283419f0..7641fbcd3de7b29ded0b1ad631c43eab74b16470 100644 (file)
@@ -65,10 +65,10 @@ class Level(object):
             return True
         return False
 
-    def press_keypad(self, x, y, roaches):
+    def press_keypad(self, x, y, smart):
         for keypad in self.keypads:
             if (x, y) == keypad.game_pos:
-                keypad.activate(roaches)
+                keypad.activate(smart)
 
     def get_friends(self):
         return self._friends[:]
index f5e920af4e66575109a43159359697375cb91ad6..7fad44fe3271e528f7a44536206b3fd9c0561e1c 100644 (file)
          "keypads": [
             [
                6,
-               7
+               7,
+               0
             ]
          ],
          "doors": [
          "keypads": [
             [
                5,
-               12
+               12,
+               0
             ]
          ],
          "doors": [
          "keypads": [
             [
                18,
-               9
+               9,
+               1
             ]
          ],
          "doors": [
index 14db3bee5419de099d785e50d87fbbc7db72783c..9c3b6cfc19fc57c31af97b1c4337bb016131d7f8 100644 (file)
@@ -65,7 +65,7 @@ class LevelLoader(ResourceLoader):
                 doors.append(new_door)
             # Add the keypads
             for keypad in door_info['keypads']:
-                new_keypad = Keypad(keypad[0], keypad[1], doors)
+                new_keypad = Keypad(keypad[0], keypad[1], doors, keypad[2])
                 self._level.keypads.append(new_keypad)
         for pos in level_data['friendly roaches']:
             roach = get_friendly_roach(pos[0], pos[1])
index 54041baa7cc20e863e0c0457ba8a9cbe70a77b47..ca85884b75a2ccb0e4cbd3aec0494faf5ee4fff1 100644 (file)
@@ -386,7 +386,7 @@ class GameLevelScene(BaseLevelScene):
                 self._level_layer = 'floor'
                 self._mode = 'walk'
         elif self._level.is_keypad(x, y):
-            self._level.press_keypad(x, y, self._roaches)
+            self._level.press_keypad(x, y, self._stats.smart)
         elif self._level.friend_at(x, y):
             friend = self._level.friend_at(x, y)
             self._level.remove_friend(friend)