home · contact · privacy
Add FLATTEN_SURROUNDINGS task.
[plomrogue2-experiments] / new2 / plomrogue / tasks.py
index a75352625fba3ee7042091de2fa88874caf57296..0fe68791d9ee779df2f6160a8f85bc0f2ade9dcf 100644 (file)
@@ -25,6 +25,7 @@ class Task_WAIT(Task):
 
 
 class Task_MOVE(Task):
+    todo = 1
     argtypes = 'string:direction'
 
     def get_move_target(self):
@@ -33,8 +34,36 @@ class Task_MOVE(Task):
 
     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: 
+        if test_pos is None:
             raise GameError('would move out of map')
+        elif self.thing.game.map[test_pos] != '.':
+            raise GameError('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] = '.'