Commit 89c7e57c authored by Michael Catanzaro's avatar Michael Catanzaro

Revert "Disallow undo if only computer has moved"

This reverts commit d5eda2e4.
parent d5eda2e4
......@@ -228,20 +228,15 @@ public class Game : Object
return enemy_count;
}
public bool can_undo (int count = 1)
requires (count == 1 || count == 2)
public bool can_undo ()
{
/* Can undo one move if a move has been played */
if (count == 1)
return undo_index > 0;
else /* Can undo two moves only after the second ply; after the first ply, undo_index == 3 */
return undo_index > 3;
return undo_index > 0;
}
public void undo (int count = 1)
requires (count == 1 || count == 2)
{
if (!can_undo (count))
if (!can_undo ())
return;
for (var i = 0; i < count; i++)
......
......@@ -253,10 +253,8 @@ public class Iagno : Gtk.Application
/* Can't undo when running two computer players */
if (light_computer != null && dark_computer != null)
undo_action.set_enabled (false);
else if (light_computer != null)
undo_action.set_enabled (game.can_undo (1));
else
undo_action.set_enabled (game.can_undo (2));
undo_action.set_enabled (game.can_undo ());
if (game.current_color == Player.DARK)
{
......
......@@ -45,19 +45,6 @@ public class TestIagno : Object
assert (game.to_string ().strip () == string.joinv ("\n", board).strip ());
}
private static void test_undo_at_start ()
{
Game game = new Game ();
assert (!game.can_undo (1));
assert (!game.can_undo (2));
game.place_tile (2, 3);
assert (game.can_undo (1));
assert (!game.can_undo (2));
game.place_tile (2, 2);
assert (game.can_undo (1));
assert (game.can_undo (2));
}
private static void test_current_color_after_pass ()
{
string[] board = {"L LLLLLL",
......@@ -160,7 +147,6 @@ public class TestIagno : Object
public static int main (string[] args) {
Test.init (ref args);
Test.add_func ("/Iagno/Pass then Undo", test_undo_after_pass);
Test.add_func ("/Iagno/Undo at Start", test_undo_at_start);
Test.add_func ("/Iagno/Current Color after Pass", test_current_color_after_pass);
Test.add_func ("/Iagno/AI Search 1", test_ai_search_1);
Test.add_func ("/Iagno/AI Search 2", test_ai_search_2);
......
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