Beispiel #1
0
        /// <summary>Creates a duplicate Checkers piece object from an identical (possibly cloned) game.</summary>
        /// <returns>The new Checkers piece object.</returns>
        public CheckersPiece Clone(CheckersGame game)
        {
            CheckersPiece clonedPiece = game.PieceAt(Location);

            // Make sure piece exists
            if (clonedPiece == null)
            {
                return(null);
            }
            // Make sure piece is equivalent
            if ((clonedPiece.Player != Player) || (clonedPiece.InPlay != InPlay) || (clonedPiece.Rank != Rank))
            {
                return(null);
            }
            // Return cloned piece
            return(clonedPiece);
        }
 /// <summary>Creates a duplicate Checkers piece object from an identical (possibly cloned) game.</summary>
 /// <returns>The new Checkers piece object.</returns>
 public CheckersPiece Clone(CheckersGame game)
 {
     CheckersPiece clonedPiece = game.PieceAt(Location);
     // Make sure piece exists
     if(clonedPiece == null)
         return null;
     // Make sure piece is equivalent
     if((clonedPiece.Player != Player) || (clonedPiece.InPlay != InPlay) || (clonedPiece.Rank != Rank))
         return null;
     // Return cloned piece
     return clonedPiece;
 }