home · contact · privacy
Allow player movement beyond central map. Lots of mapping rewrite.
[plomrogue2-experiments] / new / plomrogue / tasks.py
index 330eff9b158e41357adbaa91bc207087af0d13c0..6d67c35b1b088b0bf5b617525530668d8c1acbac 100644 (file)
@@ -1,5 +1,6 @@
 from plomrogue.errors import GameError
 from plomrogue.misc import quote
+from plomrogue.mapping import YX
 
 
 
@@ -37,12 +38,13 @@ class Task_WAIT(Task):
 class Task_MOVE(Task):
     argtypes = 'string:direction'
 
+    def get_move_target(self):
+        return self.thing.world.game.map_geometry.move(self.thing.position,
+                                                       self.args[0],
+                                                       self.thing.world.game.map_size)
+
     def check(self):
-        test_pos = ((0,0),
-                    self.thing.world.maps[(0,0)].
-                    move(self.thing.position[1], self.args[0]))
-        if test_pos == ((0,0), None):
-            raise GameError('would move outside map bounds')
+        test_pos = self.get_move_target()
         if self.thing.world.maps[test_pos[0]][test_pos[1]] != '.':
             raise GameError('%s would move into illegal terrain' % self.thing.id_)
         for t in self.thing.world.things_at_pos(test_pos):
@@ -50,8 +52,7 @@ class Task_MOVE(Task):
                 raise GameError('%s would move into other thing' % self.thing.id_)
 
     def do(self):
-        self.thing.position = (0,0), self.thing.world.maps[(0,0)].\
-                                     move(self.thing.position[1], self.args[0])
+        self.thing.position = self.get_move_target()