[gnome-chess] Add [White/Black] AI and level properties to PGNGame, and use them



commit b0e661b1202ad4454fd0bfe3aa73fb0c4d999003
Author: Michael Catanzaro <mike catanzaro gmail com>
Date:   Sat Jun 8 17:08:45 2013 -0500

    Add [White/Black] AI and level properties to PGNGame, and use them

 src/chess-pgn.vala   |   20 ++++++++++++++++++++
 src/gnome-chess.vala |   16 ++++++++--------
 2 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/chess-pgn.vala b/src/chess-pgn.vala
index 7c81c73..4599bfb 100644
--- a/src/chess-pgn.vala
+++ b/src/chess-pgn.vala
@@ -129,6 +129,26 @@ public class PGNGame
         get { return tags.lookup ("Termination"); }
         set { tags.insert ("Termination", value); }
     }
+    public string? white_ai
+    {
+        get { return tags.lookup ("WhiteAI"); }
+        set { tags.insert ("WhiteAI", value); }
+    }
+    public string? white_level
+    {
+        get { return tags.lookup ("WhiteLevel"); }
+        set { tags.insert ("WhiteLevel", value); }
+    }
+    public string? black_ai
+    {
+        get { return tags.lookup ("BlackAI"); }
+        set { tags.insert ("BlackAI", value); }
+    }
+    public string? black_level
+    {
+        get { return tags.lookup ("BlackLevel"); }
+        set { tags.insert ("BlackLevel", value); }
+    }
 
     public PGNGame ()
     {
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 62d4cfa..f42f836 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -431,13 +431,13 @@ public class Application : Gtk.Application
         update_control_buttons ();
 
         // TODO: Could both be engines
-        var white_engine = pgn_game.tags.lookup ("WhiteAI");
-        var white_level = pgn_game.tags.lookup ("WhiteLevel");
+        var white_engine = pgn_game.white_ai;
+        var white_level = pgn_game.white_level;
         if (white_level == null)
             white_level = "normal";
 
-        var black_engine = pgn_game.tags.lookup ("BlackAI");
-        var black_level = pgn_game.tags.lookup ("BlackLevel");
+        var black_engine = pgn_game.black_ai;
+        var black_level = pgn_game.black_level;
         if (black_level == null)
             black_level = "normal";
 
@@ -1765,13 +1765,13 @@ public class Application : Gtk.Application
         {
             if (settings.get_boolean ("play-as-white"))
             {
-                pgn_game.tags.insert ("BlackAI", engine_name);
-                pgn_game.tags.insert ("BlackLevel", engine_level);
+                pgn_game.black_ai = engine_name;
+                pgn_game.black_level = engine_level;
             }
             else
             {
-                pgn_game.tags.insert ("WhiteAI", engine_name);
-                pgn_game.tags.insert ("WhiteLevel", engine_level);
+                pgn_game.white_ai = engine_name;
+                pgn_game.white_level = engine_level;
             }
         }
         start_game ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]