X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=new%2Fplomrogue%2Ftasks.py;h=3bc0f56ebf50245ee974ba68bbb8644949245118;hb=b707d9f6b6351f3cb8be13f67edfd18b1801e3d5;hp=dfd22f7d50094d3732a327e370080e1085ef81ca;hpb=0f7c3e5559d61d352ae529239e667e9da5e284fd;p=plomrogue2-experiments diff --git a/new/plomrogue/tasks.py b/new/plomrogue/tasks.py index dfd22f7..3bc0f56 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 @@ -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) @@ -36,21 +39,20 @@ class Task_MOVE(Task): argtypes = 'string:direction' def check(self): - test_pos = self.thing.world.map_.move(self.thing.position, self.args[0]) - if test_pos is None: + test_pos = (YX(0,0), + self.thing.world.maps[YX(0,0)]. + move(self.thing.position[1], self.args[0])) + if test_pos == (YX(0,0), None): raise GameError('would move outside map bounds') - if self.thing.world.map_[test_pos] != '.': + 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): 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 = YX(0,0), self.thing.world.maps[YX(0,0)].\ + move(self.thing.position[1], self.args[0])