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.")
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[:]
"keypads": [
[
6,
- 7
+ 7,
+ 0
]
],
"doors": [
"keypads": [
[
5,
- 12
+ 12,
+ 0
]
],
"doors": [
"keypads": [
[
18,
- 9
+ 9,
+ 1
]
],
"doors": [
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])
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)