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 (
|
require (
|
||||||
github.com/heroiclabs/nakama-common v1.44.0
|
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)
|
game := chess.NewGame(fen)
|
||||||
|
|
||||||
// Find the move and get its algebraic notation
|
// Verify move is valid first
|
||||||
var algebraicMove string
|
found := false
|
||||||
for _, move := range game.ValidMoves() {
|
for _, move := range game.ValidMoves() {
|
||||||
if move.S1().String() == from && move.S2().String() == to {
|
if move.S1().String() == from && move.S2().String() == to {
|
||||||
// Check promotion
|
// Check promotion
|
||||||
|
|
@ -748,17 +748,21 @@ func validateChessMove(fenStr, from, to, promotion string) MoveResult {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
algebraicMove = move.String()
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if algebraicMove == "" {
|
if !found {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the move using algebraic notation
|
// Make the move using UCI notation (e.g., "e2e4" or "e7e8q")
|
||||||
if err := game.PushMove(algebraicMove); err != nil {
|
uciMove := from + to
|
||||||
|
if promotion != "" {
|
||||||
|
uciMove += promotion
|
||||||
|
}
|
||||||
|
if err := game.PushNotationMove(uciMove, chess.UCINotation{}, nil); err != nil {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue