From: Christian Heller Date: Sun, 6 Jan 2019 02:05:50 +0000 (+0100) Subject: Keep checking tasks are possible during proceeding. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7Bdb.prefix%7D%7D/unset_cookie?a=commitdiff_plain;h=a0ff1bc357c32328749982b8a2c5d2970a2eeaa2;p=plomrogue2-experiments Keep checking tasks are possible during proceeding. --- diff --git a/server_/game.py b/server_/game.py index 9c264ed..974de92 100644 --- a/server_/game.py +++ b/server_/game.py @@ -110,7 +110,17 @@ class Thing(game_common.Thing): Decrements .task.todo; if it thus falls to <= 0, enacts method whose name is 'task_' + self.task.name and sets .task = None. If is_AI, calls .decide_task to decide a self.task. + + Before doing anything, checks that task is still possible, and aborts + it otherwise (for AI things, decides a new task). """ + try: + self.task.check() + except GameError: + self.task = None + if is_AI: + self.decide_task() + return self.task.todo -= 1 if self.task.todo <= 0: task = getattr(self, 'task_' + self.task.name)