home · contact · privacy
Allow player movement beyond central map. Lots of mapping rewrite.
[plomrogue2-experiments] / new / plomrogue / tasks.py
index c9ce45ed654f1aff64848c65f6b43167db3037c7..6d67c35b1b088b0bf5b617525530668d8c1acbac 100644 (file)
@@ -1,5 +1,6 @@
 from plomrogue.errors import GameError
 from plomrogue.misc import quote
+from plomrogue.mapping import YX
 
 
 
@@ -19,6 +20,8 @@ class Task:
         for arg in self.args:
             if type(arg) == str:
                 stringed_args += [quote(arg)]
+            elif type(arg) == int:
+                stringed_args += [str(arg)]
             else:
                 raise GameError('stringifying arg type not implemented')
         return ' '.join(stringed_args)
@@ -35,22 +38,21 @@ 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 = self.thing.world.map_.move(self.thing.position, self.args[0])
-        if test_pos is None:
-            raise GameError('would move outside map bounds')
-        if self.thing.world.map_[test_pos] != '.':
+        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:
-            if t.blocking and t.position == test_pos:
+        for t in self.thing.world.things_at_pos(test_pos):
+            if t.blocking:
                 raise GameError('%s would move into other thing' % self.thing.id_)
 
     def do(self):
-        self.thing.position = self.thing.world.map_.move(self.thing.position,
-                                                         self.args[0])
-        for id_ in self.thing.inventory:
-            t = self.thing.world.get_thing(id_)
-            t.position = self.thing.position
+        self.thing.position = self.get_move_target()