Exemplo n.º 1
0
        /// <summary>
        /// For debug
        /// </summary>
        /// <param name="board"></param>
        /// <param name="coordinates"></param>
        /// <param name="playerColor"></param>
        /// <returns></returns>
        private IList<Coordinate> Debugging(Board board, string coordinates, out string playerColor)
        {
            IList<Coordinate> coords = new List<Coordinate>();
            const char delimiterChar = ' ';
            string[] word = coordinates.Split(delimiterChar);
            for (int i = 0; i < word.Length - 1; i++)
            {
                int x = Int32.Parse(word[i].Substring(1, 1));
                int y = Int32.Parse(word[i].Substring(3, 1));
                coords.Add(new Coordinate {X = x, Y = y});
            }
            foreach (var item in coords)
            {
                item.Status = board[board.Search(item)].Status;
            }
            playerColor = word[word.Length - 1];

            return coords;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Convert Shmul and Limor moves to our coordinate
        /// </summary>
        /// <param name="board"></param>
        /// <param name="coordinates"></param>
        /// <param name="playerColor"></param>
        /// <returns>A list of coordinates</returns>
        private IList<Coordinate> ShmulToCoordinate(Board board, string coordinates, out string playerColor)
        {
            IList<Coordinate> coords = new List<Coordinate>();
            const char delimiterChar = ' ';
            string[] word = coordinates.Split(delimiterChar);

            for (int i = 0; i < word.Length - 1; i++)
            {
                int x = Int32.Parse(word[i].Substring(1, 1));
                int y = Int32.Parse(word[i].Substring(3, 1));
                coords.Add(new Coordinate {X = x, Y = y});
            }

            //If list is not empty
            if (coords.Count > 0)
            {
                //Convert to our ccordinates and update their status
                foreach (var item in coords)
                {
                    item.X = 8 - item.X;
                    item.Y++;
                    item.Status = board[board.Search(item)].Status;
                }
            }
            playerColor = word[word.Length - 1];
            return coords;
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Checks if Piece on coordinate became a King
 /// </summary>
 /// <param name="board"></param>
 /// <param name="coordinate"></param>
 public bool IsBecameAKing(Board board, Coordinate coordinate)
 {
     int index;
     if ((board[index = board.Search(coordinate)].Status == Piece.BlackPiece) && (coordinate.X == 1))
     {
         board[index].Status = Piece.BlackKing;
         board.NumberOfBlackKings++;
         board.NumberOfBlackPieces--;
     }
     else if ((board[index = board.Search(coordinate)].Status == Piece.WhitePiece) && (coordinate.X == board.Rows))
     {
         board[index].Status = Piece.WhiteKing;
         board.NumberOfWhiteKings++;
         board.NumberOfWhitePieces--;
     }
     else
     {
         return false;
     }
     return true;
 }