This is a simple implementation of the classic board game,
implemented in React. It supports all possible moves, including
castling, and en passant.
{
getAllSettings().map(setting => {
return (
);
})
}
}
/>
: null
);
}
/* Board class can't (always) include a settings button if used as a demo. */
render() {
const checkMsg = this.whoInCheck() ? "Check! " : "";
const isCheckmate = this.checkmate();
const namedPlayer = isCheckmate ?
!this.state.blackIsNext : this.state.blackIsNext
const color = namedPlayer ? 'Black' : 'White';
const status = isCheckmate ? "Checkmate! " + color + " Wins!" :
checkMsg + color + "'s Turn";
return (
{status}
{range(8).map(n => this.row(n))}
{this.renderPopup()}
);
}
}
export default Board;
export {Piece};
export { BLACK, WHITE, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY };