Beispiel #1
0
def create_champions_dict(minions_json):
    minions = static_io.read_json('minions_by_id.json')
    upgrades = static_io.read_json('upgrades_by_id.json')
    w = len(regions)
    for r in regions:
        minions_json[r] = {}

        for hast in static_data.highest_achieved_season_tier:
            minions_json[r][hast] = {}
            for minion_id, minion_name in minions.items():
                minions_json[r][hast][minion_id] = \
                    {'name': minion_name, 'won': 0, 'lost': 0}
                for upgrade_id, upgarde_name in upgrades.items():
                    minions_json[r][hast][minion_id][upgrade_id] = \
                        {'name': upgarde_name, 'won': 0, 'lost': 0}
def run_query(regions, tiers):
    if len(regions) == 0:
        regions=static_data.regions
    if len(tiers) == 0:
        tiers = static_data.highest_achieved_season_tier

    champions = static_io.read_json('champions_by_id.json')

    data = query_io.read_json('champions.json')

    result = {}

    create_empty_result_dict(result, champions)
    query_champions_json(result, data, regions, tiers, champions)
    calculate_extras(result)

    winrate = []
    pickrate = []
    for key, value in result.items():
        winrate.append([key, value['key'], value['winrate']])
        pickrate.append([key, value['key'], value['pickrate'], value['won'] + value['lost']])
    winrate = sorted(sorted(winrate, key=lambda x: x[1], reverse=False), key=lambda x: x[2], reverse=True)
    pickrate = sorted(sorted(pickrate, key=lambda x: x[1], reverse=False), key=lambda x: x[2], reverse=True)

    result = {'winrate': winrate, 'pickrate': pickrate}
    return result
Beispiel #3
0
def run_query(regions = get_match_data.get_match_regions(), tiers = static_data.highest_achieved_season_tier):

    minions = static_io.read_json('minions_by_id.json')
    upgrades = static_io.read_json('upgrades_by_id.json')

    data = query_io.read_json('minions.json')

    result = {}

    create_query_result_dict(result, minions, upgrades)
    query_champions_json(result, data, regions, tiers, minions, upgrades)
    calculate_extras(result)

    query_io.write_json(result, 'test.json')

    return result_breakdown(result)
def create_champions_dict(dict):
    champion_keys = static_io.read_json('champions_by_id.json')
    for r in regions:
        dict[r] = {}
        for hast in static_data.highest_achieved_season_tier:
            dict[r][hast] = {}
            for key, value in champion_keys.items():
                dict[r][hast][key] = {'key': value, 'won': 0, 'lost': 0}
Beispiel #5
0
def populate_dict(minions_json):
    minions_and_upgrades = static_io.read_json('minions_by_id.json')
    minions_and_upgrades.update(static_io.read_json('upgrades_by_id.json'))
    for r in regions:
        match_data_directory = os.path.join(config.match_data_directory, r.upper())
        matches = os.listdir(match_data_directory)
        progress_counter = len(matches)
        for m in matches:
            if not m.endswith('json'):
                continue
            match_data = os.path.join(match_data_directory, m)
            with open(match_data, 'r') as f:  # open match file
                data = json.load(f)  # load match file as json
                win_team_id = [t['teamId'] for t in data['teams'] if t['winner']][0]
                for p in data['participants']:
                    minion_bought = ''
                    tier = p['highestAchievedSeasonTier']
                    team_id = p['teamId']
                    for frame in data['timeline']['frames']:
                        if 'events' not in frame:
                            continue
                        for event in frame['events']:
                            if event['eventType'] == 'ITEM_PURCHASED' \
                                    and event['participantId'] == p['participantId'] \
                                    and str(event['itemId']) in minions_and_upgrades:
                                item_id = str(event['itemId'])
                                if minion_bought == '':
                                    if win_team_id == team_id:
                                        minions_json[r][tier][item_id]['won'] += 1
                                    else:
                                        minions_json[r][tier][item_id]['lost'] += 1
                                    minion_bought = item_id
                                else:
                                    if win_team_id == team_id:
                                        minions_json[r][tier][minion_bought][item_id]['won'] += 1
                                    else:
                                        minions_json[r][tier][minion_bought][item_id]['lost'] += 1
            progress_counter -= 1
            data_filter.progress_countdown(progress_counter, r)