home · contact · privacy
Only count new turns on ticks that change world state.
[plomrogue2-experiments] / new2 / plomrogue / game.py
index 81bd530d8b3cde8c12db964042dabc505468256e..82e5d181c98d3562f4bcd73b215bd714634b9813 100755 (executable)
@@ -1,6 +1,6 @@
 from plomrogue.tasks import Task_WAIT, Task_MOVE, Task_WRITE
 from plomrogue.errors import GameError
-from plomrogue.commands import cmd_ALL, cmd_LOGIN, cmd_QUERY
+from plomrogue.commands import cmd_ALL, cmd_LOGIN, cmd_QUERY, cmd_PING
 from plomrogue.io import GameIO
 from plomrogue.misc import quote
 from plomrogue.things import Thing, ThingPlayer 
@@ -41,7 +41,8 @@ class Game(GameBase):
         self.map_geometry = MapGeometrySquare(YX(24, 40))
         self.commands = {'QUERY': cmd_QUERY,
                          'ALL': cmd_ALL,
-                         'LOGIN': cmd_LOGIN}
+                         'LOGIN': cmd_LOGIN,
+                         'PING': cmd_PING}
         self.thing_type = Thing
         self.thing_types = {'player': ThingPlayer}
         self.sessions = {}
@@ -86,8 +87,8 @@ 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)
-        self.turn += 1
         if self.changed:
+            self.turn += 1
             self.send_gamestate()
             self.changed = False