From: adrianna Date: Sat, 5 Mar 2016 22:46:57 +0000 (+0200) Subject: smartness now required for keypads X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;ds=sidebyside;h=92591cd60f6346d318735b9a1adf778b57177917;hp=f1955c8e7345b183c12682caa9daac0741d52af1;p=koperkapel.git smartness now required for keypads --- diff --git a/koperkapel/gamelib/keypad.py b/koperkapel/gamelib/keypad.py index b328f39..bf9e084 100644 --- a/koperkapel/gamelib/keypad.py +++ b/koperkapel/gamelib/keypad.py @@ -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.") diff --git a/koperkapel/gamelib/level.py b/koperkapel/gamelib/level.py index cfbf45e..7641fbc 100644 --- a/koperkapel/gamelib/level.py +++ b/koperkapel/gamelib/level.py @@ -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[:] diff --git a/koperkapel/levels/level1.json b/koperkapel/levels/level1.json index f5e920a..7fad44f 100644 --- a/koperkapel/levels/level1.json +++ b/koperkapel/levels/level1.json @@ -4291,7 +4291,8 @@ "keypads": [ [ 6, - 7 + 7, + 0 ] ], "doors": [ @@ -4305,7 +4306,8 @@ "keypads": [ [ 5, - 12 + 12, + 0 ] ], "doors": [ @@ -4323,7 +4325,8 @@ "keypads": [ [ 18, - 9 + 9, + 1 ] ], "doors": [ diff --git a/koperkapel/loaders/levelloader.py b/koperkapel/loaders/levelloader.py index 14db3be..9c3b6cf 100644 --- a/koperkapel/loaders/levelloader.py +++ b/koperkapel/loaders/levelloader.py @@ -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]) diff --git a/koperkapel/scenes/level.py b/koperkapel/scenes/level.py index 54041ba..ca85884 100644 --- a/koperkapel/scenes/level.py +++ b/koperkapel/scenes/level.py @@ -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)