diff --git a/nakama/go-modules/main.go b/nakama/go-modules/main.go index 3cc8799..4b5bc5a 100644 --- a/nakama/go-modules/main.go +++ b/nakama/go-modules/main.go @@ -736,8 +736,8 @@ func validateChessMove(fenStr, from, to, promotion string) MoveResult { game := chess.NewGame(fen) - // Find the move in valid moves - found := false + // Find and execute the move + var validMove *chess.Move for _, move := range game.ValidMoves() { if move.S1().String() == from && move.S2().String() == to { // Check promotion @@ -748,21 +748,17 @@ func validateChessMove(fenStr, from, to, promotion string) MoveResult { continue } } - found = true + validMove = &move break } } - if !found { + if validMove == nil { return result } - // Make the move using MoveStr (UCI format) - moveStr := from + to - if promotion != "" { - moveStr += promotion - } - if err := game.MoveStr(moveStr); err != nil { + // Make the move + if err := game.Move(validMove); err != nil { return result }