mirror of
https://github.com/tiyn/yeschess.git
synced 2025-04-01 14:47:44 +02:00
bugfix: threefold repitition throws nullpointer
If the threefold repitition check is called before enough moves are saved in the previous board state it throws a nullpointer. A simple null check solves the problem
This commit is contained in:
parent
91281d97a7
commit
5bee0f84d2
@ -810,6 +810,8 @@ proc isCheckmate*(game: Game, color: Color): bool =
|
||||
proc threeMoveRep(game: Game): bool =
|
||||
## Returns true if a 3-fold repitition happened on the last move of the
|
||||
## `game`.
|
||||
if game.previousBoard == []:
|
||||
return false
|
||||
var lastState = game.previousBoard[game.previousBoard.high]
|
||||
var lastCastleRights = game.previousCastleRights[game.previousBoard.high]
|
||||
var reps = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user