コード例 #1
0
 def test_to_json(self):
     game = Game()
     self.assertDictEqual(
         game.to_json(),
         {
             "whose_turn": None,
             "grid": [BoxType.empty] * Game.grid_size * Game.grid_size,
             "winner": None,
             "status": GameStatus.awaiting,
         },
     )
コード例 #2
0
async def publish_game_state(game: Game) -> None:
    payload = {"data": {"event": "game_state", "payload": game.to_json()}}
    await publish(payload, game.players)