[gnome-mines/wip/theming-support] Place mines on creation instead of first clear
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mines/wip/theming-support] Place mines on creation instead of first clear
- Date: Sun, 4 Jan 2015 00:59:38 +0000 (UTC)
commit 4d0eadee71635b0a42d5fb8cca8e2b30799dc598
Author: Robert Roth <robert roth off gmail com>
Date: Sun Jan 4 01:39:33 2015 +0200
Place mines on creation instead of first clear
src/minefield.vala | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
---
diff --git a/src/minefield.vala b/src/minefield.vala
index c537e54..e4defd4 100644
--- a/src/minefield.vala
+++ b/src/minefield.vala
@@ -60,13 +60,8 @@ public class Minefield : Object
/* true if have hit a mine */
public bool exploded = false;
- /* true if have placed the mines onto the map */
- private bool placed_mines = false;
-
/* keep track of flags and cleared squares */
private uint _n_cleared = 0;
- private uint _n_flags = 0;
-
public uint n_cleared
{
get { return _n_cleared; }
@@ -78,6 +73,7 @@ public class Minefield : Object
get { return n_cleared == width * height - n_mines; }
}
+ private uint _n_flags = 0;
public uint n_flags
{
get { return _n_flags; }
@@ -140,6 +136,8 @@ public class Minefield : Object
this.width = width;
this.height = height;
this.n_mines = n_mines;
+
+ place_mines (width - 1, height - 1);
}
public bool is_clock_started ()
@@ -168,11 +166,6 @@ public class Minefield : Object
start_clock ();
/* Place mines on first attempt to clear */
- if (!placed_mines)
- {
- place_mines (x, y);
- placed_mines = true;
- }
if (locations[x, y].cleared || locations[x, y].flag == FlagType.FLAG)
return;
@@ -296,7 +289,7 @@ public class Minefield : Object
}
/* Randomly set the mines, but avoid the current and adjacent locations */
- private void place_mines (uint x, uint y)
+ protected void place_mines (uint x, uint y)
{
for (var n = 0; n < n_mines;)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]