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)
|
game := chess.NewGame(fen)
|
||||||
|
|
||||||
// Find the move in valid moves
|
// Find and execute the move
|
||||||
found := false
|
var validMove *chess.Move
|
||||||
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,21 +748,17 @@ func validateChessMove(fenStr, from, to, promotion string) MoveResult {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
found = true
|
validMove = &move
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
if validMove == nil {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the move using MoveStr (UCI format)
|
// Make the move
|
||||||
moveStr := from + to
|
if err := game.Move(validMove); err != nil {
|
||||||
if promotion != "" {
|
|
||||||
moveStr += promotion
|
|
||||||
}
|
|
||||||
if err := game.MoveStr(moveStr); err != nil {
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue