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()}
);
}
}
class Game extends React.Component {
constructor(props){
super(props);
this.state = { showPopup: false };
}
render() {
return (
);
}
}
// ========================================
ReactDOM.render(
,
document.getElementById('root')
);