예제 #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}
예제 #2
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
    outcome = ['won', 'lost', 'total']

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

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

    result = {}

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

    final_result = {}
    for o in outcome:
        final_result[o] = []
        for c in result:
            dict = OrderedDict({'id': c, 'name': champions[c]['name'], 'key': champions[c]['key']})
            dict.update(sorted((result[c][o]).items()))
            final_result[o].append(dict)

    return final_result
예제 #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_minions_json(result, data, regions, tiers, minions, upgrades)
    calculate_extras(result)

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

    return result_breakdown(result)
예제 #4
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)
예제 #5
0
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] = {'won': {}, 'lost': {}}
                for outcome, stats in dict[r][hast][key].items():
                    stats = dict[r][hast][key][outcome]
                    stats['picks'] = 0
                    stats['matchDuration'] = 0
                    for t in stat_titles:
                        stats[t] = 0
                        stats[t + '-per5min'] = 0