优化ysd卡片和部分消息提示

This commit is contained in:
CMHopeSunshine 2022-08-25 13:26:52 +08:00
parent 206b86ea90
commit 04b5b31852
9 changed files with 1605 additions and 1959 deletions

View File

@ -7,7 +7,7 @@ from LittlePaimon.utils.migration import migrate_database
from LittlePaimon.utils.tool import check_resource
DRIVER = get_driver()
__version__ = '3.0.0beta1'
__version__ = '3.0.0beta2'
try:
SUPERUSERS: List[int] = [int(s) for s in DRIVER.config.superusers]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ weapon_map = load_json(JSON_DATA / 'weapon.json')
prop_list_map = load_json(JSON_DATA / 'prop.json')
artifact_map = load_json(JSON_DATA / 'artifact.json')
score_talent_map = load_json(JSON_DATA / 'score.json')
enka_icon_map = load_json(JSON_DATA / 'enka_icon.json')
enka_icon_map = load_json(JSON_DATA / 'genshin_info.json')
reaction_coefficient = {
'蒸发': 0,
'融化': 0,
@ -165,6 +165,9 @@ class Artifacts(BaseModel):
def append(self, artifact: Artifact):
self.artifact_list.append(artifact)
def index(self, artifact: Artifact) -> int:
return self.artifact_list.index(artifact)
class Constellation(BaseModel):
"""命座数据"""
@ -325,14 +328,13 @@ class Character(Model):
data['skillLevelMap'][
list(data['skillLevelMap'].keys())[score_talent_map['Talent'][role_name][1]]] += 3
if character.name in ['神里绫华', '莫娜']:
del data['skillLevelMap'][list(data['skillLevelMap'].keys())[2]]
character.talents = Talents(talent_list=[Talent(name=role_skill_map['Name'][talent],
level=data['skillLevelMap'][talent],
icon=role_skill_map['Icon'][talent]) for talent in
data['skillLevelMap']])
if character.name == '神里绫华':
character.talents[0], character.talents[-1] = character.talents[-1], character.talents[0]
character.talents[2], character.talents[-1] = character.talents[-1], character.talents[2]
if character.name == '安柏':
character.talents[0], character.talents[-1] = character.talents[-1], character.talents[0]
if character.name in ['', '']:
@ -431,7 +433,6 @@ class Character(Model):
range(data['actived_constellation_num'])
])
if character.name in ['', '']:
# TODO 草主
character.fetter = 10
character.element = '' if data['element'] == 'Geo' else '' if data['element'] == 'Anemo' else '' if data['element'] == 'Dendro' else ''
role_name = character.element + ''
@ -446,10 +447,10 @@ class Character(Model):
data['skill_list'][score_talent_map['Talent'][role_name][0]]['level_current'] += 3
if len(data['talentIdList']) >= 5:
data['skill_list'][score_talent_map['Talent'][role_name][1]]['level_current'] += 3
talents_list = data['skill_list'][:3]
if character.name in ['莫娜', '神里绫华']:
talents_list[-1] = data['skill_list'][3]
elif character.name == '达达利亚':
del data['skill_list'][2]
talents_list = data['skill_list'][:3]
if character.name == '达达利亚':
talents_list[0]['level_current'] += 1
character.talents = Talents(talent_list=[Talent(name=t['name'],
level=t['level_current'],

View File

@ -863,32 +863,32 @@ async def draw_dmg_pic(dmg: Dict[str, Union[tuple, list]]) -> PMImage:
:return: 伤害图片
"""
height = 60 * len(dmg) - 20
img = PMImage(size=(948, height + 80), color=(0, 0, 0, 0), mode='RGBA')
await img.draw_rounded_rectangle((0, 0, img.width, img.height), 10, (0, 0, 0, 100))
await img.draw_line((250, 0), (250, 948), (255, 255, 255, 75), 2)
await img.draw_line((599, 0), (599, 60), (255, 255, 255, 75), 2)
await img.draw_line((0, 60), (948, 60), (255, 255, 255, 75), 2)
img = PMImage(size=(1002, height + 80), color=(0, 0, 0, 0), mode='RGBA')
await img.draw_rounded_rectangle((0, 0, img.width, img.height), 10, (14, 41, 68, 115))
await img.draw_line((250, 0), (250, 1002), (255, 255, 255, 75), 2)
await img.draw_line((626, 0), (626, 60), (255, 255, 255, 75), 2)
await img.draw_line((0, 60), (1002, 60), (255, 255, 255, 75), 2)
await img.text('伤害计算', (0, 250), (0, 60), font_manager.get('hywh.ttf', 30), 'white', 'center')
await img.text('期望伤害', (250, 599), (0, 60), font_manager.get('hywh.ttf', 30), 'white', 'center')
await img.text('暴击伤害', (599, 948), (0, 60), font_manager.get('hywh.ttf', 30), 'white', 'center')
await img.text('期望伤害', (250, 626), (0, 60), font_manager.get('hywh.ttf', 30), 'white', 'center')
await img.text('暴击伤害', (626, 1002), (0, 60), font_manager.get('hywh.ttf', 30), 'white', 'center')
i = 1
for describe, dmg_list in dmg.items():
await img.draw_line((0, 60 * i), (948, 60 * i), (255, 255, 255, 75), 2)
await img.draw_line((0, 60 * i), (1002, 60 * i), (255, 255, 255, 75), 2)
await img.text(describe, (0, 250), (60 * i, 60 * (i + 1)), font_manager.get('hywh.ttf', 30), 'white', 'center')
if len(dmg_list) == 1:
if describe == '额外说明':
await img.text(dmg_list[0], (250, 948), (60 * i, 60 * (i + 1)), font_manager.get('hywh.ttf', 30),
await img.text(dmg_list[0], (250, 1002), (60 * i, 60 * (i + 1)), font_manager.get('hywh.ttf', 30),
'white',
'center')
else:
await img.text(dmg_list[0], (250, 948), (60 * i, 60 * (i + 1)), font_manager.get('number.ttf', 30),
await img.text(dmg_list[0], (250, 1002), (60 * i, 60 * (i + 1)), font_manager.get('number.ttf', 30),
'white',
'center')
else:
await img.draw_line((599, 60 * i), (599, 60 * (i + 1)), (255, 255, 255, 75), 2)
await img.text(dmg_list[0], (250, 599), (60 * i, 60 * (i + 1)), font_manager.get('number.ttf', 30), 'white',
await img.draw_line((626, 60 * i), (626, 60 * (i + 1)), (255, 255, 255, 75), 2)
await img.text(dmg_list[0], (250, 626), (60 * i, 60 * (i + 1)), font_manager.get('number.ttf', 30), 'white',
'center')
await img.text(dmg_list[1], (599, 948), (60 * i, 60 * (i + 1)), font_manager.get('number.ttf', 30), 'white',
await img.text(dmg_list[1], (626, 1002), (60 * i, 60 * (i + 1)), font_manager.get('number.ttf', 30), 'white',
'center')
i += 1

View File

@ -1,10 +1,11 @@
from nonebot import logger
from LittlePaimon.config.path import ENKA_RES, RESOURCE_BASE_PATH
from LittlePaimon.utils import load_image, aiorequests
from LittlePaimon.utils import load_image
from LittlePaimon.utils.genshin import GenshinTools
from LittlePaimon.utils.image import PMImage, font_manager as fm
from LittlePaimon.utils.message import MessageBuild
from LittlePaimon.utils.alias import get_icon
from LittlePaimon.database.models import Character
from .damage_cal import get_role_dmg
@ -22,11 +23,7 @@ ICON = RESOURCE_BASE_PATH / 'icon'
async def draw_chara_detail(uid: str, info: Character):
# 暂时用风
if info.element == '':
img = PMImage(image=ENKA_RES / f'背景_风.png')
else:
img = PMImage(image=ENKA_RES / f'背景_{info.element}.png')
img = PMImage(await load_image(ENKA_RES / f'背景_{info.element}.png'))
try:
dmg_img = await get_role_dmg(info)
except Exception as e:
@ -34,87 +31,95 @@ async def draw_chara_detail(uid: str, info: Character):
dmg_img = None
if dmg_img:
await img.stretch((730, 1377), dmg_img.height + 667, 'height')
await img.paste(dmg_img, (71, 1846))
await img.paste(await load_image(ENKA_RES / '底遮罩.png'), (0, 0))
if info.name not in ['', '', '埃洛伊']:
await img.paste(await load_image(ENKA_RES / f'{info.region}.png', size=(130, 130)), (0, 0))
await img.paste(dmg_img, (42, 1820))
await img.text(f"UID{uid}", 131, 100, fm.get('number.ttf', 48))
await img.text(info.name, 134, 150, fm.get('优设标题黑.ttf', 72))
# 立绘
chara_img = await load_image(RESOURCE_BASE_PATH / 'splash' / f'{get_icon(chara_id=info.character_id, icon_type="splash")}.png')
if chara_img.height >= 630:
chara_img = chara_img.resize((chara_img.width * 630 // chara_img.height, 630))
await img.paste(chara_img, (770 - chara_img.width // 2, 20))
await img.paste(await load_image(ENKA_RES / '底遮罩.png'), (0, 0))
# 地区
if info.name not in ['', '', '埃洛伊']:
await img.paste(await load_image(ENKA_RES / f'{info.region}.png', size=(108, 108)), (25, 25))
await img.text(f"UID{uid}", 160, 100, fm.get('number.ttf', 48))
await img.text(info.name, 45, 150, fm.get('优设标题黑.ttf', 72))
name_length = img.text_length(info.name, fm.get('优设标题黑.ttf', 72))
level_mask = await load_image(ENKA_RES / '等级遮罩.png')
await img.paste(level_mask, (298 + 60 * (len(info.name) - 2), 172))
await img.paste(level_mask, (45 + name_length + 25, 172))
await img.text(f'LV{info.level}',
(298 + 60 * (len(info.name) - 2), 298 + 60 * (len(info.name) - 2) + 171),
(170, 172 + 52),
(40 + name_length + 25, 40 + name_length + 25 + 171),
(172, 172 + 52),
fm.get('number.ttf', 48),
'black',
'#0e2944',
'center')
# 属性值
await img.text('生命值', 89, 262, fm.get('hywh.ttf', 34))
await img.text('生命值', 59, 267, fm.get('hywh.ttf', 34))
await img.text(f"{info.prop.base_health}",
480 - img.text_length(f"+{info.prop.extra_health}", fm.get('number.ttf', 34)) - 5,
264,
450 - img.text_length(f"+{info.prop.extra_health}", fm.get('number.ttf', 34)) - 5,
269,
fm.get('number.ttf', 34),
align='right')
await img.text(f"+{info.prop.extra_health}",
480,
264,
450,
269,
fm.get('number.ttf', 34),
'#59c538',
'right')
await img.text('攻击力', 89, 319, fm.get('hywh.ttf', 34))
await img.text('攻击力', 59, 324, fm.get('hywh.ttf', 34))
await img.text(f"{info.prop.base_attack}",
480 - img.text_length(f"+{info.prop.extra_attack}", fm.get('number.ttf', 34)) - 5,
321,
450 - img.text_length(f"+{info.prop.extra_attack}", fm.get('number.ttf', 34)) - 5,
326,
fm.get('number.ttf', 34),
align='right')
await img.text(f"+{info.prop.extra_attack}",
480,
321,
450,
326,
fm.get('number.ttf', 34),
'#59c538',
'right')
await img.text('防御力', 89, 377, fm.get('hywh.ttf', 34))
await img.text('防御力', 59, 382, fm.get('hywh.ttf', 34))
await img.text(f"{info.prop.base_defense}",
480 - img.text_length(f"+{info.prop.extra_defense}", fm.get('number.ttf', 34)) - 5,
379,
450 - img.text_length(f"+{info.prop.extra_defense}", fm.get('number.ttf', 34)) - 5,
384,
fm.get('number.ttf', 34),
align='right')
await img.text(f"+{info.prop.extra_defense}",
480,
379,
450,
384,
fm.get('number.ttf', 34),
'#59c538',
'right')
await img.text('暴击率', 89, 436, fm.get('hywh.ttf', 34))
await img.text('暴击率', 59, 441, fm.get('hywh.ttf', 34))
await img.text(f"{round(info.prop.crit_rate * 100, 1)}%",
480,
438,
450,
443,
fm.get('number.ttf', 34),
align='right')
await img.text('暴击伤害', 89, 493, fm.get('hywh.ttf', 34))
await img.text('暴击伤害', 59, 498, fm.get('hywh.ttf', 34))
await img.text(f"{round(info.prop.crit_damage * 100, 1)}%",
480,
495,
450,
500,
fm.get('number.ttf', 34),
align='right')
await img.text('元素精通', 89, 551, fm.get('hywh.ttf', 34))
await img.text('元素精通', 59, 556, fm.get('hywh.ttf', 34))
await img.text(str(int(info.prop.elemental_mastery)),
480,
553,
450,
558,
fm.get('number.ttf', 34),
align='right')
await img.text('元素充能效率', 89, 610, fm.get('hywh.ttf', 34))
await img.text('元素充能效率', 59, 615, fm.get('hywh.ttf', 34))
await img.text(f"{round(info.prop.elemental_efficiency * 100, 1)}%",
480,
612,
450,
617,
fm.get('number.ttf', 34),
align='right')
@ -123,99 +128,91 @@ async def draw_chara_detail(uid: str, info: Character):
if v >= max_element[1]:
max_element = e, v
await img.text(f'{max_element[0]}伤害加成' if max_element[0] == '物理' else f'{max_element[0]}元素伤害加成',
89,
669,
59,
674,
fm.get('hywh.ttf', 34))
await img.text(f"{round(max_element[1] * 100, 1)}%",
480,
671,
450,
676,
fm.get('number.ttf', 34),
align='right')
# 天赋
if info.element == '':
base_icon = await load_image(ENKA_RES / '图标_风.png', mode='RGBA')
else:
base_icon = await load_image(ENKA_RES / f'图标_{info.element}.png', mode='RGBA')
base_icon = await load_image(ENKA_RES / f'图标_{info.element}.png', mode='RGBA')
base_icon_grey = await load_image(ENKA_RES / '图标_灰.png', mode='RGBA')
if info.name in ['神里绫华', '莫娜']:
info.talents.pop(2)
for i in range(3):
await img.paste(base_icon.resize((132, 142)), (564, 253 + 146 * i))
await img.paste(base_icon.resize((132, 142)), (551 + i * 176, 633))
await img.text(str(info.talents[i].level),
(510, 552),
(304 + 146 * i, 349 + 146 * i),
(517 + 176 * i, 559 + 176 * i),
690,
fm.get('number.ttf', 34),
'black',
'#0e2944',
'center')
talent_icon = await load_image(TALENT_ICON / f'{info.talents[i].icon}.png', size=(57, 57), mode='RGBA')
await img.paste(talent_icon, (603, 298 + 147 * i))
await img.paste(await load_image(TALENT_ICON / f'{info.talents[i].icon}.png', size=(57, 57), mode='RGBA'), (588 + i * 176, 679))
# 命座
lock = await load_image(ENKA_RES / '锁.png', mode='RGBA', size=(45, 45))
t = 0
for con in info.constellation:
await img.paste(base_icon.resize((83, 90)), (510 + t * 84, 790))
await img.paste(base_icon.resize((83, 90)), (510 + t * 84, 805))
con_icon = await load_image(TALENT_ICON / f'{con.icon}.png', size=(45, 45), mode='RGBA')
await img.paste(con_icon, (529 + t * 84, 813))
await img.paste(con_icon, (529 + t * 84, 828))
t += 1
for t2 in range(t, 6):
await img.paste(base_icon_grey.resize((83, 90)), (510 + t2 * 84, 790))
await img.paste(lock, (530 + t2 * 84, 813))
await img.paste(base_icon_grey.resize((83, 90)), (510 + t2 * 84, 805))
await img.paste(lock, (530 + t2 * 84, 828))
# 武器
weapon_bg = await load_image(ICON / f'star{info.weapon.rarity}.png', size=(150, 150))
await img.paste(weapon_bg, (91, 760))
await img.paste(weapon_bg, (59, 757))
weapon_icon = await load_image(WEAPON_ICON / f'{info.weapon.icon}.png', size=(150, 150), mode='RGBA')
await img.paste(weapon_icon, (91, 760))
await img.text(info.weapon.name, 268, 758, fm.get('hywh.ttf', 34))
await img.paste(weapon_icon, (59, 757))
await img.text(info.weapon.name, 254, 759, fm.get('hywh.ttf', 34))
star = await load_image(ENKA_RES / 'star.png')
for i in range(info.weapon.rarity):
await img.paste(star, (267 + i * 30, 799))
await img.paste(star, (254 + i * 30, 798))
await img.text(f'LV{info.weapon.level}',
(268, 268 + 98),
(835, 864),
(254, 254 + 98),
(834, 864),
fm.get('number.ttf', 27),
'black',
'#0e2944',
'center')
await img.text(f'精炼{info.weapon.affix_level}', 266, 869, fm.get('hywh.ttf', 34))
await img.text(f'精炼{info.weapon.affix_level}', 254, 879, fm.get('hywh.ttf', 34))
# 圣遗物
effective = GenshinTools.get_effective(info)
average = GenshinTools.get_expect_score(effective)
total_score = 0
# 第一排
for i in range(2):
try:
artifact = info.artifacts[i]
except IndexError:
break
artifact_bg = await load_image(RESOURCE_BASE_PATH / 'other' / f'star{artifact.rarity}.png', size=(100, 100))
await img.paste(artifact_bg, (587 + 317 * i, 1002))
artifact_icon = await load_image(ARTIFACT_ICON / f'{artifact.icon}.png', size=(100, 100), mode='RGBA')
await img.paste(artifact_icon, (587 + 317 * i, 1002))
await img.text(artifact.name, 411 + 317 * i, 951, fm.get('hywh.ttf', 40))
w = 380
h = 937
for artifact in info.artifacts:
artifact_bg = await load_image(ICON / f'star{artifact.rarity}.png', size=(93, 93))
await img.paste(artifact_bg, (216 + w, 70 + h))
a_icon = await load_image(ARTIFACT_ICON / f'{artifact.icon}.png', size=(93, 93), mode='RGBA')
await img.paste(a_icon, (217 + w, 70 + h))
await img.text(artifact.name, 22 + w, 24 + h, fm.get('hywh.ttf', 36))
value, score = GenshinTools.artifact_score(info.prop, artifact, effective)
total_score += value
rank = 'SSS' if score >= 140 else 'SS' if 120 <= score < 140 else 'S' if 100 <= score < 120 else 'A' if 75 <= score < 100 else 'B' if 50 <= score < 75 else 'C'
await img.text(f'{rank}-{value}', 412 + 317 * i, 998, fm.get('number.ttf', 28))
await img.paste(level_mask.resize((98, 30)), (412 + 317 * i, 1032))
await img.text(f"LV{artifact.level}",
(412 + 317 * i, 412 + 317 * i + 98),
(1032, 1062),
await img.text(f'{rank}-{value}', 22 + w, 66 + h, fm.get('number.ttf', 28), '#ffde6b')
await img.paste(level_mask.resize((98, 30)), (21 + w, 97 + h))
await img.text(f"+{artifact.level}",
(21 + w, 21 + w + 98),
99 + h,
fm.get('number.ttf', 27),
'black',
'center')
await img.text(artifact.main_property.name, 410 + 317 * i, 1069, fm.get('hywh.ttf', 25))
await img.text(artifact.main_property.name, 21 + w, 134 + h, fm.get('hywh.ttf', 25))
value_text = f'+{artifact.main_property.value}%' if artifact.main_property.name not in ['生命值', '攻击力', '元素精通'] else f'+{int(artifact.main_property.value)}'
await img.text(value_text, 408 + 317 * i, 1100, font=fm.get('number.ttf', 48))
await img.text(value_text, 21 + w, 168 + h, font=fm.get('number.ttf', 48))
for j in range(len(artifact.prop_list)):
if '百分比' in artifact.prop_list[j].name:
text = artifact.prop_list[j].name.replace('百分比', '')
else:
text = artifact.prop_list[j].name
await img.text(text, 411 + 317 * i, 1163 + 50 * j,
await img.text(text, 21 + w, 230 + h + 50 * j,
color='white' if GenshinTools.check_effective(artifact.prop_list[j].name,
effective) else '#afafaf',
font=fm.get('hywh.ttf', 25))
@ -223,107 +220,67 @@ async def draw_chara_detail(uid: str, info: Character):
num = '+' + str(artifact.prop_list[j].value) + '%'
else:
num = '+' + str(int(artifact.prop_list[j].value))
await img.text(num, 679 + 317 * i, 1163 + 50 * j,
color='white' if GenshinTools.check_effective(artifact.prop_list[j].name,
effective) else '#afafaf',
font=fm.get('number.ttf', 25), align='right')
# 第二排
for i in range(3):
try:
artifact = info.artifacts[i + 2]
except IndexError:
break
artifact_bg = await load_image(RESOURCE_BASE_PATH / 'other' / f'star{artifact.rarity}.png', size=(100, 100))
await img.paste(artifact_bg, (270 + 317 * i, 1439))
artifact_icon = await load_image(ARTIFACT_ICON / f'{artifact.icon}.png', size=(100, 100), mode='RGBA')
await img.paste(artifact_icon, (270 + 317 * i, 1439))
await img.text(artifact.name, 94 + 317 * i, 1388, fm.get('hywh.ttf', 40))
value, score = GenshinTools.artifact_score(info.prop, artifact, effective)
total_score += value
rank = 'SSS' if score >= 140 else 'SS' if 120 <= score < 140 else 'S' if 100 <= score < 120 else 'A' if 75 <= score < 100 else 'B' if 50 <= score < 75 else 'C'
await img.text(f'{rank}-{value}', 95 + 317 * i, 1435, fm.get('number.ttf', 28))
await img.paste(level_mask.resize((98, 30)), (95 + 317 * i, 1469))
await img.text(f"LV{artifact.level}",
(95 + 317 * i, 95 + 317 * i + 98),
(1469, 1499),
fm.get('number.ttf', 27),
'black',
'center')
await img.text(artifact.main_property.name, 94 + 317 * i, 1506, fm.get('hywh.ttf', 25))
value_text = f'+{artifact.main_property.value}%' if artifact.main_property.name not in ['生命值', '攻击力',
'元素精通'] else f'+{int(artifact.main_property.value)}'
await img.text(value_text, 91 + 317 * i, 1538, font=fm.get('number.ttf', 48))
for j in range(len(artifact.prop_list)):
if '百分比' in artifact.prop_list[j].name:
text = artifact.prop_list[j].name.replace('百分比', '')
else:
text = artifact.prop_list[j].name
await img.text(text, 94 + 317 * i, 1600 + 50 * j,
color='white' if GenshinTools.check_effective(artifact.prop_list[j].name,
effective) else '#afafaf',
font=fm.get('hywh.ttf', 25))
if artifact.prop_list[j].name not in ['攻击力', '防御力', '生命值', '元素精通']:
num = '+' + str(artifact.prop_list[j].value) + '%'
else:
num = '+' + str(int(artifact.prop_list[j].value))
await img.text(num, 362 + 317 * i, 1600 + 50 * j,
await img.text(num, 307 + w, 230 + h + 50 * j,
color='white' if GenshinTools.check_effective(artifact.prop_list[j].name,
effective) else '#afafaf',
font=fm.get('number.ttf', 25), align='right')
if info.artifacts.index(artifact) == 1:
w = 42
h += 437
else:
w += 338
# 圣遗物评分
await img.text('总有效词条数', 119, 1057, color='#afafaf', font=fm.get('hywh.ttf', 36))
score_pro = total_score / (average * 5) * 100
total_rank = 'SSS' if score_pro >= 140 else 'SS' if 120 <= score_pro < 140 else 'S' if 100 <= score_pro < 120 else 'A' if 75 <= score_pro < 100 else 'B' if 50 <= score_pro < 75 else 'C'
rank_icon = await load_image(ENKA_RES / f'评分{total_rank[0]}.png', mode='RGBA')
if len(total_rank) == 3:
await img.paste(rank_icon, (65, 964))
await img.paste(rank_icon, (115, 964))
await img.paste(rank_icon, (165, 964))
await img.text(str(round(total_score, 1)), 220, 974, font=fm.get('number.ttf', 60))
elif len(total_rank) == 2:
await img.paste(rank_icon, (95, 964))
await img.paste(rank_icon, (145, 964))
await img.paste(rank_icon, (195, 964))
await img.text(str(round(total_score, 1)), 250, 974, font=fm.get('number.ttf', 60))
elif len(total_rank) == 2:
await img.paste(rank_icon, (125, 964))
await img.paste(rank_icon, (175, 964))
await img.text(str(round(total_score, 1)), 235, 974, font=fm.get('number.ttf', 60))
await img.text(str(round(total_score, 1)), 205, 974, font=fm.get('number.ttf', 60))
else:
await img.paste(rank_icon, (143, 964))
await img.text(str(round(total_score, 1)), 217, 974, font=fm.get('number.ttf', 60))
await img.paste(rank_icon, (113, 964))
await img.text(str(round(total_score, 1)), 187, 974, font=fm.get('number.ttf', 60))
# 圣遗物套装
suit = GenshinTools.get_artifact_suit(info.artifacts)
if not suit:
await img.text('未激活套装', 184, 1168, font=fm.get('hywh.ttf', 36))
await img.text('未激活套装', 184, 1292, font=fm.get('hywh.ttf', 36))
await img.text('未激活套装', 154, 1168, font=fm.get('hywh.ttf', 36))
await img.text('未激活套装', 154, 1292, font=fm.get('hywh.ttf', 36))
elif len(suit) == 1:
artifact1 = await load_image(ARTIFACT_ICON / f'{suit[0][1]}.png', size=(110, 110), mode='RGBA')
await img.paste(artifact1, (76, 1130))
await img.text(f'{suit[0][0][:2]}二件套', 184, 1168, font=fm.get('hywh.ttf', 36))
await img.text('未激活套装', 184, 1292, font=fm.get('hywh.ttf', 36))
await img.paste(artifact1, (46, 1130))
await img.text(f'{suit[0][0][:2]}二件套', 154, 1168, font=fm.get('hywh.ttf', 36))
await img.text('未激活套装', 154, 1292, font=fm.get('hywh.ttf', 36))
else:
if suit[0][0] == suit[1][0]:
artifact2 = artifact1 = await load_image(ARTIFACT_ICON / f'{suit[0][1]}.png', size=(110, 110), mode='RGBA')
await img.text(f'{suit[0][0][:2]}四件套', 184, 1168, font=fm.get('hywh.ttf', 36))
await img.text(f'{suit[0][0][:2]}四件套', 184, 1292, font=fm.get('hywh.ttf', 36))
await img.text(f'{suit[0][0][:2]}四件套', 154, 1168, font=fm.get('hywh.ttf', 36))
await img.text(f'{suit[0][0][:2]}四件套', 154, 1292, font=fm.get('hywh.ttf', 36))
else:
artifact1 = await load_image(ARTIFACT_ICON / f'{suit[0][1]}.png', size=(110, 110), mode='RGBA')
artifact2 = await load_image(ARTIFACT_ICON / f'{suit[1][1]}.png', size=(110, 110), mode='RGBA')
await img.text(f'{suit[0][0][:2]}两件套', 184, 1168, font=fm.get('hywh.ttf', 36))
await img.text(f'{suit[1][0][:2]}两件套', 184, 1292, font=fm.get('hywh.ttf', 36))
await img.paste(artifact1, (76, 1130))
await img.paste(artifact2, (76, 1255))
await img.text(f'{suit[0][0][:2]}两件套', 154, 1168, font=fm.get('hywh.ttf', 36))
await img.text(f'{suit[1][0][:2]}两件套', 154, 1292, font=fm.get('hywh.ttf', 36))
await img.paste(artifact1, (46, 1130))
await img.paste(artifact2, (46, 1255))
# 立绘
await img.paste(await load_image(ENKA_RES / '立绘' / f'{info.name}.png'), (695, 234))
await img.text(f'更新于{info.update_time.strftime("%m-%d %H:%M")}',
(0, 1080),
(img.height - 110, img.height - 50),
(img.height - 123, img.height - 80),
fm.get('优设标题黑.ttf', 33),
'#afafaf',
'center')
await img.text('Created by LittlePaimon | Powered by Enka.Network',
(0, 1080),
(img.height - 60, img.height),
fm.get('优设标题黑.ttf', 36),
(img.height - 80, img.height - 40),
fm.get('优设标题黑.ttf', 33),
'white',
'center')

View File

@ -1,10 +1,11 @@
import difflib
from typing import Union, Literal, List
from typing import Union, Literal, List, Optional
from .files import load_json
from LittlePaimon.config import JSON_DATA
alias_file = load_json(JSON_DATA / 'alias.json')
info_file = load_json(JSON_DATA / 'genshin_info.json')
def get_short_name(name: str) -> str:
@ -85,3 +86,31 @@ def get_match_alias(msg: str, type: Literal['角色', '武器', '原魔', '圣
elif type == '原魔':
match_list = difflib.get_close_matches(msg, alias_list, cutoff=0.4, n=5)
return match_list[0] if len(match_list) == 1 else match_list
def get_icon(name: Optional[str] = None, chara_id: Optional[int] = None,
icon_type: Literal['avatar', 'card', 'splash', 'slice', 'side'] = 'avatar') -> Optional[str]:
"""
根据角色名字或id获取角色的图标
:param name: 角色名
:param chara_id角色id
:param icon_type: 图标类型有rolesweaponsmonsters
:return: 图标字符串
"""
if name and not chara_id:
chara_id = get_id_by_name(name)
info = info_file.get(str(chara_id))
if not info:
return None
side_icon = info['SideIconName']
if icon_type == 'side':
return side_icon
elif icon_type == 'avatar':
return side_icon.replace('_Side', '')
elif icon_type == 'card':
return side_icon.replace('_Side', '') + '_Card'
elif icon_type == 'splash':
return side_icon.replace('Icon_Side', 'Img').replace('UI_', 'UI_Gacha_')
elif icon_type == 'slice':
return side_icon.replace('_Side', '').replace('UI_', 'UI_Gacha_')

View File

@ -330,7 +330,7 @@ async def get_mihoyo_private_data(
if await check_retcode(data, cookie_info, 'private', user_id, uid):
return data
else:
return 'cookie疑似失效'
return f'你的UID{uid}cookie疑似失效'
async def get_sign_reward_list() -> dict:

View File

@ -180,7 +180,7 @@ def CommandPlayer(limit: int = 3, only_cn: bool = True) -> List[Player]:
elif uid := await get_uid(event=event, user_id=user):
uids = [uid]
else:
await matcher.finish('请把uid给我哦', at_sender=True)
await matcher.finish('第一次查询请把uid给我哦', at_sender=True)
extra_info = replace_all(extra_info, uids)
for uid in uids:
query_list.append(Player(user_id=user, uid=uid))
@ -212,7 +212,7 @@ def CommandUID(only_cn: bool = True) -> str:
elif uid := await get_uid(event=event):
uid = uid
else:
await matcher.finish('请提供uid')
await matcher.finish('第一次查询请把UID给我哦')
state['msg'] = event.message.extract_plain_text().replace(uid, '')
return uid
@ -228,7 +228,7 @@ def CommandCharacter(limit: int = 3, replace_uid: bool = True) -> List[str]:
async def _character(matcher: Matcher, state: T_State, msg: str = Arg('msg')):
if not msg:
await matcher.finish('输入要查询的角色名称')
await matcher.finish('给出要查询的角色名称')
character_list = []
characters = msg.split(' ')
for character_name in characters:
@ -237,7 +237,7 @@ def CommandCharacter(limit: int = 3, replace_uid: bool = True) -> List[str]:
character_list.append(list(character_match.keys())[0])
msg.replace(character_name, '')
if not character_list:
await matcher.finish(f'没有名为{msg}的角色')
await matcher.finish(f'没有名为{msg}的角色')
state['msg'] = msg
if len(character_list) > limit:
character_list = character_list[:limit]
@ -246,7 +246,7 @@ def CommandCharacter(limit: int = 3, replace_uid: bool = True) -> List[str]:
async def _character2(matcher: Matcher, state: T_State, msg: Message = CommandArg()):
msg = msg.extract_plain_text().strip()
if not msg:
await matcher.finish('输入角色名称')
await matcher.finish('给出要查询的角色名称')
character_list = []
characters = msg.split(' ')
for character_name in characters:
@ -255,7 +255,7 @@ def CommandCharacter(limit: int = 3, replace_uid: bool = True) -> List[str]:
character_list.append(list(character_match.keys())[0])
msg.replace(character_name, '')
if not character_list:
await matcher.finish(f'没有名为{msg}的角色')
await matcher.finish(f'没有名为{msg}的角色')
state['msg'] = msg
if len(character_list) > limit:
character_list = character_list[:limit]