/// <summary> /// Verifies if a piece attacks a square. This method does not check if the piece on "from" /// on the board is of the same type as this FlyweightPiece represents. /// </summary> /// <param name="board">Board to check attacking on.</param> /// <param name="from">Square on which attacking piece is placed.</param> /// <param name="to">The square to check if attacked.</param> /// <returns>True if a FlyweightPiece placed on "from" square attacks the "to" square. False otherwise.</returns> public bool Attacks(Board board, Square from, Square to) { if ((m_color == PieceColor.White && Board.Rank(to) == Board.Rank(from) + 1) || (m_color == PieceColor.Black && Board.Rank(to) == Board.Rank(from) - 1)) { if ((Math.Abs(Board.File(to) - Board.File(from)) == 1) && (board.GetPieceColor(to) != m_color)) return true; } return false; }
/// <summary> /// Verifies if a piece attacks a square. This method does not check if the piece on "from" /// on the board is of the same type as this FlyweightPiece represents. /// </summary> /// <param name="board">Board to check attacking on.</param> /// <param name="from">Square on which attacking piece is placed.</param> /// <param name="to">The square to check if attacked.</param> /// <returns>True if a FlyweightPiece placed on "from" square attacks the "to" square. False otherwise.</returns> public bool Attacks(Board board, Square from, Square to) { if ((m_color == PieceColor.White && Board.Rank(to) == Board.Rank(from) + 1) || (m_color == PieceColor.Black && Board.Rank(to) == Board.Rank(from) - 1)) { if ((Math.Abs(Board.File(to) - Board.File(from)) == 1) && (board.GetPieceColor(to) != m_color)) { return(true); } } return(false); }
/// <summary> /// Returns the color of the piece on the square the iterator is currently located on. /// </summary> /// <returns>Current color of piece.</returns> public PieceColor CurrentPieceColor() { return(m_board.GetPieceColor(m_currentSquare)); }