home · contact · privacy
Add TASK:DOOR error message on absence of adjacent door.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 16 Dec 2020 19:33:55 +0000 (20:33 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 16 Dec 2020 19:33:55 +0000 (20:33 +0100)
plomrogue/tasks.py

index fced65036f94fa122afd07b9d634a76931c6535a..4cf8700b1f5b93473fabb70c3acedf471167667d 100644 (file)
@@ -187,6 +187,13 @@ class Task_DROP(Task):
 
 class Task_DOOR(Task):
 
 
 class Task_DOOR(Task):
 
+    def check(self):
+        action_radius = list(self.thing.game.map_geometry.
+                             get_neighbors_yxyx(self.thing.position).values())
+        if len([t for t in self.thing.game.things if
+                  t.type_ == 'Door' and t.position in action_radius]) == 0:
+            raise PlayError('not standing next to a door to open/close')
+
     def do(self):
         action_radius = list(self.thing.game.map_geometry.
                              get_neighbors_yxyx(self.thing.position).values())
     def do(self):
         action_radius = list(self.thing.game.map_geometry.
                              get_neighbors_yxyx(self.thing.position).values())