/**
   * Handles the mouse location click.
   *
   * @param loc the location that was clicked
   * @return true because the click has been handled
   */
  @Override
  public boolean locationClicked(Location loc) {
    if (game.getTurn() instanceof SmartComputerCheckerPlayer) // ignore all clicks on CPU's turn
    {
      return true;
    }

    if (lastMove != null
        && lastMove.isJump()
        && lastMove.getPiece().canJump()) // locks selection onto jump-chaining piece
    {
      Piece lastPiece = lastMove.getPiece();

      if (!loc.equals(lastPiece.getLocation())
          && !lastPiece.getAllowedMoves().contains(loc)) // consumes irrelevant clicks
      {
        return true;
      }
    }
    if (getGrid().get(loc) != null && !(getGrid().get(loc) instanceof PieceTile)) {
      Piece p = getGrid().get(loc);
      if (pieceSelected) {
        game.undisplayMoves(playerPiece);
      }
      game.displayMoves(p); // selection and highlight available moves
      playerPiece = p;
      pieceSelected = true;
    } else if (pieceSelected && !playerPiece.getAllowedMoves().contains(loc)) {
      pieceSelected = false;
      game.undisplayMoves(playerPiece); // undo selection and highlight
      playerPiece = null;
    } else if (pieceSelected && playerPiece.getAllowedMoves().contains(loc)) {
      pieceSelected = false;
      game.undisplayMoves(playerPiece); // undo selection and highlight
      setPlayerLocation(loc);
    }

    return true;
  }