Only display claim draw dialog if game has started

We should also probably decide whether the game has started before
scheduling the timeout, since that's a 100ms window for everything to
break, otherwise.

Fixes #22
This commit is contained in:
Michael Catanzaro 2018-07-27 16:21:13 -05:00
parent ea79e9471f
commit 9b892882b1

View file

@ -1124,15 +1124,16 @@ Copyright © 20152016 Sahil Sareen""";
/* Remaining work goes in a timeout to give the game widget a chance to
* redraw first, so the pieces are shown to move before displaying the
* claim draw dialog. */
var started = !starting && game.is_started;
Timeout.add(100, () => {
if (game.can_claim_draw ())
if (game.can_claim_draw () && started)
present_claim_draw_dialog ();
if (opponent_engine != null)
{
opponent_engine.report_move (move);
if (move.piece.color != opponent.color && !starting && game.is_started)
if (move.piece.color != opponent.color && started)
opponent_engine.move ();
}