smartness now required for keypads
[koperkapel.git] / koperkapel / gamelib / keypad.py
1 # A doors / keypads set
2
3 import os
4 from pgzero.loaders import images
5 from ..actors.orientatedsurf import SurfActor
6 from ..constants import TILE_SIZE
7
8
9 class Keypad(SurfActor):
10
11     def __init__(self, x, y, doors, required_smart=0):
12         self._doors = doors
13         self.game_pos = (x, y)
14         self.required_smart = required_smart
15         surf = images.load(os.path.join('fixtures', 'keypad'))
16         super().__init__(surf, anchor=(0, 0))
17
18     def activate(self, smart):
19         if smart >= self.required_smart:
20             for door in self._doors:
21                 if door.is_closed():
22                     door.open()
23                 else:
24                     door.close()
25         else:
26             print("You are not smart enough for this keypad.")