projects
/
koperkapel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f1955c8
)
smartness now required for keypads
author
adrianna
<adrianna.pinska@gmail.com>
Sat, 5 Mar 2016 22:46:57 +0000
(
00:46
+0200)
committer
adrianna
<adrianna.pinska@gmail.com>
Sat, 5 Mar 2016 22:47:11 +0000
(
00:47
+0200)
koperkapel/gamelib/keypad.py
patch
|
blob
|
history
koperkapel/gamelib/level.py
patch
|
blob
|
history
koperkapel/levels/level1.json
patch
|
blob
|
history
koperkapel/loaders/levelloader.py
patch
|
blob
|
history
koperkapel/scenes/level.py
patch
|
blob
|
history
diff --git
a/koperkapel/gamelib/keypad.py
b/koperkapel/gamelib/keypad.py
index b328f3965e54b3af1ed0b4997ae5bd739c246f3a..bf9e084e0d23319d841a27088656f72b34ff4cb9 100644
(file)
--- a/
koperkapel/gamelib/keypad.py
+++ b/
koperkapel/gamelib/keypad.py
@@
-8,16
+8,19
@@
from ..constants import TILE_SIZE
class Keypad(SurfActor):
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._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))
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 cfbf45e1118c824f63cddac3294a09c9283419f0..7641fbcd3de7b29ded0b1ad631c43eab74b16470 100644
(file)
--- a/
koperkapel/gamelib/level.py
+++ b/
koperkapel/gamelib/level.py
@@
-65,10
+65,10
@@
class Level(object):
return True
return False
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:
for keypad in self.keypads:
if (x, y) == keypad.game_pos:
- keypad.activate(
roaches
)
+ keypad.activate(
smart
)
def get_friends(self):
return self._friends[:]
def get_friends(self):
return self._friends[:]
diff --git
a/koperkapel/levels/level1.json
b/koperkapel/levels/level1.json
index f5e920af4e66575109a43159359697375cb91ad6..7fad44fe3271e528f7a44536206b3fd9c0561e1c 100644
(file)
--- a/
koperkapel/levels/level1.json
+++ b/
koperkapel/levels/level1.json
@@
-4291,7
+4291,8
@@
"keypads": [
[
6,
"keypads": [
[
6,
- 7
+ 7,
+ 0
]
],
"doors": [
]
],
"doors": [
@@
-4305,7
+4306,8
@@
"keypads": [
[
5,
"keypads": [
[
5,
- 12
+ 12,
+ 0
]
],
"doors": [
]
],
"doors": [
@@
-4323,7
+4325,8
@@
"keypads": [
[
18,
"keypads": [
[
18,
- 9
+ 9,
+ 1
]
],
"doors": [
]
],
"doors": [
diff --git
a/koperkapel/loaders/levelloader.py
b/koperkapel/loaders/levelloader.py
index 14db3bee5419de099d785e50d87fbbc7db72783c..9c3b6cfc19fc57c31af97b1c4337bb016131d7f8 100644
(file)
--- 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']:
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.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 54041baa7cc20e863e0c0457ba8a9cbe70a77b47..ca85884b75a2ccb0e4cbd3aec0494faf5ee4fff1 100644
(file)
--- 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_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)
elif self._level.friend_at(x, y):
friend = self._level.friend_at(x, y)
self._level.remove_friend(friend)