home · contact · privacy
Keep checking tasks are possible during proceeding.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 6 Jan 2019 02:05:50 +0000 (03:05 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 6 Jan 2019 02:05:50 +0000 (03:05 +0100)
server_/game.py

index 9c264ed019584fdc6fdb009ab5434623bd0cdbdd..974de92866979b25b0031a9c62969e6fdbc7ffa2 100644 (file)
@@ -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)