def generate(league, raf_path, fontconfig_path, corrections): font_config = load_fontconfig(fontconfig_path) champ_inibins = find_inibins(raf_path, re.compile(r"^data/characters/([^/]+)/\1.inibin$")) mappings = map_champion_data(champ_inibins, font_config) mappings = map_by_ids(mappings, league) mappings = dict(mappings) ability_inibins = find_inibins(raf_path, re.compile(r"^data/(?:characters/[^/]+/)?spells/(.+).inibin$")) ability_inibins = dict(ability_inibins) # Add ability info to champions for champion in mappings.values(): abilities = champion['abilities'] for k, name in abilities.items(): name = name.lower() # TODO: Lookup in league # if name not in ability_inibins: # name = champion['internal_name'] + name if name in ability_inibins: # Parse ability try: ability = read_inibin(ability_inibins[name], font_config, 'ability') except RuntimeError: # TODO: Handle this (probably by updating pyinibin_parser) pass else: abilities[k] = {'name': name, 'raw': ability} mappings = { 'champions': mappings } return mappings
def map_champion_data(inibins, font_config): for internal_name, data in inibins: # TODO: Make using IniBinReader better mapping = read_inibin(data, font_config) yield internal_name, mapping