From a0ff1bc357c32328749982b8a2c5d2970a2eeaa2 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 6 Jan 2019 03:05:50 +0100
Subject: [PATCH] Keep checking tasks are possible during proceeding.

---
 server_/game.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

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)
-- 
2.30.2