1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Allow pieces to take one another

This commit is contained in:
Daniel Barber 2016-12-08 15:51:52 +00:00
parent 877506a648
commit 5ca7520012

View File

@ -16,18 +16,13 @@ class ChessBoardSquare extends React.Component {
selectSquare() {
var { store } = this.props;
console.log(`Clicked: ${this.props.file}${this.props.rank}`);
if (this.props.piece != undefined) {
if (store.getState().selectedSquare != null) {
store.dispatch(movePiece(store.getState().selectedSquare, this.squareCoords()));
}
else if (this.props.piece != undefined) {
store.dispatch(selectPiece(this.squareCoords()));
}
else {
console.log("About to move!");
store.dispatch(movePiece(store.getState().selectedSquare, this.squareCoords()));
console.log("Moved!");
}
console.log(store.getState().selectedSquare);
};
isSelectedSquare() {