This commit is contained in:
parent
7916294943
commit
c13210e5ed
2 changed files with 11 additions and 7 deletions
|
|
@ -4,5 +4,5 @@ go 1.22
|
|||
|
||||
require (
|
||||
github.com/heroiclabs/nakama-common v1.44.0
|
||||
github.com/corentings/chess/v2 v2.0.1
|
||||
github.com/corentings/chess/v2 v2.3.3
|
||||
)
|
||||
|
|
|
|||
|
|
@ -736,8 +736,8 @@ func validateChessMove(fenStr, from, to, promotion string) MoveResult {
|
|||
|
||||
game := chess.NewGame(fen)
|
||||
|
||||
// Find the move and get its algebraic notation
|
||||
var algebraicMove string
|
||||
// Verify move is valid first
|
||||
found := false
|
||||
for _, move := range game.ValidMoves() {
|
||||
if move.S1().String() == from && move.S2().String() == to {
|
||||
// Check promotion
|
||||
|
|
@ -748,17 +748,21 @@ func validateChessMove(fenStr, from, to, promotion string) MoveResult {
|
|||
continue
|
||||
}
|
||||
}
|
||||
algebraicMove = move.String()
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if algebraicMove == "" {
|
||||
if !found {
|
||||
return result
|
||||
}
|
||||
|
||||
// Make the move using algebraic notation
|
||||
if err := game.PushMove(algebraicMove); err != nil {
|
||||
// Make the move using UCI notation (e.g., "e2e4" or "e7e8q")
|
||||
uciMove := from + to
|
||||
if promotion != "" {
|
||||
uciMove += promotion
|
||||
}
|
||||
if err := game.PushNotationMove(uciMove, chess.UCINotation{}, nil); err != nil {
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue