diff --git a/src/Chessboard/Piece.js b/src/Chessboard/Piece.js index da4b661..5950075 100644 --- a/src/Chessboard/Piece.js +++ b/src/Chessboard/Piece.js @@ -161,7 +161,7 @@ const pieceSource = { if (onDrop.length) { wasManuallyDropped(true); // execute user's logic - return onDrop(props.currentSquare, dropResults.target); + return onDrop(props.currentSquare, dropResults.target, piece); } // set new position @@ -174,8 +174,8 @@ function collect(connect, monitor) { return { connectDragSource: connect.dragSource(), connectDragPreview: connect.dragPreview(), - isDragging: monitor.isDragging(), - dropTarget: monitor.getDropResult() + isDragging: monitor.isDragging() + // dropTarget: monitor.getDropResult() }; } diff --git a/src/Chessboard/index.js b/src/Chessboard/index.js index 3f142c9..9b7f547 100644 --- a/src/Chessboard/index.js +++ b/src/Chessboard/index.js @@ -310,7 +310,6 @@ class Chessboard extends Component { /* Called on drop if there is no onDrop prop. This is what executes when a position does not change through the position prop, i.e., simple drag and drop operations on the pieces.*/ setPosition = (piece, sourceSquare, targetSquare = null) => { - console.log('sq', sourceSquare, 'ts', targetSquare); const { currentPosition } = this.state; const { getPosition, dropOffBoard } = this.props; if (sourceSquare === targetSquare) return; diff --git a/src/Demo.js b/src/Demo.js index 0d236a8..5da604a 100644 --- a/src/Demo.js +++ b/src/Demo.js @@ -3,19 +3,19 @@ import React, { Component } from 'react'; import Chessboard from './Chessboard'; // import HumanVsRandom from './integrations/HumanVsRandom'; // import RandomVsRandom from './integrations/RandomVsRandom'; -// import HumanVsHuman from './integrations/HumanVsHuman'; +import HumanVsHuman from './integrations/HumanVsHuman'; // import RandomFEN from './integrations/RandomFEN'; // import Stockfish from './integrations/Stockfish'; // import { roughSquare } from './integrations/customRough'; -import lebronJames from './img/kingJames.png'; -import elvis from './img/elvis.png'; +// import lebronJames from './img/kingJames.png'; +// import elvis from './img/elvis.png'; // import defaultPieces from './Chessboard/svg/chesspieces/standard'; class Demo extends Component { render() { return (
-
+ {/*
- console.log('cs', currentSquare, 'sq', sourceSquare) || currentSquare === 'f4' || (sourceSquare === 'f4' && !currentSquare) || (sourceSquare === 'a2' && currentSquare !== 'spare') ? ( @@ -46,9 +45,9 @@ class Demo extends Component { sparePieces={true} />
-
+
*/}
- {/*
+
{({ position, @@ -72,10 +71,11 @@ class Demo extends Component { getPosition={getPosition} darkSquareStyle={darkSquareStyle} lightSquareStyle={{ backgroundColor: 'white' }} + sparePieces={true} /> )} -
*/} +
{/*
diff --git a/src/integrations/HumanVsHuman.js b/src/integrations/HumanVsHuman.js index 2cfd2af..dfac1a8 100644 --- a/src/integrations/HumanVsHuman.js +++ b/src/integrations/HumanVsHuman.js @@ -21,7 +21,8 @@ class HumanVsHuman extends Component { getPosition = position => this.setState({ myPosition: position }); - onDrop = (source, target) => { + onDrop = (source, target, piece) => { + console.log('source', source, 'target', target, 'piece', piece); this.removeHighlightSquare(); // see if the move is legal