🚨修复大部分已知错误

This commit is contained in:
qwerdvd 2023-05-13 17:21:03 +08:00
parent 697e3d0050
commit a15a01fd40
2 changed files with 67 additions and 33 deletions

View File

@ -99,12 +99,12 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
# 放角色名 # 放角色名
char_img_draw = ImageDraw.Draw(char_info) char_img_draw = ImageDraw.Draw(char_info)
char_img_draw.text( char_img_draw.text(
(690, 175), char.char_name, white_color, sr_font_38, 'mm' (705, 175), char.char_name, white_color, sr_font_38, 'mm'
) )
# 放等级 # 放等级
char_img_draw.text( char_img_draw.text(
(765, 183), f'LV.{str(char.char_level)}', white_color, sr_font_20, 'mm' (790, 183), f'LV.{str(char.char_level)}', white_color, sr_font_20, 'mm'
) )
# 放星级 # 放星级
@ -121,6 +121,11 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
) )
char_info.paste(rank_img, (772, 190), rank_img) char_info.paste(rank_img, (772, 190), rank_img)
# # 放uid
# char_img_draw.text(
# (750, 290), f'UID: {sr_uid}', white_color, sr_font_23, 'mm'
# )
# 放属性列表 # 放属性列表
attr_bg = Image.open(TEXT_PATH / 'attr_bg.png') attr_bg = Image.open(TEXT_PATH / 'attr_bg.png')
attr_bg_draw = ImageDraw.Draw(attr_bg) attr_bg_draw = ImageDraw.Draw(attr_bg)
@ -136,7 +141,14 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
hp = int(mp.floor(hp)) hp = int(mp.floor(hp))
add_hp = int(mp.floor(add_hp)) add_hp = int(mp.floor(add_hp))
attr_bg_draw.text( attr_bg_draw.text(
(500, 31), f'{hp + add_hp} (+{add_hp})', white_color, sr_font_26, 'rm' (415, 31), f'{hp + add_hp}', white_color, sr_font_26, 'rm'
)
attr_bg_draw.text(
(430, 31),
f'(+{str(round(add_hp))})',
(95, 251, 80),
sr_font_26,
anchor='lm',
) )
# 攻击力 # 攻击力
attack = mp.mpf(char.base_attributes['attack']) attack = mp.mpf(char.base_attributes['attack'])
@ -150,12 +162,19 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
atk = int(mp.floor(attack)) atk = int(mp.floor(attack))
add_attack = int(mp.floor(add_attack)) add_attack = int(mp.floor(add_attack))
attr_bg_draw.text( attr_bg_draw.text(
(500, 31 + 48), (415, 31 + 48),
f'{atk + add_attack} (+{add_attack})', f'{atk + add_attack}',
white_color, white_color,
sr_font_26, sr_font_26,
'rm', 'rm',
) )
attr_bg_draw.text(
(430, 31 + 48),
f'(+{str(round(add_attack))})',
(95, 251, 80),
sr_font_26,
anchor='lm',
)
# 防御力 # 防御力
defence = mp.mpf(char.base_attributes['defence']) defence = mp.mpf(char.base_attributes['defence'])
add_defence = mp.mpf( add_defence = mp.mpf(
@ -170,12 +189,19 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
defence = int(mp.floor(defence)) defence = int(mp.floor(defence))
add_defence = int(mp.floor(add_defence)) add_defence = int(mp.floor(add_defence))
attr_bg_draw.text( attr_bg_draw.text(
(500, 31 + 48 * 2), (415, 31 + 48 * 2),
f'{defence + add_defence} (+{add_defence})', f'{defence + add_defence}',
white_color, white_color,
sr_font_26, sr_font_26,
'rm', 'rm',
) )
attr_bg_draw.text(
(430, 31 + 48 * 2),
f'(+{str(round(add_defence))})',
(95, 251, 80),
sr_font_26,
anchor='lm',
)
# 速度 # 速度
speed = mp.mpf(char.base_attributes['speed']) speed = mp.mpf(char.base_attributes['speed'])
add_speed = mp.mpf( add_speed = mp.mpf(
@ -184,12 +210,19 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
speed = int(mp.floor(speed)) speed = int(mp.floor(speed))
add_speed = int(mp.floor(add_speed)) add_speed = int(mp.floor(add_speed))
attr_bg_draw.text( attr_bg_draw.text(
(500, 31 + 48 * 3), (415, 31 + 48 * 3),
f'{speed + add_speed} (+{add_speed})', f'{speed + add_speed}',
white_color, white_color,
sr_font_26, sr_font_26,
'rm', 'rm',
) )
attr_bg_draw.text(
(430, 31 + 48 * 3),
f'(+{str(round(add_speed))})',
(95, 251, 80),
sr_font_26,
anchor='lm',
)
# 暴击率 # 暴击率
critical_chance = mp.mpf(char.base_attributes['CriticalChance']) critical_chance = mp.mpf(char.base_attributes['CriticalChance'])
critical_chance_base = mp.mpf( critical_chance_base = mp.mpf(
@ -304,11 +337,11 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
'lm', 'lm',
) )
skill_panel_img_draw.text( skill_panel_img_draw.text(
(60, 88), (75, 90),
f'{skill["skillName"]}', f'{skill["skillName"]}',
(105, 105, 105), (105, 105, 105),
sr_font_20, sr_font_20,
'lm', 'mm',
) )
skill_bg.paste(skill_panel_img, (50 + 187 * i, 35), skill_panel_img) skill_bg.paste(skill_panel_img, (50 + 187 * i, 35), skill_panel_img)
i += 1 i += 1
@ -383,7 +416,7 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
TEXT_PATH TEXT_PATH
/ f'LightCore_Rarity{RelicId2Rarity[str(relic["relicId"])]}.png' / f'LightCore_Rarity{RelicId2Rarity[str(relic["relicId"])]}.png'
).resize((200, 48)) ).resize((200, 48))
relic_img.paste(rarity_img, (-20, 80), rarity_img) relic_img.paste(rarity_img, (-10, 80), rarity_img)
relic_img_draw = ImageDraw.Draw(relic_img) relic_img_draw = ImageDraw.Draw(relic_img)
if len(relic['relicName']) <= 5: if len(relic['relicName']) <= 5:
main_name = relic['relicName'] main_name = relic['relicName']
@ -405,7 +438,7 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
if main_name in ['攻击力', '生命值', '防御力', '速度']: if main_name in ['攻击力', '生命值', '防御力', '速度']:
mainValueStr = nstr(main_value, 3) mainValueStr = nstr(main_value, 3)
else: else:
mainValueStr = nstr(main_value * 100, 3) + '%' mainValueStr = str(math.floor(main_value * 1000) / 10) + '%'
mainNameNew = ( mainNameNew = (
main_name.replace('百分比', '') main_name.replace('百分比', '')
@ -428,7 +461,7 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
anchor='lm', anchor='lm',
) )
relic_img_draw.text( relic_img_draw.text(
(250, 60), (180, 105),
'+{}'.format(str(main_level)), '+{}'.format(str(main_level)),
(255, 255, 255), (255, 255, 255),
sr_font_23, sr_font_23,

View File

@ -78,13 +78,13 @@ async def api_to_dict(
char_dict_list = [] char_dict_list = []
im = f'UID: {sr_uid} 的角色展柜刷新成功\n' im = f'UID: {sr_uid} 的角色展柜刷新成功\n'
if PlayerDetailInfo['AssistAvatar']: if PlayerDetailInfo.get('AssistAvatar'):
char_dict, avatarName = await get_data( char_dict, avatarName = await get_data(
PlayerDetailInfo['AssistAvatar'], sr_data, sr_uid PlayerDetailInfo['AssistAvatar'], sr_data, sr_uid
) )
im += f'支援角色 {avatarName}\n' im += f'支援角色 {avatarName}\n'
char_dict_list.append(char_dict) char_dict_list.append(char_dict)
if PlayerDetailInfo['IsDisplayAvatarList']: if PlayerDetailInfo.get('DisplayAvatarList'):
im += '星海同行' im += '星海同行'
for char in PlayerDetailInfo['DisplayAvatarList']: for char in PlayerDetailInfo['DisplayAvatarList']:
char_dict, avatarName = await get_data(char, sr_data, sr_uid) char_dict, avatarName = await get_data(char, sr_data, sr_uid)
@ -199,23 +199,24 @@ async def get_data(char: dict, sr_data: dict, sr_uid: str):
relic_temp['MainAffix']['Value'] = value relic_temp['MainAffix']['Value'] = value
relic_temp['SubAffixList'] = [] relic_temp['SubAffixList'] = []
for sub_affix in relic['RelicSubAffix']: if relic.get('RelicSubAffix'):
sub_affix_temp = {} for sub_affix in relic['RelicSubAffix']:
sub_affix_temp['SubAffixID'] = sub_affix['SubAffixID'] sub_affix_temp = {}
sub_affix_property, value = await cal_relic_sub_affix( sub_affix_temp['SubAffixID'] = sub_affix['SubAffixID']
relic_id=relic['ID'], sub_affix_property, value = await cal_relic_sub_affix(
affix_id=sub_affix['SubAffixID'], relic_id=relic['ID'],
cnt=sub_affix['Cnt'], affix_id=sub_affix['SubAffixID'],
step=sub_affix['Step'] if 'Step' in sub_affix else 0, cnt=sub_affix['Cnt'],
) step=sub_affix['Step'] if 'Step' in sub_affix else 0,
sub_affix_temp['Property'] = sub_affix_property )
sub_affix_temp['Name'] = Property2Name[sub_affix_property] sub_affix_temp['Property'] = sub_affix_property
sub_affix_temp['Cnt'] = sub_affix['Cnt'] sub_affix_temp['Name'] = Property2Name[sub_affix_property]
sub_affix_temp['Step'] = ( sub_affix_temp['Cnt'] = sub_affix['Cnt']
sub_affix['Step'] if 'Step' in sub_affix else 0 sub_affix_temp['Step'] = (
) sub_affix['Step'] if 'Step' in sub_affix else 0
sub_affix_temp['Value'] = value )
relic_temp['SubAffixList'].append(sub_affix_temp) sub_affix_temp['Value'] = value
relic_temp['SubAffixList'].append(sub_affix_temp)
char_data['RelicInfo'].append(relic_temp) char_data['RelicInfo'].append(relic_temp)
# 处理命座 # 处理命座