From 1101707a5518de54204fb2f856bdc540ae622991 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 16 Dec 2020 20:33:55 +0100 Subject: [PATCH] Add TASK:DOOR error message on absence of adjacent door. --- plomrogue/tasks.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plomrogue/tasks.py b/plomrogue/tasks.py index fced650..4cf8700 100644 --- a/plomrogue/tasks.py +++ b/plomrogue/tasks.py @@ -187,6 +187,13 @@ class Task_DROP(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()) -- 2.30.2