Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/game_map.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-02-26 09:03:42 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-02-26 09:03:42 (GMT)
commit3356cbdc0fe9a643b78245eb3da9f30fbc54ad86 (patch)
tree0791fc14d0539fc9a3f3a24ffbd5c4064f2862eb /game_map.py
parentafb22b50b2040b45680473880d7ff5ff79362751 (diff)
Draw the room name in the doors
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'game_map.py')
-rw-r--r--game_map.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/game_map.py b/game_map.py
index df03c0c..383c9df 100644
--- a/game_map.py
+++ b/game_map.py
@@ -94,6 +94,20 @@ class GameMap():
else:
return ''
+ def get_door_info(self, door_name, direction):
+ if not 'doors' in self.data:
+ self.data['doors'] = {}
+ key = door_name + '_' + direction
+ if not key in self.data['doors']:
+ self.data['doors'][key] = {}
+ return self.data['doors'][key]
+
+ def set_door_info(self, door_name, direction, door_info):
+ if not 'doors' in self.data:
+ self.data['doors'] = {}
+ key = door_name + '_' + direction
+ self.data['doors'][key] = door_info
+
def get_next_coords(self, x, y, direction):
if direction == 'N':
y -= 1
@@ -267,9 +281,11 @@ class GameMap():
# Search in walls data
for wall in self.data['walls']:
if wall['position'] == [x, y, direction]:
- return 'doors' in wall and len(wall['doors']) > 0
+ if 'doors' in wall and len(wall['doors']) > 0:
+ return wall['doors']
+ else:
+ return []
# look for information in the other side of the room too.
- # (only valid for doors)
if next_room is not None:
reversed_direction = self.get_reversed_direction(direction)
x2, y2 = self.get_next_coords(x, y, direction)
@@ -277,9 +293,12 @@ class GameMap():
return []
for wall in self.data['walls']:
if wall['position'] == [x2, y2, reversed_direction]:
- return 'doors' in wall and len(wall['doors']) > 0
+ if 'doors' in wall and len(wall['doors']) > 0:
+ return wall['doors']
+ else:
+ return []
# Nothing found
- return False
+ return []
# testing