Make games rejoinable again! #14

Merged
marco merged 4 commits from make-games-rejoinable-again into master 2024-05-19 12:44:57 +00:00
3 changed files with 5 additions and 4 deletions
Showing only changes of commit 90dca37d44 - Show all commits

View File

@ -58,6 +58,7 @@ func GetLobbyForPassphraseHandler(c *gin.Context) {
ID: &lobby.Uuid, ID: &lobby.Uuid,
} }
c.Header("Access-Control-Allow-Origin", "*")
c.IndentedJSON(http.StatusOK, lobbyInfo) c.IndentedJSON(http.StatusOK, lobbyInfo)
} }
@ -84,6 +85,7 @@ func JoinPrivateGame(c *gin.Context) {
_, found = lobby.GetPlayerByUUID(*req.PlayerID) _, found = lobby.GetPlayerByUUID(*req.PlayerID)
} }
if found { if found {
c.Header("Access-Control-Allow-Origin", "*")
c.IndentedJSON( c.IndentedJSON(
http.StatusOK, http.StatusOK,
api.PlayerInfo{ api.PlayerInfo{

View File

@ -220,5 +220,5 @@ func (game *Game) playerDisconnected(p *Player) {
} }
func (game *Game) SetWebsocketConnectionFor(ctx context.Context, p *Player, ws *gorillaws.Conn) { func (game *Game) SetWebsocketConnectionFor(ctx context.Context, p *Player, ws *gorillaws.Conn) {
p.SetWebsocketConnectionAndSendBoardState(ctx, ws, game.board.PGN(), game.board.colorToMove) p.SetWebsocketConnectionAndSendBoardState(ctx, ws, &game.board)
} }

View File

@ -41,11 +41,10 @@ func (p *Player) SetWebsocketConnection(ctx context.Context, ws *gorillaws.Conn)
func (p *Player) SetWebsocketConnectionAndSendBoardState( func (p *Player) SetWebsocketConnectionAndSendBoardState(
ctx context.Context, ctx context.Context,
ws *gorillaws.Conn, ws *gorillaws.Conn,
boardPosition string, board *Board,
turnColor types.ChessColor,
) { ) {
p.SetWebsocketConnection(ctx, ws) p.SetWebsocketConnection(ctx, ws)
p.SendBoardState(types.Move{}, boardPosition, turnColor) p.SendBoardState(board.getLastMove(), board.PGN(), board.colorToMove)
} }
func (p *Player) SetColor(color types.ChessColor) { func (p *Player) SetColor(color types.ChessColor) {