WS send game state
This commit is contained in:
@ -18,14 +18,14 @@ from hopper.api.dto import (
|
||||
from hopper.engine import GameEngine
|
||||
from hopper.enums import Direction, PlayerMoveResult
|
||||
from hopper.errors import Collision, PositionOutOfBounds
|
||||
from hopper.ws_client import send_game_state
|
||||
from hopper.ws_client import ws_send_game_state
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/ping", response_model=PingResponse)
|
||||
async def ping() -> PingResponse:
|
||||
await send_game_state()
|
||||
await ws_send_game_state()
|
||||
return PingResponse(
|
||||
message="Pong!",
|
||||
)
|
||||
@ -48,7 +48,7 @@ async def start_game(
|
||||
body: StartGameRequestDto,
|
||||
engine: GameEngine = Depends(get_game_engine),
|
||||
) -> StartGameResponseDto:
|
||||
new_player = engine.start_game(player_name=body.player_name)
|
||||
new_player = await engine.start_game(player_name=body.player_name)
|
||||
|
||||
return StartGameResponseDto(
|
||||
board=engine.board,
|
||||
@ -118,7 +118,7 @@ async def move_player(
|
||||
)
|
||||
|
||||
try:
|
||||
move_result = engine.move_player(player, direction)
|
||||
move_result = await engine.move_player(player, direction)
|
||||
except PositionOutOfBounds:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT, detail="Position out of bounds"
|
||||
|
||||
Reference in New Issue
Block a user