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:
Michael Catanzaro 2018-07-27 17:57:59 -05:00
parent f4961bd57b
commit 9bc94a14ee

View file

@ -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)