[iagno/gnome-3-12] Revert "Disallow undo if only computer has moved"



commit 89c7e57cb1058b895de496c81d617b2fd47fac0d
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Aug 16 17:12:32 2014 -0500

    Revert "Disallow undo if only computer has moved"
    
    This reverts commit d5eda2e4447352612f4632df25b0b29c52151ba6.

 src/game.vala       |   11 +++--------
 src/iagno.vala      |    4 +---
 src/test-iagno.vala |   14 --------------
 3 files changed, 4 insertions(+), 25 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index 5f58f07..153e7f0 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -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++)
diff --git a/src/iagno.vala b/src/iagno.vala
index eb631a7..fe5b076 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -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)
         {
diff --git a/src/test-iagno.vala b/src/test-iagno.vala
index f625869..f1c79c0 100644
--- a/src/test-iagno.vala
+++ b/src/test-iagno.vala
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]