def create_versioned_spell_icons(championfull, summoners): if not os.path.exists(os.path.join(ver_path, "spell")): os.makedirs(os.path.join(ver_path, "spell")) # Champion Spells champion_summary = download.download_versioned_cdragon_champion_summary() for x in champion_summary: champion = download.download_versioned_cdragon_champion( "default", x['id']) for i, spell in enumerate(champion['spells']): image = download.download_image( get_cdragon_url(spell['abilityIconPath'])) name = championfull['data'][x['alias']]['spells'][i]['id'] with open(os.path.join(ver_path, f"spell/{name}.png"), "wb") as f: f.write(image) # Summoner Spells cdragon_summoners = download.download_versioned_cdragon_summoner_spells( "default") for summoner, value in summoners['data'].items(): for x in cdragon_summoners: if str(x['id']) == value['key']: url = get_cdragon_url(x['iconPath']) image = download.download_image(url) with open(os.path.join(ver_path, f"spell/{summoner}.png"), "wb") as f: f.write(image) return
def create_versioned_champion_passives(): if not os.path.exists(os.path.join(ver_path, "passive")): os.makedirs(os.path.join(ver_path, "passive")) cdragon_champions = download.download_versioned_cdragon_champion_summary() for champion in cdragon_champions: cdragon_champion = download.download_versioned_cdragon_champion( "default", champion['id']) url = get_cdragon_url(cdragon_champion['passive']['abilityIconPath']) image = download.download_image(url) with open( os.path.join( ver_path, f"passive/{get_image_name_from_path(cdragon_champion['passive']['abilityIconPath'])}" ), "wb") as f: f.write(image) return
def create_unversioned_champion_tile(championfull): if not os.path.exists(os.path.join(unv_path, "champion/tiles")): os.makedirs(os.path.join(unv_path, "champion/tiles")) for champion in championfull['data']: champion_key = championfull['data'][champion]['key'] cdragon_champion = download.download_versioned_cdragon_champion( "default", champion_key) for i in range(len(cdragon_champion['skins'])): url = get_cdragon_url(cdragon_champion['skins'][i]['tilePath']) image = download.download_image(url) print( f"{champion}_{championfull['data'][champion]['skins'][i]['num']}" ) with open( os.path.join( unv_path, f"champion/tiles/{champion}_{championfull['data'][champion]['skins'][i]['num']}.jpg" ), "wb") as f: f.write(image) return
def create_championfull_json(cdragon_language, ddragon_language): cdragon_champions = download.download_versioned_cdragon_champion_summary() ddragon_champions = download.download_versioned_ddragon_championfull( ddragon_language) champions = { 'type': 'champion', 'format': 'full', 'version': settings.patch['json'], "data": {}, "keys": {}, } champions["data"] = {} for champion in cdragon_champions: champions['data'][champion['alias']] = { 'id': champion['alias'], 'key': str(champion['id']), } champions['keys'][champion['id']] = champion['alias'] for champion in champions["data"]: id = champions["data"][champion]["key"] cdragon_champion = download.download_versioned_cdragon_champion( cdragon_language, id) cdragon_bin = download.download_versioned_cdragon_champion_bin( champion) champions['data'][champion].update({ 'name': cdragon_champion['name'], 'title': cdragon_champion['title'], 'image': { 'full': cdragon_champion['alias'] + '.png' }, 'skins': { }, 'lore': cdragon_champion['shortBio'], 'blurb': blurb(cdragon_champion['shortBio']), "allytips": get_tip_list(ddragon_language, cdragon_bin['tips1']), "enemytips": get_tip_list(ddragon_language, cdragon_bin['tips2']), 'tags': list(map(lambda x: x.title(), cdragon_champion['roles'])), 'partype': "", 'info': { 'attack': if_key_exists('attackRank', cdragon_bin['characterToolData']), 'defense': if_key_exists('defenseRank', cdragon_bin['characterToolData']), 'magic': if_key_exists('magicRank', cdragon_bin['characterToolData']), 'difficulty': if_key_exists('difficultyRank', cdragon_bin['characterToolData']), }, 'stats': { 'hp': round(cdragon_bin['baseHP'], 3), 'hpperlevel': cdragon_bin['hpPerLevel'], 'mp': round(if_key_exists('arBase', cdragon_bin['primaryAbilityResource']), 3), 'mpperlevel': if_key_exists('arPerLevel', cdragon_bin['primaryAbilityResource']), 'movespeed': cdragon_bin['baseMoveSpeed'], 'armor': round(cdragon_bin['baseArmor'], 3), 'armorperlevel': round(if_key_exists('armorPerLevel', cdragon_bin), 3), 'spellblock': round(cdragon_bin['baseSpellBlock'], 3), 'spellblockperlevel': round(cdragon_bin['spellBlockPerLevel'], 3), 'attackrange': round(cdragon_bin['attackRange'], 3), 'hpregen': round(if_key_exists('baseStaticHPRegen', cdragon_bin) * 5, 3), 'hpregenperlevel': round(cdragon_bin['hpRegenPerLevel'] * 5, 3), 'mpregen': round(if_key_exists('arBaseStaticRegen', cdragon_bin['primaryAbilityResource']) * 5, 3), 'mpregenperlevel': round(if_key_exists('arRegenPerLevel', cdragon_bin['primaryAbilityResource']) * 5, 3), 'crit': 0, 'critperlevel': 0, 'attackdamage': round(cdragon_bin['baseDamage'], 3), 'attackdamageperlevel': round(if_key_exists('damagePerLevel', cdragon_bin), 3), 'attackspeedperlevel': round(if_key_exists('attackSpeedPerLevel', cdragon_bin), 3), 'attackspeed': round(cdragon_bin['attackSpeed'], 3), }, 'spells': [], 'passive': { 'name': cdragon_champion['passive']['name'], 'description': cdragon_champion['passive']['description'], 'image': { 'full': get_icon_name(cdragon_champion['passive']['abilityIconPath']) }, }, 'recommended': [], }) champions['data'][champion]['skins'] = [] for y, i in enumerate(cdragon_champion["skins"]): skin_num = get_skin_num(id, cdragon_champion["skins"][y]['id']) skin = { 'id': str(cdragon_champion["skins"][y]['id']), 'num': skin_num, 'name': cdragon_champion["skins"][y]['name'] if cdragon_champion["skins"][y]['isBase'] != True else "default", 'chromas': True if "chromaPath" in cdragon_champion["skins"][y] and cdragon_champion["skins"][y]['chromaPath'] is not None else False, } champions['data'][champion]['skins'].append(skin) y = 0 for x in cdragon_champion['spells']: cdragon_champion['spells'][y] = process_spell_variables( cdragon_champion['spells'][y]) spell = { 'id': cdragon_bin['spellNames'][y].split("/")[-1], } cdragon_ability_bin = download.download_versioned_cdragon_champion_bin_ability( champion, spell['id']) spell.update({ 'name': cdragon_champion['spells'][y]['name'], 'description': cdragon_champion['spells'][y]['description'], 'tooltip': "", 'leveltip': { 'label': [], "effect": [], }, }) if "mClientData" in cdragon_ability_bin['mSpell'] and "mTooltipData" in cdragon_ability_bin['mSpell']['mClientData'] and "mLocKeys" in cdragon_ability_bin['mSpell']['mClientData']['mTooltipData']: if "keyTooltipExtendedBelowLine" in cdragon_ability_bin['mSpell']['mClientData']['mTooltipData']['mLocKeys']: spell['tooltip'] = get_tooltip(translate.t(ddragon_language, cdragon_ability_bin['mSpell']['mClientData']['mTooltipData']['mLocKeys']['keyTooltip']) + " " + translate.t(ddragon_language, cdragon_ability_bin['mSpell']['mClientData']['mTooltipData']['mLocKeys']['keyTooltipExtendedBelowLine'])) else: if "keyTooltip" in cdragon_ability_bin['mSpell']['mClientData']['mTooltipData']['mLocKeys']: spell['tooltip'] = get_tooltip(translate.t(ddragon_language, cdragon_ability_bin['mSpell']['mClientData']['mTooltipData']['mLocKeys']['keyTooltip'])) try: spell['maxrank'] = cdragon_ability_bin['mSpell']['mClientData']['mTooltipData']['mLists']['LevelUp']['levelCount'] except KeyError: spell['maxrank'] = 6 # Aphelios spell['cooldown'] = [] spell['cooldownBurn'] = "" for i in range(spell['maxrank']): spell['cooldown'].append( cdragon_champion['spells'][y]['cooldownCoefficients'][i]) spell['cooldownBurn'] = spell['cooldownBurn'] + remove_trailing_zeros( cdragon_champion['spells'][y]['cooldownCoefficients'][i]) + "/" spell['cooldownBurn'] = get_burn_string(spell['cooldownBurn']) spell['cost'] = [] spell['costBurn'] = "" for i in range(spell['maxrank']): spell['cost'].append( cdragon_champion['spells'][y]['costCoefficients'][i]) spell['costBurn'] = spell['costBurn'] + \ remove_trailing_zeros( cdragon_champion['spells'][y]['costCoefficients'][i]) + "/" spell['costBurn'] = get_burn_string(spell['costBurn']) spell['datavalues'] = {} if "mDataValues" in cdragon_ability_bin['mSpell']: for i in cdragon_ability_bin['mSpell']['mDataValues']: if "mValues" in i: values = [] for m in range(spell['maxrank']): value = i['mValues'][m] if "mFormula" in i: try: value = round(eval(i['mFormula'].replace( "P", str(value)).replace("N", str(m))), 3) except Exception: value = round(eval(re.sub( r'\b0+(?!\b)', '', i['mFormula'].replace("P", str(value)).replace("N", str(m)))), 3) else: value = round(value, 3) values.append(value) spell['datavalues'].update({ i['mName'].lower(): values, }) if "{94572284}" in cdragon_ability_bin['mSpell']: spell['calculations'] = {} for i in cdragon_ability_bin['mSpell']['{94572284}']: if "{50f145c0}" in cdragon_ability_bin['mSpell']['{94572284}'][i]: print(spell['id']) calculation = create_damage_list( cdragon_ability_bin['mSpell']['{94572284}'][i]['{50f145c0}']) if calculation is not False: spell['calculations'][translate.__getitem__( i).lower()] = calculation if "mFormulaParts" in cdragon_ability_bin['mSpell']['{94572284}'][i]: calculation = create_damage_list( cdragon_ability_bin['mSpell']['{94572284}'][i]['mFormulaParts']) if calculation is not False: spell['calculations'][translate.__getitem__( i).lower()] = calculation else: print("CALCULATION FALSE!") if "mModifiedGameCalculation" in cdragon_ability_bin['mSpell']['{94572284}'][i]: maxdamagetooltip = { 'modifiedCalculation': "", 'multiplier': {} } maxdamagetooltip.update({ 'modifiedCalculation': translate.__getitem__(cdragon_ability_bin['mSpell']['{94572284}'][i]['mModifiedGameCalculation']).lower() }) for j in cdragon_ability_bin['mSpell']['{94572284}'][i]['mMultiplier']: if j == "mBreakpoints": maxdamagetooltip['multiplier'].update({ j[1:].lower(): create_damage_list(cdragon_ability_bin['mSpell']['{94572284}'][i]) }) elif "part" in j.lower(): maxdamagetooltip['multiplier'].update({ j[1:].lower(): create_damage_list(cdragon_ability_bin['mSpell']['{94572284}'][i]['mMultiplier'][j]) }) else: maxdamagetooltip['multiplier'].update({ j[1:].lower(): translate.__getitem__( cdragon_ability_bin['mSpell']['{94572284}'][i]['mMultiplier'][j]) }) if maxdamagetooltip != {}: spell['calculations'][translate.__getitem__( i).lower()] = maxdamagetooltip if "formulas" in cdragon_champion['spells'][y]: spell['formulas'] = {} for i in cdragon_champion['spells'][y]['formulas']: if cdragon_champion['spells'][y]['formulas'][i]['link'] != "": spell['formulas'].update( {i: cdragon_champion['spells'][y]['formulas'][i]}) spell['effect'] = [] spell['effectBurn'] = [] for i in range(11): if i == 0: spell['effect'].append(None) spell['effectBurn'].append(None) continue spell['effectBurn'].append("") spell['effect'].append([]) for j in range(spell['maxrank']): spell['effect'][i].append(cdragon_champion[ 'spells'][y]['effectAmounts'][f'Effect{i}Amount'][j+1]) spell['effectBurn'][i] = spell['effectBurn'][i] + remove_trailing_zeros( cdragon_champion['spells'][y]['effectAmounts'][f'Effect{i}Amount'][j+1]) + "/" spell['effectBurn'][i] = get_burn_string( spell['effectBurn'][i]) spell['vars'] = [] j = 0 for i in cdragon_champion['spells'][y]['coefficients']: if cdragon_champion['spells'][y]['coefficients'][i] != 0: spell_var = {} spell_var['link'] = "spelldamage" spell_var['coeff'] = cdragon_champion['spells'][y]['coefficients'][i] if "a" + str(j + 1) in spell['tooltip']: spell_var['key'] = "a" + str(j + 1) else: spell_var['link'] = "physicaldamage" spell_var['key'] = "f" + str(j + 1) if spell_var['key'] in spell['tooltip']: spell['vars'].append(spell_var) j += 1 spell['costType'] = remove_html_tags(get_tooltip( cdragon_champion['spells'][y]['cost'])) if "}}" in spell['costType']: spell['costType'] = spell['costType'].split("}}", 1)[1] spell['maxammo'] = str(cdragon_champion['spells'][y]['ammo']['maxAmmo'][0] ) if cdragon_champion['spells'][y]['ammo']['maxAmmo'][0] != 0 else "-1" spell['range'] = [] spell['rangeBurn'] = "" for i in range(spell['maxrank']): spell['range'].append( cdragon_champion['spells'][y]['range'][i]) spell['rangeBurn'] = spell['rangeBurn'] + remove_trailing_zeros( cdragon_champion['spells'][y]['range'][i]) + "/" spell['rangeBurn'] = get_burn_string(spell['rangeBurn']) spell['image'] = {} spell['image']['full'] = spell['id'] + ".png" champions['data'][champion]['spells'].append(spell) spell['resource'] = remove_html_tags(get_tooltip( cdragon_champion['spells'][y]['cost'])) try: for desc in cdragon_ability_bin['mSpell']['mClientData']['mTooltipData']['mLists']['LevelUp']['elements']: if "nameOverride" in desc: if desc['nameOverride'] == "Spell_Cost_NoCost": continue if desc['nameOverride'] == "Spell_ListType_Cost": desc['nameOverride'] = "Spell_ListType_UnnamedCost" spell['leveltip']['label'].append( translate.t(ddragon_language, desc['nameOverride'])) else: spell['leveltip']['label'].append( translate.t(ddragon_language, "Spell_ListType_" + desc['type'])) percent = "" if "Style" in desc and desc['Style'] == 1: percent = "%" multiplier = "" newvalue = "NL" if "multiplier" in desc: multiplier = "*" + str(desc['multiplier']) + "00000" newvalue = "nl" if "Effect" in desc['type']: effect = "e" + str(desc['typeIndex']) spell['leveltip']['effect'].append( f"{{{{ {effect}{multiplier} }}}}{percent} -> {{{{ {effect}{newvalue}{multiplier} }}}}") else: spell['leveltip']['effect'].append( f"{{{{ {desc['type'].lower()}{multiplier} }}}}{percent} -> {{{{ {desc['type'].lower()}{newvalue}{multiplier} }}}}{percent}") except KeyError: print("No leveltip " + spell['id']) y += 1 for x in cdragon_champion['recommendedItemDefaults']: champions['data'][champion]['recommended'].append( download.download_versioned_cdragon_recommended(x)) try: champions['data'][champion]['partype'] = ddragon_champions['data'][champion]['partype'] except Exception: champions['data'][champion]['partype'] = get_partype( cdragon_bin, ddragon_language).title() print("ddragon failed") utils.save_json( champions, os.path.join( __main__.files, f"{settings.patch['json']}/data/{ddragon_language}/championFull.json")) return champions
def create_champion_json(cdragon_language, ddragon_language): cdragon_champions = download.download_versioned_cdragon_champion_summary() champions = { 'type': 'champion', 'format': 'standAloneComplex', 'version': settings.patch['json'], } champions["data"] = {} for champion in cdragon_champions: champions['data'][champion['alias']] = { "version": settings.patch['json'], 'id': champion['alias'], 'key': str(champion['id']), } for champion in champions["data"]: cdragon_champion = download.download_versioned_cdragon_champion( cdragon_language, champions['data'][champion]['key']) cdragon_bin = download.download_versioned_cdragon_champion_bin( champion) champions['data'][champion].update({ 'name': if_key_exists('name', cdragon_champion), 'title': if_key_exists('title', cdragon_champion), 'blurb': blurb(cdragon_champion['shortBio']), 'info': { 'attack': if_key_exists('attackRank', cdragon_bin['characterToolData']), 'defense': if_key_exists('defenseRank', cdragon_bin['characterToolData']), 'magic': if_key_exists('magicRank', cdragon_bin['characterToolData']), 'difficulty': if_key_exists('difficultyRank', cdragon_bin['characterToolData']), }, 'image': { 'full': cdragon_champion['alias'] + '.png' }, 'tags': list(map(lambda x: x.title(), cdragon_champion['roles'])), 'partype': "", 'stats': { 'hp': round(cdragon_bin['baseHP'], 3), 'hpperlevel': cdragon_bin['hpPerLevel'], 'mp': round(if_key_exists('arBase', cdragon_bin['primaryAbilityResource']), 3), 'mpperlevel': if_key_exists('arPerLevel', cdragon_bin['primaryAbilityResource']), 'movespeed': cdragon_bin['baseMoveSpeed'], 'armor': round(cdragon_bin['baseArmor'], 3), 'armorperlevel': round(if_key_exists('armorPerLevel', cdragon_bin), 3), 'spellblock': round(cdragon_bin['baseSpellBlock'], 3), 'spellblockperlevel': cdragon_bin['spellBlockPerLevel'], 'attackrange': cdragon_bin['attackRange'], 'hpregen': round(if_key_exists('baseStaticHPRegen', cdragon_bin) * 5, 3), 'hpregenperlevel': round(cdragon_bin['hpRegenPerLevel'] * 5, 3), 'mpregen': round(if_key_exists('arBaseStaticRegen', cdragon_bin['primaryAbilityResource']) * 5, 3), 'mpregenperlevel': round(if_key_exists('arRegenPerLevel', cdragon_bin['primaryAbilityResource']) * 5, 3), 'crit': 0, 'critperlevel': 0, 'attackdamage': round(cdragon_bin['baseDamage'], 3), 'attackdamageperlevel': round(if_key_exists('damagePerLevel', cdragon_bin), 3), 'attackspeedperlevel': round(if_key_exists('attackSpeedPerLevel', cdragon_bin), 3), 'attackspeed': round(cdragon_bin['attackSpeed'], 3), }, }) # Need to be able to find the game_ability_resource strings from CDragon try: champions['data'][champion]['partype'] = ddragon_champions['data'][champion]['partype'] except Exception: champions['data'][champion]['partype'] = get_partype( cdragon_bin, ddragon_language).title() utils.save_json( champions, os.path.join( __main__.files, f"{settings.patch['json']}/data/{ddragon_language}/champion.json")) return champions