[gnome-chess/gnome-3-8] Make the computer's pieces uncontrollable



commit c96487b017596ebbc1a878d1b9e7421878b01e73
Author: Michael Catanzaro <mike catanzaro gmail com>
Date:   Sat May 11 14:54:04 2013 -0500

    Make the computer's pieces uncontrollable
    
    https://bugzilla.gnome.org/show_bug.cgi?id=665610

 src/chess-game.vala  |   10 ++++++++++
 src/chess-scene.vala |    2 +-
 src/gnome-chess.vala |    9 +++++++++
 3 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/src/chess-game.vala b/src/chess-game.vala
index 557acbc..cbbbddd 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -13,6 +13,16 @@ public class ChessPlayer : Object
     public signal bool do_resign ();
     public signal bool do_claim_draw ();
 
+    private bool _local_human = false;
+    public bool local_human
+    {
+        get { return _local_human; }
+        set
+        {
+            _local_human = value;
+        }
+    }
+
     public ChessPlayer (Color color)
     {
         this.color = color;
diff --git a/src/chess-scene.vala b/src/chess-scene.vala
index 88b5ee6..035956a 100644
--- a/src/chess-scene.vala
+++ b/src/chess-scene.vala
@@ -180,7 +180,7 @@ public class ChessScene : Object
 
     public void select_square (int file, int rank)
     {
-        if (game == null)
+        if (game == null || !game.current_player.local_human)
             return;
 
         /* Can only control when showing the current move */
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 3db29fa..71e8740 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -445,12 +445,21 @@ public class Application : Gtk.Application
             opponent = game.white;
             human_player = game.black;
             opponent_engine = get_engine (white_engine, white_level);
+            opponent.local_human = false;
+            human_player.local_human = true;
         }
         else if (black_engine != null)
         {
             opponent = game.black;
             human_player = game.white;
             opponent_engine = get_engine (black_engine, black_level);
+            opponent.local_human = false;
+            human_player.local_human = true;
+        }
+        else
+        {
+            game.black.local_human = true;
+            game.white.local_human = true;
         }
 
         if (opponent_engine != null)


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