X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=new%2Fplomrogue%2Ftasks.py;h=6d67c35b1b088b0bf5b617525530668d8c1acbac;hb=97049163acc0844e1656df3f761c9ca612afdeb0;hp=ae559800f5f931769f6861cae5a652a8ffd6987b;hpb=3b7db36664e8989b106d8975d7a115e8a872b473;p=plomrogue2-experiments diff --git a/new/plomrogue/tasks.py b/new/plomrogue/tasks.py index ae55980..6d67c35 100644 --- a/new/plomrogue/tasks.py +++ b/new/plomrogue/tasks.py @@ -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,11 +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]) - 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()