import fnmatch


def find_item_wildcard(player, name, locations=None):
    """
    Find the first item whose name matches a wildcard pattern ('*') in specific
    locations.

    :param text_game_maker.player.player.Player player: player object
    :param str name: wildcard pattern
    :param [[text_game_maker.game_objects.items.Item]] locations: location\
        lists to search. If None, the item list of the current tile is used
    :return: found item. If no matching item is found, None is returned.
    :rtype: text_game_maker.game_objects.items.Item
    """
    if name.startswith('the '):
        name = name[4:]

    if locations is None:
        locations = player.current.items.values()

    ret = []
    for loc in locations:
        for item in loc:
            if (not item.scenery) and fnmatch.fnmatch(item.name, name):
                return item

    return None