Fix wrong player sometimes winning when timer expires
Fixes #25. Thanks to Alessandro Bruni for investigating and proposing the original version of this patch.
This commit is contained in:
parent
f4961bd57b
commit
9bc94a14ee
1 changed files with 4 additions and 2 deletions
|
@ -313,10 +313,12 @@ public class ChessGame : Object
|
|||
|
||||
private void clock_expired_cb (ChessClock clock)
|
||||
{
|
||||
if (current_player.color == Color.WHITE)
|
||||
if (clock.white_remaining_seconds <= 0)
|
||||
stop (ChessResult.BLACK_WON, ChessRule.TIMEOUT);
|
||||
else
|
||||
else if (clock.black_remaining_seconds <= 0)
|
||||
stop (ChessResult.WHITE_WON, ChessRule.TIMEOUT);
|
||||
else
|
||||
assert_not_reached ();
|
||||
}
|
||||
|
||||
public ChessPiece? get_piece (int rank, int file, int move_number = -1)
|
||||
|
|
Loading…
Reference in a new issue