home · contact · privacy
Add blink screen on trivial errors instead of log messages.
[plomrogue2-experiments] / new2 / plomrogue / game.py
index 74c79d1e2eadddc7502bd803455f6c691ad70eb5..2d71ac3e5089beec9117ad84dd20513f6d06d9bc 100755 (executable)
@@ -1,9 +1,9 @@
 from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE,
                              Task_FLATTEN_SURROUNDINGS)
-from plomrogue.errors import GameError
+from plomrogue.errors import GameError, PlayError
 from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_QUERY, cmd_PING,
                                 cmd_TURN, cmd_MAP_LINE, cmd_MAP, cmd_GET_ANNOTATION,
-                                cmd_ANNOTATE)
+                                cmd_ANNOTATE, cmd_GET_GAMESTATE)
 from plomrogue.io import GameIO
 from plomrogue.misc import quote
 from plomrogue.things import Thing, ThingPlayer 
@@ -50,6 +50,7 @@ class Game(GameBase):
                          'TURN': cmd_TURN,
                          'MAP_LINE': cmd_MAP_LINE,
                          'GET_ANNOTATION': cmd_GET_ANNOTATION,
+                         'GET_GAMESTATE': cmd_GET_GAMESTATE,
                          'ANNOTATE': cmd_ANNOTATE,
                          'MAP': cmd_MAP,
                          'PING': cmd_PING}
@@ -67,7 +68,7 @@ class Game(GameBase):
                 for i in range(len(lines)):
                     line = lines[i]
                     print("FILE INPUT LINE %5s: %s" % (i, line), end='')
-                    self.io.handle_input(line)
+                    self.io.handle_input(line, god_mode=True)
 
     def get_string_options(self, string_option_type):
         import string
@@ -108,6 +109,10 @@ class Game(GameBase):
                     for connection_id in [c_id for c_id in self.sessions
                                           if self.sessions[c_id] == t.id_]:
                         self.io.send('GAME_ERROR ' + quote(str(e)), connection_id)
+                except PlayError as e:
+                    for connection_id in [c_id for c_id in self.sessions
+                                          if self.sessions[c_id] == t.id_]:
+                        self.io.send('PLAY_ERROR ' + quote(str(e)), connection_id)
         if self.changed:
             self.turn += 1
             self.send_gamestate()