[iagno] Rework is_complete().
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Rework is_complete().
- Date: Sat, 20 Sep 2014 16:59:43 +0000 (UTC)
commit 8c9c48072327f21108b3ab6c91e3e4170731667e
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Sep 20 18:54:16 2014 +0200
Rework is_complete().
https://bugzilla.gnome.org/show_bug.cgi?id=737007
src/game.vala | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index db2167c..f97a29e 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -163,15 +163,20 @@ public class Game : Object
public bool is_complete ()
ensures (result || n_tiles < size * size)
{
- return !can_move (Player.LIGHT) && !can_move (Player.DARK);
+ return !can_move (null);
}
- public bool can_move (Player color)
+ public bool can_move (Player? color)
+ requires (color != Player.NONE)
{
for (var x = 0; x < size; x++)
for (var y = 0; y < size; y++)
- if (can_place (x, y, color))
+ {
+ if (color != Player.DARK && can_place (x, y, Player.LIGHT))
return true;
+ if (color != Player.LIGHT && can_place (x, y, Player.DARK))
+ return true;
+ }
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]