예제 #1
0
        /// <summary>
        /// DeSerialize the Side object from XML String
        /// </summary>
        /// <returns>XML containing the Side object state XML</returns>
        public void XmlDeserialize(XmlNode xmlCells)
        {
            // Serialize and append to the side object
            XmlNode cellXml = xmlCells.FirstChild;

            // Serialize and append every cell of this board back to chess cells
            for (int row = 1; row <= 8; row++)
            {
                for (int col = 1; col <= 8; col++)
                {
                    Cell cell = (Cell)XMLHelper.XmlDeserialize(typeof(Cell), cellXml.OuterXml);
                    m_Cells[GetKey(row, col)] = cell;

                    // Get the next node XML
                    cellXml = cellXml.NextSibling;
                }
            }
        }
예제 #2
0
파일: Game.cs 프로젝트: GCourtney27/CSChess
        /// <summary>
        /// DeSerialize the Game object from XML String
        /// </summary>
        /// <returns>XML containing the Game object state XML</returns>
        public void XmlDeserialize(XmlNode xmlGame)
        {
            // If this source file doesn't contain the check sum attribut, return back
            if (xmlGame.Attributes["Checksum"] == null)
            {
                return;
            }

            // Read game state attributes
            DoNullMovePruning    = (XMLHelper.GetNodeText(xmlGame, "DoNullMovePruning") == "True");
            DoPrincipleVariation = (XMLHelper.GetNodeText(xmlGame, "DoPrincipleVariation") == "True");
            DoQuiescentSearch    = (XMLHelper.GetNodeText(xmlGame, "DoQuiescentSearch") == "True");

            // Restore the Game turn info
            GameTurn = (XMLHelper.GetNodeText(xmlGame, "DoQuiescentSearch") == "Black") ? Side.SideType.Black : Side.SideType.White;

            // Restore the Board State
            XmlNode xmlBoard = XMLHelper.GetFirstNodeByName(xmlGame, "Board");

            Board.XmlDeserialize(xmlBoard);

            // Restore the Player info
            XmlNode xmlPlayer = XMLHelper.GetFirstNodeByName(xmlGame, "WhitePlayer");

            m_WhitePlayer           = (Player)XMLHelper.XmlDeserialize(typeof(Player), xmlPlayer.InnerXml);
            m_WhitePlayer.GameRules = m_Rules;

            xmlPlayer               = XMLHelper.GetFirstNodeByName(xmlGame, "BlackPlayer");
            m_BlackPlayer           = (Player)XMLHelper.XmlDeserialize(typeof(Player), xmlPlayer.InnerXml);
            m_BlackPlayer.GameRules = m_Rules;

            // Restore all the moves for the move history
            XmlNode xmlMoves = XMLHelper.GetFirstNodeByName(xmlGame, "MovesHistory");

            foreach (XmlNode xmlMove in xmlMoves.ChildNodes)
            {
                Move move = (Move)XMLHelper.XmlDeserialize(typeof(Move), xmlMove.OuterXml);
                m_MovesHistory.Push(move);
            }
        }
예제 #3
0
파일: Side.cs 프로젝트: Deathblade226/Chess
 /// <summary>
 /// DeSerialize the Side object from XML String
 /// </summary>
 /// <returns>XML containing the Side object state XML</returns>
 public void XmlDeserialize(XmlNode xmlSide)
 {
     // Serialize and append to the side object
     m_side = (SideType)XMLHelper.XmlDeserialize(typeof(SideType), xmlSide.InnerXml);
 }