summaryrefslogtreecommitdiffstats
path: root/weatbag/__init__.py
diff options
context:
space:
mode:
authorThomas Kluyver <takowl@gmail.com>2013-01-05 17:10:23 +0000
committerThomas Kluyver <takowl@gmail.com>2013-01-05 17:10:23 +0000
commit76d1149e6725ca8a59799e0c1f2112d3cbab5afb (patch)
tree33cba89268bf470722339c037731c592c6cfa1ca /weatbag/__init__.py
parentc73be5a26c11a6bc5aa6df097735452f254e15d7 (diff)
Various fixes to game core
Diffstat (limited to 'weatbag/__init__.py')
-rw-r--r--weatbag/__init__.py45
1 files changed, 24 insertions, 21 deletions
diff --git a/weatbag/__init__.py b/weatbag/__init__.py
index 7212bfa..7c39d21 100644
--- a/weatbag/__init__.py
+++ b/weatbag/__init__.py
@@ -34,7 +34,7 @@ class World:
try:
return self.tiles[key]
except KeyError:
- n,e = key
+ e,n = key
modname = 'weatbag.tiles.'
if n > 0:
modname += 'n'+str(n)
@@ -42,9 +42,9 @@ class World:
modname += 's'+str(abs(n))
if e > 0:
- modname += 'e'+str(n)
- elif n < 0:
- modname += 'w'+str(abs(n))
+ modname += 'e'+str(e)
+ elif e < 0:
+ modname += 'w'+str(abs(e))
try:
mod = import_module(modname)
@@ -60,23 +60,26 @@ def main():
player = Player(name)
world = World()
tile = world[0,0]
+ tile.describe()
while True:
- tile.describe()
- while True:
- do = action.get_action()
- if action.is_move(do):
- # check if we can leave tile
- if not getattr(tile, 'leave', lambda p,d: True)(player, do[1]):
- continue
- # move
- n,e = player.position
- dn, de = action.process_move(do[1])
- new_posn = n+dn, e+de
- try:
- tile = world[new_posn]
- except KeyError:
- print("The undergrowth in that direction is impassable. "
- "You turn back.")
+ do = action.get_action()
+ if action.is_move(do):
+ direction = do[1][0].lower()
+ # check if we can leave tile
+ if not getattr(tile, 'leave', lambda p,d: True)(player, direction):
+ continue
+ # move
+ e,n = player.position
+ de, dn = action.move_coords[direction]
+ new_posn = e+de, n+dn
+ try:
+ tile = world[new_posn]
+ except KeyError:
+ print("The undergrowth in that direction is impassable. "
+ "You turn back.")
else:
- action.handle_action(tile, player, do)
+ player.position = new_posn
+ tile.describe()
+ else:
+ action.handle_action(tile, player, do)