if ( getRenderer().getDraggedPiece() == null )
return; // nothing being dragged
Board board = (Board)controller.getBoard();
// get the original position.
BoardPosition position = board.getPosition( getRenderer().getDraggedPiece().getLocation());
// valid or not, we won't show the dragged piece after releasing the mouse
getRenderer().setDraggedPiece(null);
BoardPosition destp = board.getPosition( loc );
if (customCheckFails(position, destp)) {
invalidMove();
return;
}
List possibleMoveList = getPossibleMoveList(position);
// verify that the move is valid before allowing it to be made
Iterator it = possibleMoveList.iterator();
boolean found = false;
TwoPlayerMove move = null;
while ( it.hasNext() && !found ) {
move = (TwoPlayerMove) it.next();
if ( (move.getToRow() == destp.getRow()) && (move.getToCol() == destp.getCol()) )
found = true;
}
if ( !found ) {
invalidMove();