[gnome-mahjongg/gnome-3-10] Flash any two matching tiles if the selected tile has no match.



commit 451d65138929e0e3b7c5a7be244b08b391a54817
Author: Mario Wenzel <maweki gmail com>
Date:   Wed Jan 8 20:54:01 2014 +0100

    Flash any two matching tiles if the selected tile has no match.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721248

 src/gnome-mahjongg.vala |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/src/gnome-mahjongg.vala b/src/gnome-mahjongg.vala
index 9e89ccd..1d3677e 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -481,22 +481,19 @@ public class Mahjongg : Gtk.Application
     private void hint_cb ()
     {
         var matches = game_view.game.find_matches (game_view.game.selected_tile);
-        var n_matches = matches.length ();
 
-        /* No match, just flash the selected tile */
-        if (n_matches == 0)
+        /* No match, find any random match as if nothing was selected */
+        if (matches.length () == 0)
         {
             if (game_view.game.selected_tile == null)
                 return;
-            game_view.game.set_hint (game_view.game.selected_tile, null);
-        }
-        else
-        {
-            var n = Random.int_range (0, (int) n_matches);
-            var match = matches.nth_data (n);
-            game_view.game.set_hint (match.tile0, match.tile1);
+            matches = game_view.game.find_matches ();
         }
 
+        var n = Random.int_range (0, (int) matches.length ());
+        var match = matches.nth_data (n);
+        game_view.game.set_hint (match.tile0, match.tile1);
+
         update_ui ();
     }
 


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