diff --git a/Guess_voice/download_data.py b/Guess_voice/download_data.py
index 3217170..14a40f5 100644
--- a/Guess_voice/download_data.py
+++ b/Guess_voice/download_data.py
@@ -1,8 +1,3 @@
-# -*- coding: UTF-8 -*-
-"""
-该脚本可以直接获取wiki上的语音文件 并保存进数据库中
-"""
-
import json
import os
from pathlib import Path
@@ -14,7 +9,6 @@ from sqlitedict import SqliteDict # TODO 加入requirements
from utils import aiorequests
from .util import get_path
-# OUT_PUT = Path(__file__).parent / 'voice'
OUT_PUT = Path() / 'data' / 'LittlePaimon' / 'guess_voice' / 'voice'
BASE_URL = 'https://wiki.biligame.com/ys/'
@@ -28,11 +22,8 @@ config = {
'voice_language': ['日', '英', '韩']
}
-# dir_data = os.path.join(os.path.dirname(__file__), 'data')
dir_data = Path() / 'data' / 'LittlePaimon' / 'guess_voice' / 'data'
-# if not os.path.exists(dir_data):
-# os.makedirs(dir_data)
dir_data.mkdir(parents=True, exist_ok=True)
diff --git a/Guess_voice/handler.py b/Guess_voice/handler.py
index c3fbe19..574a6a7 100644
--- a/Guess_voice/handler.py
+++ b/Guess_voice/handler.py
@@ -15,21 +15,14 @@ from sqlitedict import SqliteDict
from .download_data import voice_list_by_mys, voice_detail_by_mys
from .util import get_path, require_file
+from utils.alias_handler import get_alias_by_name
scheduler = require('nonebot_plugin_apscheduler').scheduler
-# dir_data = os.path.join(os.path.dirname(__file__), 'data')
dir_data = Path() / 'data' / 'LittlePaimon' / 'guess_voice' / 'data'
-
-# data_path = os.path.join(os.path.dirname(__file__), 'voice')
data_path = Path() / 'data' / 'LittlePaimon' / 'guess_voice' / 'voice'
-
-# data2_path = os.path.join(os.path.dirname(__file__), 'voice2')
data2_path = Path() / 'data' / 'LittlePaimon' / 'guess_voice' / 'voice2'
-# if not os.path.exists(dir_data):
-# os.makedirs(dir_data)
-
dir_data.mkdir(parents=True, exist_ok=True)
db = {}
@@ -57,15 +50,23 @@ with open(os.path.join(os.path.dirname(__file__), 'character.json'), 'r', encodi
def create_guess_matcher(role_name, second, group_id):
+ """
+ 创建一个猜语音的正则匹配matcher,正则内容为角色的别名
+ :param role_name: 角色名
+ :param second: 结束时间(秒)
+ :param group_id: 进行的群组
+ :return: None
+ """
def check_group(event: GroupMessageEvent):
if event.group_id == group_id:
return True
return False
- alias_list = character_json.get(role_name, [])
- re_str = role_name + '|' + '|'.join(alias_list)
+ alias_list = get_alias_by_name(role_name)
+ re_str = '|'.join(alias_list)
guess_matcher = on_regex(re_str, temp=True, rule=Rule(check_group))
guess_matcher.plugin_name = "Guess_voice"
+ guess_matcher.expire_time = datetime.timedelta(seconds=second)
@guess_matcher.handle()
async def _(event: GroupMessageEvent):
diff --git a/Paimon_Gacha/gacha_res.py b/Paimon_Gacha/gacha_res.py
index 93016b7..ec9e4bd 100644
--- a/Paimon_Gacha/gacha_res.py
+++ b/Paimon_Gacha/gacha_res.py
@@ -199,7 +199,7 @@ async def create_item(rank, item_type, name, element, count, dg_time):
return bg
-async def ten(uid, gacha_data) -> PngImagePlugin.PngImageFile:
+async def ten(uid, gacha_data):
gacha_list = []
for i in range(0, 10):
if gacha_data['gacha_type'] == 'all_star':
@@ -210,7 +210,6 @@ async def ten(uid, gacha_data) -> PngImagePlugin.PngImageFile:
role = once(uid, gacha_data).copy()
gacha_list.append(role)
gacha_list.sort(key=lambda x: x["rank"], reverse=True)
- img: PngImagePlugin.PngImageFile
img = Image.open(os.path.join(RES_PATH, 'background.png'))
i = 0
for wish in gacha_list:
@@ -245,4 +244,4 @@ async def more_ten(uid, gacha_data, num, sd):
draw = ImageDraw.Draw(img)
draw.text((27, 575 * num - 30), ('@%s %s Created By LittlePaimon' % (str(sd.nickname), time_str)), font=time_font,
fill="#8E8E8E")
- return MessageBuild.Image(img, quality=75)
+ return MessageBuild.Image(img, quality=75, mode='RGB')
diff --git a/Paimon_Gacha_Log/api.py b/Paimon_Gacha_Log/api.py
index 01d470e..922fe73 100644
--- a/Paimon_Gacha_Log/api.py
+++ b/Paimon_Gacha_Log/api.py
@@ -4,7 +4,7 @@ from utils import aiorequests
def toApi(url):
- spliturl = str(url).split("?")
+ spliturl = str(url).replace('amp;', '').split("?")
if "webstatic-sea" in spliturl[0] or "hk4e-api-os" in spliturl[0]:
spliturl[0] = "https://hk4e-api-os.mihoyo.com/event/gacha_info/api/getGachaLog"
else:
diff --git a/Paimon_Gacha_Log/get_img.py b/Paimon_Gacha_Log/get_img.py
index 46db339..4303330 100644
--- a/Paimon_Gacha_Log/get_img.py
+++ b/Paimon_Gacha_Log/get_img.py
@@ -141,4 +141,4 @@ async def get_gacha_log_img(gacha_data, pool):
img_draw.text((595, 44), f'UID:{gacha_data["uid"]}', font=get_font(16), fill='black')
img_draw.text((530, total_height - 45), 'Created by LittlePaimon', font=get_font(16), fill='black')
- return MessageBuild.Image(img)
+ return MessageBuild.Image(img, mode='RGB')
diff --git a/Paimon_Info/draw_abyss_info.py b/Paimon_Info/draw_abyss_info.py
index 78ee258..74e0d5b 100644
--- a/Paimon_Info/draw_abyss_info.py
+++ b/Paimon_Info/draw_abyss_info.py
@@ -155,4 +155,4 @@ async def draw_abyss_card(data, uid, floor_num):
total_img.alpha_composite(floor_img, (5, 5 + 524 + 5 + h))
h += 1210
- return MessageBuild.Image(total_img, quality=75)
+ return MessageBuild.Image(total_img, quality=75, mode='RGB')
diff --git a/Paimon_Info/draw_daily_note.py b/Paimon_Info/draw_daily_note.py
index e2de6df..50eb9a3 100644
--- a/Paimon_Info/draw_daily_note.py
+++ b/Paimon_Info/draw_daily_note.py
@@ -157,4 +157,4 @@ async def draw_daily_note_card(data, uid):
bg_img.alpha_composite(role_img, (1220, 200))
now = datetime.datetime.now().strftime('%m月%d日%H:%M')
bg_draw.text((554, 1794), 'Created by LittlePaimon·' + now, fill='#5680d2', font=get_font(40, '优设标题黑.ttf'))
- return MessageBuild.Image(bg_img, size=0.35, quality=70)
+ return MessageBuild.Image(bg_img, size=0.35, quality=70, mode='RGB')
diff --git a/Paimon_Info/draw_month_info.py b/Paimon_Info/draw_month_info.py
index 0c68750..b604b65 100644
--- a/Paimon_Info/draw_month_info.py
+++ b/Paimon_Info/draw_month_info.py
@@ -114,4 +114,4 @@ async def draw_monthinfo_card(data):
bg_draw.text((49, 857), f'本月相比上个月,原石{ysstr},摩拉{mlstr}', font=get_font(23), fill='#27384C')
bg_draw.text((167, 900), 'Created by LittlePaimon', font=get_font(21), fill='#27384C')
- return MessageBuild.Image(bg_img, quality=70)
+ return MessageBuild.Image(bg_img, quality=70, mode='RGB')
diff --git a/Paimon_Info/draw_player_card.py b/Paimon_Info/draw_player_card.py
index 21e5ead..eaf9a57 100644
--- a/Paimon_Info/draw_player_card.py
+++ b/Paimon_Info/draw_player_card.py
@@ -495,4 +495,4 @@ async def draw_chara_card(data, skill_data, chara_name, uid):
bg_draw.text((330, 371), 'Created by LittlePaimon', font=get_font(20), fill='white')
- return MessageBuild.Image(bg_img, size=0.95, quality=80)
+ return MessageBuild.Image(bg_img, size=0.95, quality=80, mode='RGB')
diff --git a/Paimon_Info/draw_role_card.py b/Paimon_Info/draw_role_card.py
index 5632dfb..d591948 100644
--- a/Paimon_Info/draw_role_card.py
+++ b/Paimon_Info/draw_role_card.py
@@ -1,8 +1,8 @@
from PIL import Image, ImageDraw, ImageFont
from pathlib import Path
-from utils.file_handler import load_image
-from utils.enka_util import artifact_total_score, check_effective
+from utils.file_handler import load_image, load_json
+from utils.enka_util import get_artifact_suit, artifact_total_value, get_expect_score, get_effective, check_effective
from utils import aiorequests
from utils.message_util import MessageBuild
@@ -34,78 +34,86 @@ for i in range(1, 6):
paint = load_image(res_path / 'player_card2' / '立绘框.png', mode='RGBA')
lock = load_image(res_path / 'player_card2' / '锁.png', mode='RGBA', size=(45, 45))
loading = load_image(res_path / 'player_card2' / '加载中.png', mode='RGBA', size=(120, 120))
+region = load_json(path=Path(__file__).parent.parent / 'utils' / 'json' / 'role_region.json')
def get_font(size, font='hywh.ttf'):
return ImageFont.truetype(str(res_path / font), size)
+def draw_right_text(draw, text, width, height, fill, font):
+ text_length = draw.textlength(text, font=font)
+ draw.text((width - text_length, height), text, fill=fill,
+ font=font)
+
+
+def draw_center_text(draw, text, left_width, right_width, height, fill, font):
+ text_length = draw.textlength(text, font=font)
+ draw.text((left_width + (right_width - left_width - text_length) / 2, height), text, fill=fill,
+ font=font)
+
+
async def draw_role_card(uid, data):
bg = Image.new('RGBA', (1080, 1920), (0, 0, 0, 0))
bg.alpha_composite(bg_card[data['元素']], (0, 0))
bg.alpha_composite(base_mask, (0, 0))
+ if data['名称'] not in ['荧', '空', '埃洛伊']:
+ region_icon = load_image(path=res_path / 'player_card2' / f'{region[data["名称"]]}.png', size=(130, 130))
+ bg.alpha_composite(region_icon, (0, 4))
bg_draw = ImageDraw.Draw(bg)
bg_draw.text((131, 100), f"UID{uid}", fill='white', font=get_font(48, 'number.ttf'))
bg_draw.text((134, 150), data['名称'], fill='white', font=get_font(72, '优设标题黑.ttf'))
bg.alpha_composite(level_mask, (298 + 60 * (len(data['名称']) - 2), 172))
- bg_draw.text((330 + 60 * (len(data['名称']) - 2), 174), f'LV{data["等级"]}', fill='black',
- font=get_font(48, 'number.ttf'))
+ draw_center_text(bg_draw, f'LV{data["等级"]}', 298 + 60 * (len(data['名称']) - 2), 298 + 60 * (len(data['名称']) - 2) + 171, 174, 'black', get_font(48, 'number.ttf'))
+
# 属性值
prop = data['属性']
bg_draw.text((89, 262), '生命值', fill='white', font=get_font(34, 'hywh.ttf'))
- text_length = 473 - (len(str(prop['基础生命'])) + len(str(prop['额外生命']))) * 20 - 12
- bg_draw.text((text_length, 264), f"{prop['基础生命']}", fill='white', font=get_font(34, 'number.ttf'))
- bg_draw.text((text_length + len(str(prop['基础生命'])) * 20 + 3, 264), f"+{prop['额外生命']}", fill='#59c538',
- font=get_font(34, 'number.ttf'))
+ text_length = bg_draw.textlength(f"+{prop['额外生命']}", font=get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"{prop['基础生命']}", 480 - text_length - 5, 264, 'white', get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"+{prop['额外生命']}", 480, 264, '#59c538', get_font(34, 'number.ttf'))
bg_draw.text((89, 319), '攻击力', fill='white', font=get_font(34, 'hywh.ttf'))
- text_length = 473 - (len(str(prop['基础攻击'])) + len(str(prop['额外攻击']))) * 20 - 12
- bg_draw.text((text_length, 321), f"{prop['基础攻击']}", fill='white', font=get_font(34, 'number.ttf'))
- bg_draw.text((text_length + len(str(prop['基础攻击'])) * 20 + 3, 321), f"+{prop['额外攻击']}", fill='#59c538',
- font=get_font(34, 'number.ttf'))
+ text_length = bg_draw.textlength(f"+{prop['额外攻击']}", font=get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"{prop['基础攻击']}", 480 - text_length - 5, 321, 'white', get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"+{prop['额外攻击']}", 480, 321, '#59c538', get_font(34, 'number.ttf'))
bg_draw.text((89, 377), '防御力', fill='white', font=get_font(34, 'hywh.ttf'))
- text_length = 473 - (len(str(prop['基础防御'])) + len(str(prop['额外防御']))) * 20 - 12
- bg_draw.text((text_length, 379), f"{prop['基础防御']}", fill='white', font=get_font(34, 'number.ttf'))
- bg_draw.text((text_length + len(str(prop['基础防御'])) * 20 + 3, 379), f"+{prop['额外防御']}", fill='#59c538',
- font=get_font(34, 'number.ttf'))
+ text_length = bg_draw.textlength(f"+{prop['额外防御']}", font=get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"{prop['基础防御']}", 480 - text_length - 5, 379, 'white', get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"+{prop['额外防御']}", 480, 379, '#59c538', get_font(34, 'number.ttf'))
text = round(prop['暴击率'] * 100, 1)
bg_draw.text((89, 436), '暴击率', fill='white', font=get_font(34, 'hywh.ttf'))
- bg_draw.text((473 - len(str(text)) * 17 - 17, 438), f"{text}%", fill='white',
- font=get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"{text}%", 480, 438, 'white', get_font(34, 'number.ttf'))
text = round(prop['暴击伤害'] * 100, 1)
bg_draw.text((89, 493), '暴击伤害', fill='white', font=get_font(34, 'hywh.ttf'))
- bg_draw.text((473 - len(str(text)) * 17 - 17, 495), f"{text}%", fill='white',
- font=get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"{text}%", 480, 495, 'white', get_font(34, 'number.ttf'))
bg_draw.text((89, 551), '元素精通', fill='white', font=get_font(34, 'hywh.ttf'))
- bg_draw.text((473 - len(str(prop['元素精通'])) * 18, 553), f"{prop['元素精通']}", fill='white',
- font=get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, str(prop['元素精通']), 480, 553, 'white', get_font(34, 'number.ttf'))
text = round(prop['元素充能效率'] * 100, 1)
bg_draw.text((89, 610), '充能效率', fill='white', font=get_font(34, 'hywh.ttf'))
- bg_draw.text((473 - len(str(text)) * 17 - 17, 612), f"{text}%", fill='white',
- font=get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"{text}%", 480, 612, 'white', get_font(34, 'number.ttf'))
max_element = max(prop['伤害加成'])
text = round(max_element * 100, 1)
bg_draw.text((89, 669), f'{element_type[prop["伤害加成"].index(max_element)]}伤害加成', fill='white',
font=get_font(34, 'hywh.ttf'))
- bg_draw.text((473 - len(str(text)) * 16 - 16, 671), f"{text}%", fill='white',
- font=get_font(34, 'number.ttf'))
+ draw_right_text(bg_draw, f"{text}%", 480, 671, 'white', get_font(34, 'number.ttf'))
# 天赋
if data['名称'] in ['神里绫华', '莫娜']:
data['天赋'].pop(2)
for i in range(3):
bg.alpha_composite(base_icon[data['元素']].resize((132, 142)), (564, 253 + 147 * i))
- bg_draw.text((522 if data['天赋'][i]['等级'] < 10 else 513, 310 + 147 * i), str(data['天赋'][i]['等级']), fill='black',
- font=get_font(34, 'number.ttf'))
+ draw_center_text(bg_draw, str(data['天赋'][i]['等级']), 510, 552, 310 + 147 * i, 'black', get_font(34, 'number.ttf'))
skill_icon = res_path2 / 'skill' / f'{data["天赋"][i]["图标"]}.png'
- skill_icon = await aiorequests.get_img(url=skill_url.format(data["天赋"][i]["图标"]), size=(57, 57), save_path=skill_icon)
+ skill_icon = await aiorequests.get_img(url=skill_url.format(data["天赋"][i]["图标"]), size=(57, 57),
+ save_path=skill_icon)
bg.alpha_composite(skill_icon, (603, 298 + 147 * i))
# 命座
@@ -113,7 +121,8 @@ async def draw_role_card(uid, data):
for talent in data['命座']:
bg.alpha_composite((base_icon[data['元素']]).resize((83, 90)), (510 + t * 84, 790))
talent_icon = res_path2 / 'skill' / f'{talent["图标"]}.png'
- talent_icon = await aiorequests.get_img(url=talent_url.format(talent["图标"]), size=(45, 45), save_path=talent_icon)
+ talent_icon = await aiorequests.get_img(url=talent_url.format(talent["图标"]), size=(45, 45),
+ save_path=talent_icon)
bg.alpha_composite(talent_icon, (529 + t * 84, 813))
t += 1
for t2 in range(t, 6):
@@ -123,15 +132,18 @@ async def draw_role_card(uid, data):
# 武器
bg.alpha_composite(weapon_bg[data['武器']['星级'] - 1], (91, 760))
weapon_icon = res_path2 / 'weapon' / f'{data["武器"]["图标"]}.png'
- weapon_icon = await aiorequests.get_img(url=weapon_url.format(data["武器"]["图标"]), size=(150, 150), save_path=weapon_icon)
+ weapon_icon = await aiorequests.get_img(url=weapon_url.format(data["武器"]["图标"]), size=(150, 150),
+ save_path=weapon_icon)
bg.alpha_composite(weapon_icon, (91, 760))
bg_draw.text((268, 758), data['武器']['名称'], fill='white', font=get_font(34, 'hywh.ttf'))
for i in range(data['武器']['星级']):
bg.alpha_composite(star, (267 + i * 30, 799))
- bg_draw.text((283, 835), f'LV{data["武器"]["等级"]}', fill='black', font=get_font(27, 'number.ttf'))
+ draw_center_text(bg_draw, f'LV{data["武器"]["等级"]}', 268, 268 + 98, 835, 'black', get_font(27, 'number.ttf'))
bg_draw.text((266, 869), f'精炼{data["武器"]["精炼等级"]}阶', fill='white', font=get_font(34, 'hywh.ttf'))
# 圣遗物
+ effective = get_effective(data['名称'], data['武器']['名称'], data['圣遗物'], data['元素'])
+ average = get_expect_score(effective)
total_score = 0
# 第一排
for i in range(2):
@@ -141,35 +153,38 @@ async def draw_role_card(uid, data):
break
bg.alpha_composite(weapon_bg[artifact['星级'] - 1].resize((100, 100)), (587 + 317 * i, 1002))
reli_path = res_path2 / 'reli' / f'{artifact["图标"]}.png'
- reli_path = await aiorequests.get_img(url=artifact_url.format(artifact["图标"]), size=(100, 100), save_path=reli_path)
+ reli_path = await aiorequests.get_img(url=artifact_url.format(artifact["图标"]), size=(100, 100),
+ save_path=reli_path)
bg.alpha_composite(reli_path, (587 + 317 * i, 1002))
- bg_draw.text((412 + 317 * i, 950), artifact['名称'], fill='white', font=get_font(40))
- score = artifact_total_score(artifact['词条'])
- total_score += score
- rank = 'SSS' if score >= 45 else 'SS' if 40 <= score < 45 else 'S' if 35 <= score < 40 else 'A' if 30 <= score < 35 else 'B' if 25 <= score < 30 else 'C'
- bg_draw.text((412 + 317 * i, 998), f'{rank}-{score}', fill='#ffde6b', font=get_font(28, 'number.ttf'))
+ bg_draw.text((411 + 317 * i, 951), artifact['名称'], fill='white', font=get_font(40))
+ value, score = artifact_total_value(data['属性'], 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'
+ bg_draw.text((412 + 317 * i, 998), f'{rank}-{value}', fill='#ffde6b', font=get_font(28, 'number.ttf'))
bg.alpha_composite(level_mask.resize((98, 30)), (412 + 317 * i, 1032))
- bg_draw.text((433 + 317 * i, 1033), f"LV{artifact['等级']}", fill='black', font=get_font(27, 'number.ttf'))
- bg_draw.text((411 + 317 * i, 1067), artifact['主属性']['属性名'], fill='white', font=get_font(25))
+ draw_center_text(bg_draw, f"LV{artifact['等级']}", 412 + 317 * i, 412 + 317 * i + 98, 1033, 'black', get_font(27, 'number.ttf'))
+ bg_draw.text((411 + 317 * i, 1069), artifact['主属性']['属性名'], fill='white', font=get_font(25))
if artifact['主属性']['属性名'] not in ['生命值', '攻击力', '元素精通']:
- bg_draw.text((408 + 317 * i, 1100), f"+{artifact['主属性']['属性值']}%", fill='white', font=get_font(25, 'number.ttf'))
+ bg_draw.text((408 + 317 * i, 1100), f"+{artifact['主属性']['属性值']}%", fill='white',
+ font=get_font(25, 'number.ttf'))
else:
- bg_draw.text((408 + 317 * i, 1100), f"+{artifact['主属性']['属性值']}", fill='white', font=get_font(48, 'number.ttf'))
+ bg_draw.text((408 + 317 * i, 1100), f"+{artifact['主属性']['属性值']}", fill='white',
+ font=get_font(48, 'number.ttf'))
for j in range(len(artifact['词条'])):
if '百分比' in artifact['词条'][j]['属性名']:
text = artifact['词条'][j]['属性名'].replace('百分比', '')
else:
text = artifact['词条'][j]['属性名']
- bg_draw.text((411 + 317 * i, 1163 + 50 * j), text, fill='white' if check_effective(data['名称'], artifact['词条'][j]['属性名']) else '#afafaf', font=get_font(25))
+ bg_draw.text((411 + 317 * i, 1163 + 50 * j), text,
+ fill='white' if check_effective(artifact['词条'][j]['属性名'], effective) else '#afafaf',
+ font=get_font(25))
if artifact['词条'][j]['属性名'] not in ['攻击力', '防御力', '生命值', '元素精通']:
num = '+' + str(artifact['词条'][j]['属性值']) + '%'
- text_length = 671 - len(str(artifact['词条'][j]['属性值'])) * 13 + 317 * i - 35 + 8
- if '.' not in str(artifact['词条'][j]['属性值']):
- text_length -= 5
else:
num = '+' + str(artifact['词条'][j]['属性值'])
- text_length = 671 - len(str(artifact['词条'][j]['属性值'])) * 13 + 317 * i - 15
- bg_draw.text((text_length, 1163 + 50 * j), num, fill='white' if check_effective(data['名称'], artifact['词条'][j]['属性名']) else '#afafaf', font=get_font(25, 'number.ttf'))
+ draw_right_text(bg_draw, num, 679 + 317 * i, 1163 + 50 * j,
+ fill='white' if check_effective(artifact['词条'][j]['属性名'], effective) else '#afafaf',
+ font=get_font(25, 'number.ttf'))
# 第二排
for i in range(3):
try:
@@ -181,88 +196,78 @@ async def draw_role_card(uid, data):
reli_path = await aiorequests.get_img(url=artifact_url.format(artifact["图标"]), size=(100, 100),
save_path=reli_path)
bg.alpha_composite(reli_path, (270 + 317 * i, 1439))
- bg_draw.text((95 + 317 * i, 1387), artifact['名称'], fill='white', font=get_font(40))
- score = artifact_total_score(artifact['词条'])
- total_score += score
- rank = 'SSS' if score >= 45 else 'SS' if 40 <= score < 45 else 'S' if 35 <= score < 40 else 'A' if 30 <= score < 35 else 'B' if 25 <= score < 30 else 'C'
- bg_draw.text((95 + 317 * i, 1435), f'{rank}-{score}', fill='#ffde6b', font=get_font(28, 'number.ttf'))
+ bg_draw.text((94 + 317 * i, 1388), artifact['名称'], fill='white', font=get_font(40))
+ value, score = artifact_total_value(data['属性'], 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'
+ bg_draw.text((95 + 317 * i, 1435), f'{rank}-{value}', fill='#ffde6b', font=get_font(28, 'number.ttf'))
bg.alpha_composite(level_mask.resize((98, 30)), (95 + 317 * i, 1469))
- bg_draw.text((116 + 317 * i, 1470), f"LV{artifact['等级']}", fill='black', font=get_font(27, 'number.ttf'))
- bg_draw.text((94 + 317 * i, 1504), artifact['主属性']['属性名'], fill='white', font=get_font(25))
+ draw_center_text(bg_draw, f"LV{artifact['等级']}", 95 + 317 * i, 95 + 317 * i + 98, 1470, 'black',
+ get_font(27, 'number.ttf'))
+ bg_draw.text((94 + 317 * i, 1506), artifact['主属性']['属性名'], fill='white', font=get_font(25))
if artifact['主属性']['属性名'] not in ['生命值', '攻击力', '元素精通']:
- bg_draw.text((91 + 317 * i, 1537), f"+{artifact['主属性']['属性值']}%", fill='white', font=get_font(48, 'number.ttf'))
+ bg_draw.text((91 + 317 * i, 1537), f"+{artifact['主属性']['属性值']}%", fill='white',
+ font=get_font(48, 'number.ttf'))
else:
- bg_draw.text((91 + 317 * i, 1537), f"+{artifact['主属性']['属性值']}", fill='white', font=get_font(48, 'number.ttf'))
+ bg_draw.text((91 + 317 * i, 1537), f"+{artifact['主属性']['属性值']}", fill='white',
+ font=get_font(48, 'number.ttf'))
for j in range(len(artifact['词条'])):
if '百分比' in artifact['词条'][j]['属性名']:
text = artifact['词条'][j]['属性名'].replace('百分比', '')
else:
text = artifact['词条'][j]['属性名']
- bg_draw.text((94 + 317 * i, 1600 + 50 * j), text, fill='white' if check_effective(data['名称'], artifact['词条'][j]['属性名']) else '#afafaf', font=get_font(25))
+ bg_draw.text((94 + 317 * i, 1600 + 50 * j), text,
+ fill='white' if check_effective(artifact['词条'][j]['属性名'], effective) else '#afafaf',
+ font=get_font(25))
if artifact['词条'][j]['属性名'] not in ['攻击力', '防御力', '生命值', '元素精通']:
num = '+' + str(artifact['词条'][j]['属性值']) + '%'
- text_length = 354 - len(str(artifact['词条'][j]['属性值'])) * 13 + 317 * i - 35 + 8
- if '.' not in str(artifact['词条'][j]['属性值']):
- text_length -= 5
else:
num = '+' + str(artifact['词条'][j]['属性值'])
- text_length = 354 - len(str(artifact['词条'][j]['属性值'])) * 13 + 317 * i - 15
- bg_draw.text((text_length, 1600 + 50 * j), num, fill='white' if check_effective(data['名称'], artifact['词条'][j]['属性名']) else '#afafaf', font=get_font(25, 'number.ttf'))
+ draw_right_text(bg_draw, num, 362 + 317 * i, 1600 + 50 * j,
+ fill='white' if check_effective(artifact['词条'][j]['属性名'], effective) else '#afafaf',
+ font=get_font(25, 'number.ttf'))
# 圣遗物评分
- bg_draw.text((118, 1057), '圣遗物总评分', fill='#afafaf', font=get_font(36))
- bg_draw.text((192, 974), str(round(total_score, 1)), fill='white', font=get_font(60, 'number.ttf'))
- total_rank = 'S' if total_score >= 200 else 'A' if 160 <= total_score < 200 else 'B' if 120 <= total_score < 160 else 'C'
- bg.alpha_composite(rank_icon[total_rank], (110, 964))
+ bg_draw.text((119, 1057), '总有效词条数', fill='#afafaf', font=get_font(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'
+ if len(total_rank) == 3:
+ bg.alpha_composite(rank_icon[total_rank[0]], (95, 964))
+ bg.alpha_composite(rank_icon[total_rank[0]], (145, 964))
+ bg.alpha_composite(rank_icon[total_rank[0]], (195, 964))
+ bg_draw.text((250, 974), str(round(total_score, 1)), fill='white', font=get_font(60, 'number.ttf'))
+ elif len(total_rank) == 2:
+ bg.alpha_composite(rank_icon[total_rank[0]], (125, 964))
+ bg.alpha_composite(rank_icon[total_rank[0]], (175, 964))
+ bg_draw.text((235, 974), str(round(total_score, 1)), fill='white', font=get_font(60, 'number.ttf'))
+ else:
+ bg.alpha_composite(rank_icon[total_rank[0]], (143, 964))
+ bg_draw.text((217, 974), str(round(total_score, 1)), fill='white', font=get_font(60, 'number.ttf'))
# 圣遗物套装
- suit = []
- suit2 = []
- flag = False
- for artifact in data['圣遗物']:
- suit.append(artifact['所属套装'])
- for s in suit:
- if s not in suit2 and 1 < suit.count(s) < 4:
- suit2.append(s)
- if suit.count(s) >= 4:
- for r in data['圣遗物']:
- if r['所属套装'] == s:
- reli_path = res_path2 / 'reli' / f'{r["图标"]}.png'
- reli_path = await aiorequests.get_img(url=artifact_url.format(r["图标"]), size=(110, 110),
- save_path=reli_path)
- bg.alpha_composite(reli_path, (76, 1130))
- bg.alpha_composite(reli_path, (76, 1255))
- bg_draw.text((184, 1168), f'{s[:2]}四件套', fill='white', font=get_font(36))
- bg_draw.text((184, 1292), f'{s[:2]}四件套', fill='white', font=get_font(36))
- flag = True
- break
- if len(suit2) == 2:
- bg_draw.text((184, 1168), f'{suit2[0][:2]}两件套', fill='white', font=get_font(36))
- bg_draw.text((184, 1292), f'{suit2[1][:2]}两件套', fill='white', font=get_font(36))
- n = 0
- for r in data["圣遗物"]:
- if n == 2:
- break
- if r['所属套装'] in suit2:
- suit2.remove(r['所属套装'])
- reli_path = res_path2 / 'reli' / f'{r["图标"]}.png'
- reli_path = await aiorequests.get_img(url=artifact_url.format(r["图标"]), size=(110, 110),
- save_path=reli_path)
- bg.alpha_composite(reli_path, (76, 1130 + n * 125))
- n += 1
- elif len(suit2) == 1:
- bg_draw.text((184, 1168), f'{suit2[0][:2]}两件套', fill='white', font=get_font(36))
- bg_draw.text((184, 1292), '未激活套装', fill='white', font=get_font(36))
- for r in data["圣遗物"]:
- if r['所属套装'] in suit2:
- reli_path = res_path2 / 'reli' / f'{r["图标"]}.png'
- reli_path = await aiorequests.get_img(url=artifact_url.format(r["图标"]), size=(110, 110),
- save_path=reli_path)
- bg.alpha_composite(reli_path, (76, 1130))
- break
- elif not flag:
+ suit = get_artifact_suit(data['圣遗物'])
+ if not suit:
bg_draw.text((184, 1168), '未激活套装', fill='white', font=get_font(36))
bg_draw.text((184, 1292), '未激活套装', fill='white', font=get_font(36))
+ elif len(suit) == 1:
+ artifact_path = res_path2 / 'reli' / f'{suit[0][1]}.png'
+ artifact_path = await aiorequests.get_img(url=artifact_url.format(suit[0][1]), size=(110, 110),
+ save_path=artifact_path)
+ bg.alpha_composite(artifact_path, (76, 1130))
+ bg.alpha_composite(artifact_path, (76, 1255))
+ bg_draw.text((184, 1168), f'{suit[0][0][:2]}四件套', fill='white', font=get_font(36))
+ bg_draw.text((184, 1292), f'{suit[0][0][:2]}四件套', fill='white', font=get_font(36))
+ else:
+ artifact_path1 = res_path2 / 'reli' / f'{suit[0][1]}.png'
+ artifact_path1 = await aiorequests.get_img(url=artifact_url.format(suit[0][1]), size=(110, 110),
+ save_path=artifact_path1)
+ artifact_path2 = res_path2 / 'reli' / f'{suit[1][1]}.png'
+ artifact_path2 = await aiorequests.get_img(url=artifact_url.format(suit[1][1]), size=(110, 110),
+ save_path=artifact_path2)
+ bg.alpha_composite(artifact_path1, (76, 1130))
+ bg.alpha_composite(artifact_path2, (76, 1255))
+ bg_draw.text((184, 1168), f'{suit[0][0][:2]}两件套', fill='white', font=get_font(36))
+ bg_draw.text((184, 1292), f'{suit[1][0][:2]}两件套', fill='white', font=get_font(36))
# 立绘
paint_path = res_path / 'player_card2' / '立绘' / f'{data["名称"]}.png'
@@ -275,6 +280,4 @@ async def draw_role_card(uid, data):
bg_draw.text((50, 1870), f'更新于{data["更新时间"].replace("2022-", "")}', fill='white', font=get_font(36, '优设标题黑.ttf'))
bg_draw.text((560, 1869), 'Created by LittlePaimon', fill='white', font=get_font(36, '优设标题黑.ttf'))
- return MessageBuild.Image(bg, quality=75)
-
-
+ return MessageBuild.Image(bg, quality=75, mode='RGB')
diff --git a/README.md b/README.md
index c93eb7a..135d393 100644
--- a/README.md
+++ b/README.md
@@ -2,85 +2,70 @@