From: Christian Heller Date: Wed, 16 Dec 2020 19:33:55 +0000 (+0100) Subject: Add TASK:DOOR error message on absence of adjacent door. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/blog?a=commitdiff_plain;h=1101707a5518de54204fb2f856bdc540ae622991;p=plomrogue2 Add TASK:DOOR error message on absence of adjacent door. --- 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())