Fix crash when moving checker backwards

This commit is contained in:
Trevor Slocum 2024-07-25 09:41:36 -07:00
parent 3069f96568
commit 5df43b9539

12
game.go
View file

@ -425,12 +425,14 @@ ADDMOVES:
}
gameMove := gameCopy.Moves[i]
if move[0] == gameMove[1] && move[1] == gameMove[0] {
copy(gameCopy.Board, gameCopy.boardStates[i])
gameCopy.Player1.Entered = gameCopy.enteredStates[i][0]
gameCopy.Player2.Entered = gameCopy.enteredStates[i][1]
gameCopy.boardStates = gameCopy.boardStates[:i]
gameCopy.enteredStates = gameCopy.enteredStates[:i]
gameCopy.Moves = gameCopy.Moves[:i]
if !local {
copy(gameCopy.Board, gameCopy.boardStates[i])
gameCopy.Player1.Entered = gameCopy.enteredStates[i][0]
gameCopy.Player2.Entered = gameCopy.enteredStates[i][1]
gameCopy.boardStates = gameCopy.boardStates[:i]
gameCopy.enteredStates = gameCopy.enteredStates[:i]
}
continue
}
}