Commit bdf5109c authored by Arnaud B.'s avatar Arnaud B.

Fix another bug.

parent bee8a76d
Pipeline #139027 passed with stage
in 4 minutes and 28 seconds
......@@ -58,6 +58,7 @@ private class FourInARow : Gtk.Application
*/
private int [] score = { 0, 0, 0 };
private bool reset_score = true;
private uint playgame_timeout = 0;
// widgets
private Scorebox scorebox;
......@@ -294,6 +295,11 @@ private class FourInARow : Gtk.Application
internal void game_reset ()
{
stop_anim ();
if (playgame_timeout != 0)
{
Source.remove (playgame_timeout);
playgame_timeout = 0;
}
window.allow_undo (false);
window.allow_hint (false);
......@@ -339,7 +345,11 @@ private class FourInARow : Gtk.Application
if (!is_player_human ())
{
vstr [0] = vlevel [ai_level];
Timeout.add (COMPUTER_INITIAL_DELAY, () => { process_move (playgame ((string) vstr) - 1); return Source.REMOVE; });
playgame_timeout = Timeout.add (COMPUTER_INITIAL_DELAY, () => {
process_move (playgame ((string) vstr) - 1);
playgame_timeout = 0;
return Source.REMOVE;
});
}
}
......@@ -480,13 +490,14 @@ private class FourInARow : Gtk.Application
swap_player ();
if (!is_player_human ())
{
Timeout.add (COMPUTER_MOVE_DELAY, () => {
playgame_timeout = Timeout.add (COMPUTER_MOVE_DELAY, () => {
vstr [0] = vlevel [ai_level];
c = playgame ((string) vstr) - 1;
if (c < 0)
gameover = true;
var nm = new NextMove (c, this);
Timeout.add (SPEED_DROP, nm.exec);
playgame_timeout = 0;
return Source.REMOVE;
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment