/** * Method called to handle the situation where a user is moving the currentPiece to a new location * * @param position New space on the board for a piece to move */ public void handleMove(Pair<Character, Integer> position) { // place the current move onto the stack Piece captured = board.at(position); Pair<Character, Integer> oldPosition = currentPiece.getPosition(); moveStack.push(new Move(currentPiece, captured, oldPosition, position)); // make the move master.move(currentPiece, position); // refresh board after piece is moved try { gui.refreshBoard(); } catch (IOException e1) { e1.printStackTrace(); } if (!moveStack.empty()) { // can undo now that there are moves in the stack gui.setUndoEnabled(true); } // reset backgrounds and change sides switchSides(); }