mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-07 04:03:45 +08:00
👽️ 适配新的MiniggAPI格式
This commit is contained in:
parent
fcea871857
commit
8c2a925fdd
File diff suppressed because one or more lines are too long
@ -170,11 +170,11 @@ class Character:
|
||||
weapon_info['weaponStats'][0]['statValue'] = round(
|
||||
weapon_level_data['attack']
|
||||
)
|
||||
if weapon_raw_data['substat'] != '':
|
||||
if weapon_raw_data['mainStatText'] != '':
|
||||
weapon_info['weaponStats'][1]['statName'] = weapon_raw_data[
|
||||
'substat'
|
||||
'mainStatText'
|
||||
]
|
||||
if weapon_raw_data['substat'] == '元素精通':
|
||||
if weapon_raw_data['mainStatText'] == '元素精通':
|
||||
fake_value = round(weapon_level_data['specialized'])
|
||||
else:
|
||||
fake_value = float(
|
||||
@ -189,7 +189,7 @@ class Character:
|
||||
)
|
||||
else:
|
||||
weapon_info['weaponEffect'] = '无特效。'
|
||||
weapon_info['weaponType'] = weapon_raw_data['weapontype']
|
||||
weapon_info['weaponType'] = weapon_raw_data['weaponText']
|
||||
self.card_prop['weaponInfo'] = weapon_info
|
||||
|
||||
# 修改假命座:
|
||||
@ -293,7 +293,7 @@ class Character:
|
||||
# 计算突破加成
|
||||
if isinstance(char_raw, dict):
|
||||
for attr in ATTR_MAP:
|
||||
if attr in char_raw['substat']:
|
||||
if attr in char_raw['substatText']:
|
||||
sp = char_data['specialized']
|
||||
if attr == '暴击伤害':
|
||||
sp -= 0.5
|
||||
|
@ -186,6 +186,8 @@ class Fight:
|
||||
|
||||
if char.char_name == '宵宫' and power_name == 'A一段伤害':
|
||||
power_plus = 1
|
||||
elif char.char_name == '娜维娅' and '层' in power_name:
|
||||
power_plus = 2
|
||||
|
||||
power_plus += real_prop[f'{power_name[0]}_powerPlus'] - 1
|
||||
|
||||
@ -230,6 +232,9 @@ class Fight:
|
||||
effect = f'a+{ex_add}'
|
||||
effect_list.append(effect)
|
||||
|
||||
if char.char_name == '娜维娅' and '6层' in char.power_name:
|
||||
effect_list.append('E:dmgBonus+45')
|
||||
|
||||
if effect_list:
|
||||
char.real_prop = await char.get_effect_prop(
|
||||
deepcopy(char.fight_prop), effect_list, char.char_name
|
||||
|
@ -292,27 +292,31 @@ async def enka_to_dict(
|
||||
else:
|
||||
weapon_info['weaponAffix'] = 1
|
||||
weapon_info['weaponStats'] = []
|
||||
|
||||
for k in weapon_data['flat']['weaponStats']:
|
||||
weapon_prop_temp = {}
|
||||
weapon_prop_temp['appendPropId'] = k['appendPropId']
|
||||
weapon_prop_temp['statName'] = propId2Name[k['appendPropId']]
|
||||
weapon_prop_temp['statValue'] = k['statValue']
|
||||
weapon_info['weaponStats'].append(weapon_prop_temp)
|
||||
|
||||
# 武器特效,须请求API
|
||||
try:
|
||||
effect_raw = await get_weapon_info(weapon_info['weaponName'])
|
||||
except ConnectTimeout:
|
||||
effect_raw = await convert_ambr_to_weapon(weapon_info['itemId'])
|
||||
if not isinstance(effect_raw, List) and not isinstance(
|
||||
effect_raw, int
|
||||
|
||||
if (
|
||||
not isinstance(effect_raw, List)
|
||||
and not isinstance(effect_raw, int)
|
||||
and effect_raw is not None
|
||||
):
|
||||
effect = effect_raw['effect'].format( # type:ignore
|
||||
*effect_raw[ # type:ignore
|
||||
'r{}'.format(str(weapon_info['weaponAffix']))
|
||||
effect = effect_raw[f'r{weapon_info["weaponAffix"]}'][
|
||||
'description'
|
||||
]
|
||||
)
|
||||
else:
|
||||
effect = '无特效。'
|
||||
|
||||
weapon_info['weaponEffect'] = effect
|
||||
char_data['weaponInfo'] = weapon_info
|
||||
|
||||
|
@ -65,7 +65,7 @@ async def draw_artifacts_wiki_img(data: Artifact) -> bytes:
|
||||
"""
|
||||
pc2 = ''
|
||||
pc4 = ''
|
||||
for uchar in data['2pc']:
|
||||
for uchar in data['effect2Pc']:
|
||||
code = ord(uchar)
|
||||
if 32 <= code <= 126:
|
||||
code += 65248
|
||||
@ -73,7 +73,7 @@ async def draw_artifacts_wiki_img(data: Artifact) -> bytes:
|
||||
else:
|
||||
new_char = uchar
|
||||
pc2 += new_char
|
||||
for uchar in data['4pc']:
|
||||
for uchar in data['effect4Pc']:
|
||||
code = ord(uchar)
|
||||
if 32 <= code <= 126:
|
||||
code += 65248
|
||||
@ -83,9 +83,9 @@ async def draw_artifacts_wiki_img(data: Artifact) -> bytes:
|
||||
pc4 += new_char
|
||||
"""
|
||||
|
||||
if '1pc' in data:
|
||||
if 'effect1Pc' in data:
|
||||
suitbar1 = Image.open(artifacts_suitbar1_path)
|
||||
pc1 = await str_lenth(' ' + data['1pc'], 22, 455)
|
||||
pc1 = await str_lenth(' ' + data['effect1Pc'], 22, 455)
|
||||
|
||||
# 计算长度
|
||||
img_draw = ImageDraw.Draw(img1)
|
||||
@ -97,8 +97,8 @@ async def draw_artifacts_wiki_img(data: Artifact) -> bytes:
|
||||
else:
|
||||
suitbar4 = Image.open(artifacts_suitbar4_path)
|
||||
suitbar2 = Image.open(artifacts_suitbar2_path)
|
||||
pc2 = await str_lenth(' ' + data['2pc'], 22, 455)
|
||||
pc4 = await str_lenth(' ' + data['4pc'], 22, 455)
|
||||
pc2 = await str_lenth(' ' + data['effect2Pc'], 22, 455)
|
||||
pc4 = await str_lenth(' ' + data['effect4Pc'], 22, 455)
|
||||
|
||||
# 计算长度
|
||||
img_draw = ImageDraw.Draw(img1)
|
||||
@ -117,7 +117,7 @@ async def draw_artifacts_wiki_img(data: Artifact) -> bytes:
|
||||
artifacts_list = ['flower', 'plume', 'sands', 'goblet', 'circlet']
|
||||
|
||||
for index, i in enumerate(artifacts_list):
|
||||
if '1pc' in data and i != 'circlet':
|
||||
if 'effect1Pc' in data and i != 'circlet':
|
||||
continue
|
||||
|
||||
rel_path = REL_PATH / f'{data[i]["name"]}.png'
|
||||
@ -153,7 +153,7 @@ async def draw_artifacts_wiki_img(data: Artifact) -> bytes:
|
||||
|
||||
result_img.paste(artifacts_bar, (0, 260 + y2 + y1 + 40), artifacts_bar)
|
||||
|
||||
rarity = '稀有度:' + '/'.join(data['rarity'])
|
||||
rarity = '稀有度:' + '/'.join([str(i) for i in [data['rarityList']]])
|
||||
|
||||
text_draw = ImageDraw.Draw(result_img)
|
||||
text_draw.text((295, 182), data['name'], (154, 123, 51), gs_font_40, 'mm')
|
||||
|
@ -15,6 +15,7 @@ from gsuid_core.utils.api.minigg.models import (
|
||||
|
||||
from .path import TEXT_PATH
|
||||
from ..utils.resource.download_url import download
|
||||
from ..utils.get_assets import get_assets_from_ambr
|
||||
from ..utils.map.name_covert import name_to_avatar_id
|
||||
from ..utils.image.convert import str_lenth, convert_img
|
||||
from ..utils.resource.RESOURCE_PATH import (
|
||||
@ -78,7 +79,7 @@ async def get_single_constellation_img(
|
||||
async with aiofiles.open(path, 'rb') as f:
|
||||
return await f.read()
|
||||
con = data[f'c{num}']
|
||||
url = data['images'][f'c{num}']
|
||||
url = data['images'][f'filename_c{num}']
|
||||
img = await draw_single_constellation(con, url, num, data['name'], True)
|
||||
return await convert_img(img)
|
||||
|
||||
@ -91,7 +92,7 @@ async def draw_single_constellation(
|
||||
is_single: bool = False,
|
||||
) -> Image.Image:
|
||||
# 计算长度
|
||||
effect = data['effect']
|
||||
effect = data['description']
|
||||
for i in range(1, 10):
|
||||
if i % 2 != 0:
|
||||
effect = effect.replace('**', '「', 1)
|
||||
@ -126,10 +127,10 @@ async def draw_single_constellation(
|
||||
icon_bg = Image.open(TEXT_PATH / 'ring_bg.png').resize((74, 74))
|
||||
img.paste(icon_bg, (38, 20), icon_bg)
|
||||
|
||||
icon_name = image.split('/')[-1]
|
||||
icon_name = f'{image}.png'
|
||||
path = ICON_PATH / icon_name
|
||||
if not path.exists():
|
||||
await download(image, 8, icon_name)
|
||||
await get_assets_from_ambr(icon_name)
|
||||
icon = Image.open(path).resize((38, 38)).convert('RGBA')
|
||||
img.paste(icon, (57, 37), icon)
|
||||
img_draw.text(
|
||||
@ -161,7 +162,10 @@ async def draw_constellation_wiki_img(
|
||||
y = 0
|
||||
for i in range(1, 7):
|
||||
_img = await draw_single_constellation(
|
||||
data[f'c{i}'], data['images'][f'c{i}'], i, char_data['name']
|
||||
data[f'c{i}'],
|
||||
data['images'][f'filename_c{i}'],
|
||||
i,
|
||||
char_data['name'],
|
||||
)
|
||||
img_list[i] = (_img, _img.size[1])
|
||||
y += _img.size[1]
|
||||
@ -187,7 +191,7 @@ async def draw_constellation_wiki_img(
|
||||
)
|
||||
|
||||
star_pic = get_star_png(char_data['rarity'])
|
||||
element_pic_path = TEXT_PATH / f'{char_data["element"]}.png'
|
||||
element_pic_path = TEXT_PATH / f'{char_data["elementText"]}.png'
|
||||
if element_pic_path.exists():
|
||||
element_pic = Image.open(element_pic_path).resize((36, 36))
|
||||
else:
|
||||
|
@ -70,7 +70,7 @@ async def draw_single_cost(title: str, data: Dict) -> Tuple[Image.Image, str]:
|
||||
if isinstance(material, int):
|
||||
cost_pic = get_unknown_png()
|
||||
else:
|
||||
name_icon = material['images']['nameicon']
|
||||
name_icon = material['images']['filename_icon']
|
||||
_cost_pic = await get_assets_from_ambr(name_icon)
|
||||
if _cost_pic is None:
|
||||
cost_pic = get_unknown_png().resize((96, 96))
|
||||
@ -78,11 +78,11 @@ async def draw_single_cost(title: str, data: Dict) -> Tuple[Image.Image, str]:
|
||||
cost_pic = _cost_pic.resize((96, 96))
|
||||
|
||||
if (
|
||||
material['materialtype'] == '武器突破素材'
|
||||
or material['materialtype'] == '角色天赋素材'
|
||||
) and 'daysofweek' in material:
|
||||
pos = material['dropdomain']
|
||||
days = material['daysofweek']
|
||||
material['typeText'] == '武器突破素材'
|
||||
or material['typeText'] == '角色天赋素材'
|
||||
) and 'daysOfWeek' in material:
|
||||
pos = material['dropDomainName']
|
||||
days = material['daysOfWeek']
|
||||
if '周日' in days:
|
||||
days.remove('周日')
|
||||
cost_pos = f'{pos} - {"/".join(days)}'
|
||||
@ -147,7 +147,7 @@ async def draw_char_cost_img(data: Character, talent_data: CharacterTalents):
|
||||
)
|
||||
|
||||
star_pic = get_star_png(data['rarity'])
|
||||
element_pic_path = TEXT_PATH / f'{data["element"]}.png'
|
||||
element_pic_path = TEXT_PATH / f'{data["elementText"]}.png'
|
||||
if element_pic_path.exists():
|
||||
element_pic = Image.open(element_pic_path).resize((54, 54))
|
||||
else:
|
||||
|
@ -56,18 +56,18 @@ async def draw_foods_wiki_img(data: Food):
|
||||
w, h = 600, 750 + y1 + y2
|
||||
|
||||
star_pic = get_star_png(data['rarity'])
|
||||
path = TEXT_PATH / f'UI_Buff_Item_{data["foodcategory"]}.png'
|
||||
path = TEXT_PATH / f'UI_Buff_Item_{data["filterType"]}.png'
|
||||
if path.exists():
|
||||
type_pic = Image.open(path)
|
||||
else:
|
||||
type_pic = await get_assets_from_ambr(
|
||||
f'UI_Buff_Item_{data["foodcategory"]}'
|
||||
f'UI_Buff_Item_{data["filterType"]}'
|
||||
)
|
||||
if type_pic is None:
|
||||
type_pic = get_unknown_png()
|
||||
type_pic = type_pic.convert('RGBA').resize((40, 40))
|
||||
|
||||
food_pic = await get_assets_from_ambr(data['images']['nameicon'])
|
||||
food_pic = await get_assets_from_ambr(data['images']['filename_icon'])
|
||||
if food_pic is None:
|
||||
food_pic = Image.new('RGBA', (320, 320))
|
||||
else:
|
||||
@ -86,7 +86,7 @@ async def draw_foods_wiki_img(data: Food):
|
||||
|
||||
img.paste(food_pic, (140, 119), food_pic)
|
||||
img_draw.text((45, 465), '食物类型', gray_color, gs_font_18, 'lm')
|
||||
img_draw.text((45, 500), data['foodfilter'], white_color, gs_font_36, 'lm')
|
||||
img_draw.text((45, 500), data['filterText'], white_color, gs_font_36, 'lm')
|
||||
|
||||
wiki_cost_tag = Image.open(TEXT_PATH / 'cost_tag.png')
|
||||
img.paste(wiki_cost_tag, (25, 550), wiki_cost_tag)
|
||||
@ -106,7 +106,7 @@ async def draw_foods_wiki_img(data: Food):
|
||||
if isinstance(material, int):
|
||||
cost_pic = get_unknown_png()
|
||||
else:
|
||||
name_icon = material['images']['nameicon']
|
||||
name_icon = material['images']['filename_icon']
|
||||
_cost_pic = await get_assets_from_ambr(name_icon)
|
||||
if _cost_pic is None:
|
||||
cost_pic = get_unknown_png()
|
||||
|
@ -1,3 +1,4 @@
|
||||
import re
|
||||
import math
|
||||
from typing import Dict, List, Union
|
||||
|
||||
@ -62,30 +63,32 @@ async def draw_weapons_wiki_img(data: Weapon, stats: WeaponStats):
|
||||
gray_color = (214, 214, 214)
|
||||
img_test = Image.new('RGBA', (1, 1))
|
||||
img_test_draw = ImageDraw.Draw(img_test)
|
||||
effect = data['effect']
|
||||
effect = effect.replace('/', '·')
|
||||
effect_desc = re.sub(
|
||||
r'</?c[^\u4e00-\u9fa5/d]+>',
|
||||
'',
|
||||
data['effectTemplateRaw'],
|
||||
)
|
||||
rw_ef = []
|
||||
for i in range(len(data['r1'])):
|
||||
now = ''
|
||||
for i in range(len(data['r1']['values'])):
|
||||
_temp = []
|
||||
for j in range(1, 6):
|
||||
ef_val = data[f'r{j}'][i].replace('/', '·')
|
||||
now += ef_val + ' / '
|
||||
now = f'{now[:-2]}'
|
||||
_temp.append(data[f'r{j}']['values'][i].replace('/', '·'))
|
||||
now = ' / '.join(_temp)
|
||||
rw_ef.append(now)
|
||||
|
||||
if effect:
|
||||
effect = effect.format(*rw_ef)
|
||||
if effect_desc:
|
||||
effect_desc = effect_desc.format(*rw_ef)
|
||||
else:
|
||||
effect = '无特效'
|
||||
effect_desc = '无特效'
|
||||
|
||||
effect = get_str_size(effect, gs_font_22, 490)
|
||||
effect_desc = get_str_size(effect_desc, gs_font_22, 490)
|
||||
|
||||
_, _, _, y1 = img_test_draw.textbbox((0, 0), effect, gs_font_22)
|
||||
_, _, _, y1 = img_test_draw.textbbox((0, 0), effect_desc, gs_font_22)
|
||||
w, h = 600, 1110 + y1
|
||||
|
||||
star_pic = get_star_png(data['rarity'])
|
||||
type_pic = Image.open(TEXT_PATH / f'{data["weapontype"]}.png')
|
||||
gacha_pic = await get_assets_from_ambr(data['images']['namegacha'])
|
||||
type_pic = Image.open(TEXT_PATH / f'{data["weaponText"]}.png')
|
||||
gacha_pic = await get_assets_from_ambr(data['images']['filename_gacha'])
|
||||
if gacha_pic is None:
|
||||
gacha_pic = Image.new('RGBA', (333, 666))
|
||||
else:
|
||||
@ -100,35 +103,33 @@ async def draw_weapons_wiki_img(data: Weapon, stats: WeaponStats):
|
||||
img.paste(type_pic, (44, 158), type_pic)
|
||||
img.paste(gacha_pic, (134, 81), gacha_pic)
|
||||
img_draw.text((45, 744), '基础攻击力', gray_color, gs_font_18, 'lm')
|
||||
img_draw.text((545, 744), data['substat'], gray_color, gs_font_18, 'rm')
|
||||
|
||||
if data['subvalue'] != '':
|
||||
sub_val = (
|
||||
(data['subvalue'] + '%')
|
||||
if data['substat'] != '元素精通'
|
||||
else data['subvalue']
|
||||
img_draw.text(
|
||||
(545, 744), data['mainStatText'], gray_color, gs_font_18, 'rm'
|
||||
)
|
||||
|
||||
if data['baseStatText'] != '':
|
||||
sub_val = data['baseStatText']
|
||||
else:
|
||||
sub_val = ''
|
||||
|
||||
if data['substat'] != '':
|
||||
if data['mainStatText'] != '':
|
||||
sp = (
|
||||
'%.1f%%' % (stats['specialized'] * 100)
|
||||
if data['substat'] != '元素精通'
|
||||
if data['mainStatText'] != '元素精通'
|
||||
else str(math.ceil(stats['specialized']))
|
||||
)
|
||||
else:
|
||||
sp = ''
|
||||
|
||||
atk = f'{data["baseatk"]}/{math.ceil(stats["attack"])}'
|
||||
atk = f'{int(data["baseAtkValue"])}/{math.ceil(stats["attack"])}'
|
||||
subval = f'{sub_val}/{sp}'
|
||||
|
||||
img_draw.text((45, 779), atk, white_color, gs_font_36, 'lm')
|
||||
img_draw.text((545, 779), subval, white_color, gs_font_36, 'rm')
|
||||
|
||||
effect_name = f'{data["effectname"]}' if data['effectname'] else '无特效'
|
||||
effect_name = f'{data["effectName"]}' if data['effectName'] else '无特效'
|
||||
img_draw.text((46, 837), effect_name, (255, 206, 51), gs_font_28, 'lm')
|
||||
img_draw.text((46, 866), effect, gray_color, gs_font_22)
|
||||
img_draw.text((46, 866), effect_desc, gray_color, gs_font_22)
|
||||
|
||||
# 计算材料
|
||||
temp: Dict[str, List[int]] = {}
|
||||
@ -190,16 +191,16 @@ async def draw_weapons_wiki_img(data: Weapon, stats: WeaponStats):
|
||||
if isinstance(material, int):
|
||||
cost_pic = get_unknown_png()
|
||||
else:
|
||||
name_icon = material['images']['nameicon']
|
||||
name_icon = material['images']['filename_icon']
|
||||
_cost_pic = await get_assets_from_ambr(name_icon)
|
||||
if _cost_pic is None:
|
||||
cost_pic = get_unknown_png()
|
||||
else:
|
||||
cost_pic = _cost_pic.convert('RGBA').resize((64, 64))
|
||||
|
||||
if not cost_pos and material['materialtype'] == '武器突破素材':
|
||||
pos = material['dropdomain']
|
||||
days = material['daysofweek']
|
||||
if not cost_pos and material['typeText'] == '武器突破素材':
|
||||
pos = material['dropDomainName']
|
||||
days = material['daysOfWeek']
|
||||
cost_pos = f'{pos} - {"/".join(days)}'
|
||||
|
||||
t = 100 * index
|
||||
|
@ -25,14 +25,14 @@ async def artifacts_wiki(name: str) -> str:
|
||||
im = '该圣遗物不存在。'
|
||||
else:
|
||||
star = ''
|
||||
for i in data['rarity']:
|
||||
star = star + i + '星、'
|
||||
for i in data['rarityList']:
|
||||
star = f'{star}{i}星、'
|
||||
star = star[:-1]
|
||||
im = artifacts_im.format(
|
||||
data['name'],
|
||||
star,
|
||||
data['2pc'],
|
||||
data['4pc'],
|
||||
data['effect2Pc'],
|
||||
data['effect4Pc'],
|
||||
data['flower']['name'],
|
||||
data['flower']['description'],
|
||||
data['plume']['name'],
|
||||
@ -66,7 +66,7 @@ async def foods_wiki(name: str) -> str:
|
||||
data['name'],
|
||||
data['rarity'],
|
||||
data['foodtype'],
|
||||
data['foodfilter'],
|
||||
data['filterText'],
|
||||
data['effect'],
|
||||
data['description'],
|
||||
ingredients,
|
||||
@ -80,7 +80,7 @@ async def enemies_wiki(name: str) -> str:
|
||||
im = '该原魔不存在。'
|
||||
else:
|
||||
reward = ''
|
||||
for i in data['rewardpreview']:
|
||||
for i in data['rewardPreview']:
|
||||
reward += (
|
||||
f'{i["name"]}:{i["count"] if "count" in i else "未知"}'
|
||||
if 'count' in i.keys()
|
||||
@ -89,7 +89,7 @@ async def enemies_wiki(name: str) -> str:
|
||||
reward += '\n'
|
||||
im = '【{}】\n——{}——\n类型: {}\n信息: {}\n掉落物: \n{}'.format(
|
||||
data['name'],
|
||||
data['specialname'],
|
||||
data['specialName'],
|
||||
data['category'],
|
||||
data['description'],
|
||||
reward,
|
||||
@ -105,32 +105,32 @@ async def weapon_wiki(name: str) -> str:
|
||||
im = ', '.join(data)
|
||||
else:
|
||||
name = data['name']
|
||||
_type = data['weapontype']
|
||||
star = data['rarity'] + '星'
|
||||
_type = data['weaponText']
|
||||
star = str(data['rarity']) + '星'
|
||||
info = data['description']
|
||||
atk = str(data['baseatk'])
|
||||
sub_name = data['substat']
|
||||
if data['subvalue'] != '':
|
||||
sub_val = (
|
||||
(data['subvalue'] + '%')
|
||||
if sub_name != '元素精通'
|
||||
else data['subvalue']
|
||||
)
|
||||
atk = str(int(data['baseAtkValue']))
|
||||
sub_name = data['mainStatText']
|
||||
if data['baseStatText'] != '':
|
||||
sub_val = data['baseStatText']
|
||||
sub = '\n' + '【' + sub_name + '】' + sub_val
|
||||
else:
|
||||
sub = ''
|
||||
|
||||
if data['effectname'] != '':
|
||||
raw_effect = data['effect']
|
||||
if data['effectName'] != '':
|
||||
raw_effect = re.sub(
|
||||
r'</?c[^\u4e00-\u9fa5/d]+>',
|
||||
'',
|
||||
data['effectTemplateRaw'],
|
||||
)
|
||||
rw_ef = []
|
||||
for i in range(len(data['r1'])):
|
||||
for i in range(len(data['r1']["values"])):
|
||||
now = ''
|
||||
for j in range(1, 6):
|
||||
now = now + data['r{}'.format(j)][i] + '/'
|
||||
now = now + data['r{}'.format(j)]["values"][i] + '/'
|
||||
now = now[:-1]
|
||||
rw_ef.append(now)
|
||||
raw_effect = raw_effect.format(*rw_ef)
|
||||
effect = '\n' + '【' + data['effectname'] + '】' + ': ' + raw_effect
|
||||
effect = '\n' + '【' + data['effectName'] + '】' + ': ' + raw_effect
|
||||
else:
|
||||
effect = ''
|
||||
im = weapon_im.format(name, _type, star, info, atk, sub, effect)
|
||||
@ -145,13 +145,13 @@ async def weapon_stats_wiki(name: str, stats: int):
|
||||
elif isinstance(data, List) or isinstance(data2, List):
|
||||
im = '请输入具体的武器名称...'
|
||||
else:
|
||||
if data['substat'] != '':
|
||||
if data['mainStatText'] != '':
|
||||
sp = (
|
||||
data['substat']
|
||||
data['mainStatText']
|
||||
+ ': '
|
||||
+ '%.1f%%' % (data2['specialized'] * 100)
|
||||
if data['substat'] != '元素精通'
|
||||
else data['substat']
|
||||
if data['mainStatText'] != '元素精通'
|
||||
else data['mainStatText']
|
||||
+ ': '
|
||||
+ str(math.floor(data2['specialized']))
|
||||
)
|
||||
@ -202,9 +202,9 @@ async def char_wiki(name: str) -> str:
|
||||
else:
|
||||
name = data['title'] + ' — ' + data['name']
|
||||
star = data['rarity']
|
||||
_type = data['weapontype']
|
||||
element = data['element']
|
||||
up_val = data['substat']
|
||||
_type = data['weaponType']
|
||||
element = data['elementText']
|
||||
up_val = data['substatText']
|
||||
bdday = data['birthday']
|
||||
polar = data['constellation']
|
||||
cv = data['cv']['chinese']
|
||||
@ -224,9 +224,13 @@ async def char_stats_wiki(name: str, stats: int):
|
||||
im = '请输入具体的角色名称...'
|
||||
else:
|
||||
sp = (
|
||||
data2['substat'] + ': ' + '%.1f%%' % (data['specialized'] * 100)
|
||||
if data2['substat'] != '元素精通'
|
||||
else data2['substat'] + ': ' + str(math.floor(data['specialized']))
|
||||
data2['substatText']
|
||||
+ ': '
|
||||
+ '%.1f%%' % (data['specialized'] * 100)
|
||||
if data2['substatText'] != '元素精通'
|
||||
else data2['substatText']
|
||||
+ ': '
|
||||
+ str(math.floor(data['specialized']))
|
||||
)
|
||||
im = (
|
||||
data2['name']
|
||||
@ -295,7 +299,7 @@ async def constellation_wiki(name: str, c: int) -> str:
|
||||
+ '】'
|
||||
+ ': '
|
||||
+ '\n'
|
||||
+ data['c{}'.format(c)]['effect'].replace('*', '')
|
||||
+ data['c{}'.format(c)]['description'].replace('*', '')
|
||||
)
|
||||
return im
|
||||
|
||||
@ -313,7 +317,7 @@ async def talent_wiki(name: str, level: int) -> Union[List[Message], str]:
|
||||
else:
|
||||
data = data['combat3']
|
||||
skill_name = data['name']
|
||||
skill_info = data['info']
|
||||
skill_info = data['description']
|
||||
skill_detail = ''
|
||||
|
||||
mes_list: List[Message] = []
|
||||
@ -392,6 +396,6 @@ async def talent_wiki(name: str, level: int) -> Union[List[Message], str]:
|
||||
else:
|
||||
return '该角色未有第四个被动天赋...'
|
||||
skill_name = data['name']
|
||||
skill_info = data['info']
|
||||
skill_info = data['description']
|
||||
im = '【{}】\n{}'.format(skill_name, skill_info)
|
||||
return im
|
||||
|
@ -164,13 +164,13 @@ async def avatarName2ElementJson() -> None:
|
||||
if 'retcode' in data:
|
||||
data = await convert_ambr_to_minigg(_id)
|
||||
if data is not None and 'code' not in data:
|
||||
temp[name] = elementMap[data['element']]
|
||||
temp[name] = elementMap[data['elementText']]
|
||||
try:
|
||||
nameicon = data['images']['namesideicon'] # type: ignore
|
||||
enName = nameicon.split('_')[-1]
|
||||
enName2Id_result[enName] = _id
|
||||
avatarId2Star_result[int(_id)] = str(data['rarity'])
|
||||
avatarName2Weapon_result[data['name']] = data['weapontype']
|
||||
avatarName2Weapon_result[data['name']] = data['weaponText']
|
||||
except: # noqa: E722
|
||||
adata = httpx.get(
|
||||
f'https://api.ambr.top/v2/chs/avatar/{_id}?vh=40F8'
|
||||
|
@ -91,6 +91,9 @@ extra = {
|
||||
'Q炽鬃拳伤害': '蒸发',
|
||||
'Q焚落踢伤害': '蒸发',
|
||||
},
|
||||
'娜维娅': {
|
||||
'E玫瑰晶弹基础伤害': ['3层', '6层'],
|
||||
},
|
||||
}
|
||||
template = {'A重击伤害': {'name': 'A重击伤害', 'type': '', 'plus': 1, 'value': []}}
|
||||
|
||||
|
@ -71,12 +71,12 @@ WEAPON_TYPE = {
|
||||
|
||||
class ConvertWeapon(TypedDict):
|
||||
name: str
|
||||
weapontype: str
|
||||
weaponText: str
|
||||
rarity: str
|
||||
baseatk: float
|
||||
substat: str
|
||||
effect: str
|
||||
effectname: str
|
||||
baseAtkValue: float
|
||||
mainStatText: str
|
||||
effectTemplateRaw: str
|
||||
effectName: str
|
||||
level: int
|
||||
ascension: int
|
||||
attack: float
|
||||
@ -94,10 +94,10 @@ class Image(TypedDict):
|
||||
|
||||
class ConvertCharacter(TypedDict):
|
||||
name: str
|
||||
weapontype: str
|
||||
weaponText: str
|
||||
rarity: str
|
||||
baseatk: float
|
||||
substat: str
|
||||
substatText: str
|
||||
effect: str
|
||||
effectname: str
|
||||
level: int
|
||||
@ -105,7 +105,7 @@ class ConvertCharacter(TypedDict):
|
||||
attack: float
|
||||
specialized: float
|
||||
title: str
|
||||
element: str
|
||||
elementText: str
|
||||
images: Image
|
||||
hp: float
|
||||
defense: float
|
||||
@ -141,36 +141,32 @@ async def convert_ambr_to_weapon(
|
||||
substat = '无副词条'
|
||||
result = {
|
||||
'name': raw_data['name'],
|
||||
'weapontype': raw_data['type'],
|
||||
'weaponText': raw_data['type'],
|
||||
'rarity': str(raw_data['rank']),
|
||||
'baseatk': baseatk,
|
||||
'substat': substat,
|
||||
'effectname': effect_name,
|
||||
'baseAtkValue': baseatk,
|
||||
'mainStatText': substat,
|
||||
'effectName': effect_name,
|
||||
'level': 90,
|
||||
'ascension': 6,
|
||||
}
|
||||
for index, affix in enumerate(effect_up):
|
||||
effect_value = re.findall(
|
||||
r'<c[^\u4e00-\u9fa5]+>\d+?.?\d+[^\u4e00-\u9fa5]+r>',
|
||||
effect_desc = re.sub(
|
||||
r'</?c[^\u4e00-\u9fa5/d]+>',
|
||||
'',
|
||||
effect_up[affix],
|
||||
)
|
||||
attr_list = []
|
||||
if index == 0:
|
||||
result['effect'] = effect_up[affix]
|
||||
for i, v in enumerate(effect_value):
|
||||
if index == 0:
|
||||
result['effect'] = result['effect'].replace(v, f'{{{i}}}')
|
||||
r = re.search(r'>([0-9/.%]+)', v)
|
||||
if r:
|
||||
attr_list.append(r.group(1))
|
||||
result[f'r{index+1}'] = attr_list
|
||||
|
||||
result[f'r{index+1}'] = {'description': effect_desc}
|
||||
|
||||
atk_curve_type = upgrade['prop'][0]['type']
|
||||
sp_curve_type = upgrade['prop'][1]['type']
|
||||
atk_curve = WEAPON_GROW_CURVE['90']['curveInfos'][atk_curve_type]
|
||||
sp_curve = WEAPON_GROW_CURVE['90']['curveInfos'][sp_curve_type]
|
||||
atk_promoto = upgrade['promote'][-1]['addProps']['FIGHT_PROP_BASE_ATTACK']
|
||||
|
||||
result['attack'] = atk_curve * baseatk + atk_promoto
|
||||
result['specialized'] = sp_curve * basesp
|
||||
|
||||
return cast(ConvertWeapon, result)
|
||||
|
||||
|
||||
@ -187,7 +183,7 @@ async def convert_ambr_to_minigg(
|
||||
'weapontype': WEAPON_TYPE[raw_data['weaponType']],
|
||||
'element': ELEMENT_MAP[raw_data['element']],
|
||||
'images': {'namesideicon': raw_data['icon']}, # 暂时适配
|
||||
'substat': PROP_MAP[
|
||||
'substatText': PROP_MAP[
|
||||
list(raw_data['upgrade']['promote'][-1]['addProps'].keys())[-1]
|
||||
],
|
||||
'hp': raw_data['upgrade']['prop'][0]['initValue']
|
||||
|
Loading…
x
Reference in New Issue
Block a user