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



commit cd1bc4c2d65892a86ccd37a5667eadf3a2494c2b
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 2853462..611e601 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -479,22 +479,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]