WS send game state
This commit is contained in:
@ -3,7 +3,6 @@ from contextlib import asynccontextmanager
|
||||
|
||||
import websockets
|
||||
|
||||
from hopper.api.dependencies import get_game_engine
|
||||
from hopper.models.ws_dto import GameStateDto
|
||||
from settings import settings
|
||||
|
||||
@ -15,7 +14,10 @@ async def create_ws_client() -> websockets.WebSocketServerProtocol:
|
||||
yield websocket
|
||||
|
||||
|
||||
async def send_game_state() -> None:
|
||||
async def ws_send_game_state() -> None:
|
||||
# avoid circular imports
|
||||
from hopper.api.dependencies import get_game_engine
|
||||
|
||||
async with create_ws_client() as websocket:
|
||||
engine = get_game_engine()
|
||||
|
||||
@ -23,9 +25,6 @@ async def send_game_state() -> None:
|
||||
board=engine.board,
|
||||
destination=engine.board.destination,
|
||||
players=engine.players,
|
||||
layers=engine.board.layers,
|
||||
layers=engine.get_board_layout().layers,
|
||||
)
|
||||
|
||||
print(json.dumps(game_state.dict(), indent=4))
|
||||
|
||||
await websocket.send(json.dumps(game_state.dict()))
|
||||
|
||||
Reference in New Issue
Block a user