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:
parent
877506a648
commit
5ca7520012
@ -16,18 +16,13 @@ class ChessBoardSquare extends React.Component {
|
|||||||
|
|
||||||
selectSquare() {
|
selectSquare() {
|
||||||
var { store } = this.props;
|
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()));
|
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() {
|
isSelectedSquare() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user