This commit is contained in:
parent
e704a1e1c4
commit
32a19f24ea
1 changed files with 6 additions and 10 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue