/**
  * Checks the board to see if it is in a check, checkmate, or stalemate configuration. If it is,
  * it handles the situation properly.
  */
 private void evaluateBoard() {
   if (master.isCheckmate(currentColor)) {
     gui.checkmateMessage(currentColor);
     gameOver();
   } else if (master.isStalemate(currentColor)) {
     gui.stalemateMessage();
     gameOver();
   } else if (master.isCheck(currentColor) > 0) {
     // only a check, game not over
     gui.checkMessage(currentColor);
   } else {
     // display new turn
     gui.updateMessage(currentColor);
   }
 }
  /**
   * Method called to handle the situation where a user selects one of his/her pieces to move.
   *
   * @param piece Piece selected on the board
   */
  public void handlePickPiece(Piece piece) {
    // set currentPiece and locate its position
    currentPiece = piece;
    char file = piece.getFile();
    int rank = piece.getRank();

    // low-light its space
    light(gui.getSpaceAt(file, rank), false);
    ArrayList<Pair<Character, Integer>> moveList = master.moveList(piece);

    // highlight and enable legal moves
    for (javafx.util.Pair<Character, Integer> move : moveList) {
      int currRank = move.getValue();
      char currFile = move.getKey();
      light(gui.getSpaceAt(currFile, currRank), true);
    }
  }
  /**
   * 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();
  }