home · contact · privacy
Give feedback on aborted tasks.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 6 Jan 2019 18:51:38 +0000 (19:51 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 6 Jan 2019 18:51:38 +0000 (19:51 +0100)
server.py
server_/game.py

index 5847a5439982ecaa02f1673e0cceed948afd75c1..7e2d80dc67b2d2f8cd5f1f332b1755588a1cdf8f 100755 (executable)
--- a/server.py
+++ b/server.py
@@ -180,6 +180,8 @@ class CommandHandler(game_common.Commander, server_.game.Commander):
         """
         self.send_all('TURN_FINISHED ' + str(self.world.turn))
         self.world.proceed_to_next_player_turn()
+        msg = str(self.world.get_player().last_task_result)
+        self.send_all('LAST_PLAYER_TASK_RESULT ' + msg)
         self.send_all_gamestate()
 
     def cmd_FIB(self, numbers, connection_id):
index 974de92866979b25b0031a9c62969e6fdbc7ffa2..878917fbda7711a741c53a981737be741942ffda 100644 (file)
@@ -1,6 +1,7 @@
 import sys
 sys.path.append('../')
 import game_common
+import parser
 
 
 class GameError(Exception):
@@ -60,7 +61,7 @@ class Task:
         self.thing = thing
         self.args = args
         self.kwargs = kwargs
-        self.todo = 1
+        self.todo = 3
 
     def check(self):
         if self.name == 'move':
@@ -85,12 +86,14 @@ class Thing(game_common.Thing):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
         self.task = Task(self, 'wait')
+        self.last_task_result = None
 
     def task_wait(self):
-        pass
+        return 'success'
 
     def task_move(self, direction):
         move_pos(direction, self.position)
+        return 'success'
 
     def decide_task(self):
         if self.position[1] > 1:
@@ -116,15 +119,16 @@ class Thing(game_common.Thing):
         """
         try:
             self.task.check()
-        except GameError:
+        except GameError as e:
             self.task = None
+            self.last_task_result = e
             if is_AI:
                 self.decide_task()
             return
         self.task.todo -= 1
         if self.task.todo <= 0:
             task = getattr(self, 'task_' + self.task.name)
-            task(*self.task.args, **self.task.kwargs)
+            self.last_task_result = task(*self.task.args, **self.task.kwargs)
             self.task = None
         if is_AI and self.task is None:
             self.decide_task()