Skip to content

Latest commit

 

History

History
26 lines (16 loc) · 889 Bytes

chess.ts.isattacked.md

File metadata and controls

26 lines (16 loc) · 889 Bytes

Home > chess.ts > isAttacked

isAttacked() function

Checks if a square is attacked. If an attacking color is not provided, the opposite color of the piece on the square or the current turn is used. This function does not check if the attacking piece is pinned.

Signature:

export declare function isAttacked(state: Readonly<BoardState>, square: number, color?: Color): boolean;

Parameters

Parameter Type Description
state Readonly<BoardState> Board state
square number Square to check
color Color (Optional) Color of the attacking side

Returns:

boolean