home · contact · privacy
Add SWITCH_PLAYER debugging command for switching player.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 25 Jan 2019 19:52:25 +0000 (20:52 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 25 Jan 2019 19:52:25 +0000 (20:52 +0100)
server_/game.py

index 6c283b533e7a4a088397572688cac69825e0fa27..5ba3ab23ba4a39b04267807c8c3c535e5d4f103d 100644 (file)
@@ -335,6 +335,17 @@ class Game(game_common.CommonCommandsMixin):
         self.proceed()
     cmd_MOVE.argtypes = 'string'
 
+    def cmd_SWITCH_PLAYER(self):
+        player = self.world.get_player()
+        player.set_task('wait')
+        thing_ids = [t.id_ for t in self.world.things]
+        player_index = thing_ids.index(player.id_)
+        if player_index == len(thing_ids) - 1:
+            self.world.player_id = thing_ids[0]
+        else:
+            self.world.player_id = thing_ids[player_index + 1]
+        self.proceed()
+
     def cmd_WAIT(self):
         """Set player task to 'wait', finish player turn."""
         self.world.get_player().set_task('wait')