X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=new2%2Fplomrogue%2Ftasks.py;h=bb78b98699a84ac507699074de4d45dd37237fbd;hb=40681bd38201ef0caf64a979c97318b090f5cbc0;hp=402dfcb47c191ea86d9cc133c55813683b3f117e;hpb=33bfdaf647c6736d99aadc017ee935f3301d758a;p=plomrogue2-experiments diff --git a/new2/plomrogue/tasks.py b/new2/plomrogue/tasks.py index 402dfcb..bb78b98 100644 --- a/new2/plomrogue/tasks.py +++ b/new2/plomrogue/tasks.py @@ -1,5 +1,4 @@ -from plomrogue.errors import GameError -#from plomrogue.misc import quote +from plomrogue.errors import PlayError from plomrogue.mapping import YX @@ -26,21 +25,45 @@ class Task_WAIT(Task): class Task_MOVE(Task): + todo = 1 argtypes = 'string:direction' def get_move_target(self): - moves = { - 'UP': YX(-1, 0), - 'DOWN': YX(1, 0), - 'LEFT': YX(0, -1), - 'RIGHT': YX(0, 1), - } - return self.thing.position + moves[self.args[0]] + return self.thing.game.map_geometry.move(self.thing.position, + self.args[0]) def check(self): test_pos = self.get_move_target() - if test_pos.y < 0 or test_pos.x < 0 or test_pos.y >= 24 or test_pos.x >= 40: - raise GameError('would move out of map') + if test_pos is None: + raise PlayError('would move out of map') + elif self.thing.game.map[test_pos] != '.': + raise PlayError('would move into illegal territory') def do(self): self.thing.position = self.get_move_target() + + + +class Task_WRITE(Task): + todo = 1 + argtypes = 'string:char' + + def check(self): + pass + + def do(self): + self.thing.game.map[self.thing.position] = self.args[0] + + + +class Task_FLATTEN_SURROUNDINGS(Task): + todo = 10 + + def check(self): + pass + + def do(self): + self.thing.game.map[self.thing.position] = '.' + for yx in self.thing.game.map_geometry.get_neighbors(self.thing.position).values(): + if yx is not None: + self.thing.game.map[yx] = '.'