[gnome-mahjongg] Style fixups
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mahjongg] Style fixups
- Date: Fri, 29 Aug 2014 13:13:21 +0000 (UTC)
commit d800995a9f8f812274490af6f7991466dab39810
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Aug 29 08:13:11 2014 -0500
Style fixups
src/game.vala | 39 ++++++++++++++++++++++-----------------
1 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index 2e0c61b..6822415 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -189,22 +189,25 @@ public class Game : Object
reset ();
}
- public void shuffle_remaining (bool redraw = true) {
+ public void shuffle_remaining (bool redraw = true)
+ {
// Fisher Yates Shuffle
- var n = tiles.length();
- do {
- for (var i = n-1; i > 0; i--) {
- int j = Random.int_range(0,(int)i+1);
- // switch internal positions
- switch_tiles (tiles.nth_data(j), tiles.nth_data(i));
- }
- // resort for drawing order
- tiles.sort(compare_tiles);
- // reset moves and move numbers
- move_number = 1;
- foreach (var tile in tiles)
- tile.move_number = 0;
- find_matches ();
+ var n = tiles.length ();
+ do
+ {
+ for (var i = n-1; i > 0; i--)
+ {
+ int j = Random.int_range (0, (int) i+1);
+ // switch internal positions
+ switch_tiles (tiles.nth_data (j), tiles.nth_data (i));
+ }
+ // resort for drawing order
+ tiles.sort (compare_tiles);
+ // reset moves and move numbers
+ move_number = 1;
+ foreach (var tile in tiles)
+ tile.move_number = 0;
+ find_matches ();
} while (!can_move && visible_tiles > 1);
// only continue shuffling when there is a possible pairing
moved ();
@@ -212,7 +215,8 @@ public class Game : Object
redraw_all_tiles ();
}
- public void redraw_all_tiles () {
+ public void redraw_all_tiles ()
+ {
foreach (var tile in tiles)
if (tile.visible)
redraw_tile (tile);
@@ -351,7 +355,8 @@ public class Game : Object
return true;
}
- public int number_of_movable_tiles () {
+ public int number_of_movable_tiles ()
+ {
int count = 0;
foreach (var tile in tiles)
if (tile_can_move(tile))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]