[iagno] Remove place().
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Remove place().
- Date: Sun, 21 Sep 2014 17:07:53 +0000 (UTC)
commit 6e874f3288cb3940f56310fcc98d998fe4cb512a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Sep 21 14:02:33 2014 +0200
Remove place().
https://bugzilla.gnome.org/show_bug.cgi?id=737078
src/game.vala | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index be5d6b7..f996b12 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -189,7 +189,15 @@ public class Game : Object
if (tiles[x, y] != Player.NONE)
return false;
- return place (x, y, color, false) > 0;
+ if (flip_tiles (x, y, 1, 0, color, false) > 0) return true;
+ if (flip_tiles (x, y, 1, 1, color, false) > 0) return true;
+ if (flip_tiles (x, y, 0, 1, color, false) > 0) return true;
+ if (flip_tiles (x, y, -1, 1, color, false) > 0) return true;
+ if (flip_tiles (x, y, -1, 0, color, false) > 0) return true;
+ if (flip_tiles (x, y, -1, -1, color, false) > 0) return true;
+ if (flip_tiles (x, y, 0, -1, color, false) > 0) return true;
+ if (flip_tiles (x, y, 1, -1, color, false) > 0) return true;
+ return false;
}
/*\
@@ -202,7 +210,16 @@ public class Game : Object
if (tiles[x, y] != Player.NONE)
return 0;
- var tiles_turned = place (x, y, current_color, true);
+ var tiles_turned = 0;
+ tiles_turned += flip_tiles (x, y, 1, 0, current_color, true);
+ tiles_turned += flip_tiles (x, y, 1, 1, current_color, true);
+ tiles_turned += flip_tiles (x, y, 0, 1, current_color, true);
+ tiles_turned += flip_tiles (x, y, -1, 1, current_color, true);
+ tiles_turned += flip_tiles (x, y, -1, 0, current_color, true);
+ tiles_turned += flip_tiles (x, y, -1, -1, current_color, true);
+ tiles_turned += flip_tiles (x, y, 0, -1, current_color, true);
+ tiles_turned += flip_tiles (x, y, 1, -1, current_color, true);
+
if (tiles_turned == 0)
return 0;
@@ -227,7 +244,7 @@ public class Game : Object
}
/*\
- * * Placing tiles
+ * * Flipping tiles
\*/
private bool is_valid_location (int x, int y)
@@ -235,20 +252,6 @@ public class Game : Object
return x >= 0 && x < size && y >= 0 && y < size;
}
- private int place (int x, int y, Player color, bool apply)
- {
- var n_flips = 0;
- n_flips += flip_tiles (x, y, 1, 0, color, apply);
- n_flips += flip_tiles (x, y, 1, 1, color, apply);
- n_flips += flip_tiles (x, y, 0, 1, color, apply);
- n_flips += flip_tiles (x, y, -1, 1, color, apply);
- n_flips += flip_tiles (x, y, -1, 0, color, apply);
- n_flips += flip_tiles (x, y, -1, -1, color, apply);
- n_flips += flip_tiles (x, y, 0, -1, color, apply);
- n_flips += flip_tiles (x, y, 1, -1, color, apply);
- return n_flips;
- }
-
private int flip_tiles (int x, int y, int x_step, int y_step, Player color, bool apply)
{
var enemy = Player.flip_color (color);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]