[gnome-chess/chess-telepathy-networking-support-664946-communicate: 6/15] Abstract out constructor_helper and add contructor ChessState.with_players



commit 26388b9fb4211e856c172ab82bee88f7767828d5
Author: Chandni Verma <chandniverma2112 gmail com>
Date:   Mon Dec 24 17:32:08 2012 +0530

    Abstract out constructor_helper and add contructor ChessState.with_players

 src/chess-game.vala |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/chess-game.vala b/src/chess-game.vala
index 4c307be..2f0f8c9 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -301,10 +301,24 @@ public class ChessState
     {
     }
 
+    public ChessState.with_players (ChessPlayer white, ChessPlayer black, string fen)
+    {
+        players[Color.WHITE] = white;
+        players[Color.BLACK] = black;
+
+        constructor_helper (fen);
+    }
+
     public ChessState (string fen)
     {
         players[Color.WHITE] = new ChessPlayer (Color.WHITE);
         players[Color.BLACK] = new ChessPlayer (Color.BLACK);
+
+        constructor_helper (fen);
+    }
+
+    private void constructor_helper (string fen)
+    {
         for (int i = 0; i < 64; i++)
             board[i] = null;
 
@@ -386,6 +400,7 @@ public class ChessState
             number++;
 
         check_state = get_check_state (current_player);
+
     }
 
     public ChessState copy ()


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