home · contact · privacy
Add blink screen on trivial errors instead of log messages.
[plomrogue2-experiments] / new2 / plomrogue / tasks.py
index 01084166635e6fba149f2763ed3b7a1ac182f6a3..bb78b98699a84ac507699074de4d45dd37237fbd 100644 (file)
@@ -1,4 +1,4 @@
-from plomrogue.errors import GameError
+from plomrogue.errors import PlayError
 from plomrogue.mapping import YX
 
 
@@ -25,6 +25,7 @@ class Task_WAIT(Task):
 
 
 class Task_MOVE(Task):
+    todo = 1
     argtypes = 'string:direction'
 
     def get_move_target(self):
@@ -34,7 +35,35 @@ class Task_MOVE(Task):
     def check(self):
         test_pos = self.get_move_target()
         if test_pos is None:
-            raise GameError('would move out of map')
+            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] = '.'