Game/GameManager.cs
/// <summary>
/// Get available coordinates from given piece making sure that all chess rules are applied
/// </summary>
/// <param name="piece"></param>
/// <param name="xRay"></param>
/// <returns></returns>
Get available coordinates from given piece making sure that all chess rules are applied
Get available coordinates from given piece making sure that all chess rules are applied
public List<Coords> GetAvailableCoords(Piece piece, bool xRay = false)
        {
            if (piece.EPiece == EPiece.King)
                return GetKingAvailableCoords((King) piece);
            King king = piece.Side == PieceColor.White ? Board.WhiteKing : Board.BlackKing;
            if (king.Checks.Count == 0)
                return piece.AvailableCoords(Board.Tiles, xRay);
            return piece.AvailableCoords(Board.Tiles, xRay)
                .Intersect(king.Checks.Where(x => x.IsAttackBlockable).Select(x => x.Coordinate))
                .ToList();
        }
public List < Coords > GetAvailableCoords ( Piece piece , bool xRay = false ) { if ( piece . EPiece == EPiece . King ) return GetKingAvailableCoords ( ( King ) piece ) ; King king = piece . Side == PieceColor . White ? Board . WhiteKing : Board . BlackKing ; if ( king . Checks . Count == 0 ) return piece . AvailableCoords ( Board . Tiles , xRay ) ; return piece . AvailableCoords ( Board . Tiles , xRay ) . Intersect ( king . Checks . Where ( x => x . IsAttackBlockable ) . Select ( x => x . Coordinate ) ) . ToList ( ) ; }
Get available coordinates from given piece making sure that all chess rules are applied
Get available coordinates from given piece making sure that all chess rules are applied
None
piece
Piece
None
xRay
bool
None