[iagno] Add --alternative-start option.
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Add --alternative-start option.
- Date: Wed, 1 Oct 2014 17:03:27 +0000 (UTC)
commit 09e46aff6201cd64a7343e51995439cae6dbf417
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Oct 1 13:45:00 2014 +0200
Add --alternative-start option.
https://bugzilla.gnome.org/show_bug.cgi?id=737715
data/iagno.6 | 3 +++
src/game.vala | 14 +++++++-------
src/iagno.vala | 4 +++-
3 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/data/iagno.6 b/data/iagno.6
index 9d259b3..19912cb 100644
--- a/data/iagno.6
+++ b/data/iagno.6
@@ -28,6 +28,9 @@ This is done by trapping your opponent's tiles between two tiles of
your own color.
.SH OPTIONS
.TP
+.B \-\-alternative\-start
+Start the game with an alternative position.
+.TP
.B \-f, \-\-fast\-moves
Play with reduced delay before the computer moves.
.PP
diff --git a/src/game.vala b/src/game.vala
index 73712eb..c7543d7 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -87,7 +87,7 @@ public class Game : Object
* * Creation / exporting
\*/
- public Game (int tmp_size = 8)
+ public Game (bool alternative_start = false, int tmp_size = 8)
requires (tmp_size >= 4)
{
size = tmp_size;
@@ -105,9 +105,9 @@ public class Game : Object
{
/* Setup board with four tiles by default */
initial_number_of_tiles = 4;
- tiles [size / 2 - 1, size / 2 - 1] = Player.LIGHT;
+ tiles [size / 2 - 1, size / 2 - 1] = alternative_start ? Player.DARK : Player.LIGHT;
tiles [size / 2 - 1, size / 2] = Player.DARK;
- tiles [size / 2, size / 2 - 1] = Player.DARK;
+ tiles [size / 2, size / 2 - 1] = alternative_start ? Player.LIGHT : Player.DARK;
tiles [size / 2, size / 2] = Player.LIGHT;
n_current_tiles = 2;
n_opponent_tiles = 2;
@@ -117,11 +117,11 @@ public class Game : Object
/* Logical starting position for odd board */
initial_number_of_tiles = 7;
tiles [(size - 1) / 2, (size - 1) / 2] = Player.DARK;
- tiles [(size + 1) / 2, (size - 3) / 2] = Player.DARK;
- tiles [(size - 3) / 2, (size + 1) / 2] = Player.DARK;
+ tiles [(size + 1) / 2, (size - 3) / 2] = alternative_start ? Player.LIGHT : Player.DARK;
+ tiles [(size - 3) / 2, (size + 1) / 2] = alternative_start ? Player.LIGHT : Player.DARK;
tiles [(size - 1) / 2, (size - 3) / 2] = Player.LIGHT;
- tiles [(size - 3) / 2, (size - 1) / 2] = Player.LIGHT;
- tiles [(size + 1) / 2, (size - 1) / 2] = Player.LIGHT;
+ tiles [(size - 3) / 2, (size - 1) / 2] = alternative_start ? Player.DARK : Player.LIGHT;
+ tiles [(size + 1) / 2, (size - 1) / 2] = alternative_start ? Player.DARK : Player.LIGHT;
tiles [(size - 1) / 2, (size + 1) / 2] = Player.LIGHT;
n_current_tiles = 3;
n_opponent_tiles = 4;
diff --git a/src/iagno.vala b/src/iagno.vala
index 0376fd3..aa14d30 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -18,6 +18,7 @@ public class Iagno : Gtk.Application
private int window_width;
private int window_height;
private static bool fast_mode;
+ private static bool alternative_start;
private static int computer_level = 0;
private static int size = 8;
private static bool begin_with_new_game_screen = false;
@@ -57,6 +58,7 @@ public class Iagno : Gtk.Application
private static const OptionEntry[] option_entries =
{
+ { "alternative-start", 0, 0, OptionArg.NONE, ref alternative_start, N_("Start with an alternative
position"), null},
{ "fast-mode", 'f', 0, OptionArg.NONE, ref fast_mode, N_("Reduce delay before AI moves"), null},
{ "first", 0, 0, OptionArg.NONE, null, N_("Play first"), null},
{ "level", 'l', 0, OptionArg.INT, ref computer_level, N_("Set the level of the computer's AI"),
"LEVEL"},
@@ -315,7 +317,7 @@ public class Iagno : Gtk.Application
show_game_board ();
- game = new Game (size);
+ game = new Game (alternative_start, size);
game.turn_ended.connect (turn_ended_cb);
view.game = game;
view.show ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]