优化了攻略指令提示和抽卡记录分析图片

This commit is contained in:
CMHopeSunshine 2022-03-29 21:56:39 +08:00
parent 382c7e899f
commit f78a227ae3
4 changed files with 113 additions and 22 deletions

View File

@ -49,9 +49,91 @@ character_alias={
10000064:['云堇','云先生'],
10000066:['神里绫人','0人','大舅子','小舅子','绫人','神里哥']
}
short_name={
'胡桃': '胡桃',
'托马': '托马',
'宵宫': '宵宫',
'烟绯': '烟绯',
'可莉': '可莉',
'迪卢克': '姥爷',
'辛焱': '辛焱',
'安柏': '安柏',
'香菱': '香菱',
'班尼特': '点赞',
'珊瑚宫心海': '心海',
'达达利亚': '公子',
'行秋': '行秋',
'莫娜': '莫娜',
'芭芭拉': '牧师',
'申鹤': '申鹤',
'神里绫华': '绫华',
'优菈': '优菈',
'甘雨': '甘雨',
'凯亚': '凯亚',
'重云': '重云',
'七七': '七七',
'迪奥娜': '冰猫',
'罗莎莉亚': '修女',
'埃洛伊': '异界',
'八重神子': '神子',
'雷电将军': '雷神',
'九条裟罗': '九条',
'刻晴': '刻晴',
'雷泽': '雷泽',
'菲谢尔': '皇女',
'丽莎': '丽莎',
'北斗': '北斗',
'雷主': '雷主',
'早柚': '早柚',
'枫原万叶': '万叶',
'': '魈君',
'温迪': '温迪',
'': '团长',
'砂糖': '砂糖',
'风主': '风主',
'荒泷一斗': '一斗',
'五郎': '五郎',
'阿贝多': '白垩',
'钟离': '钟离',
'诺艾尔': '女仆',
'凝光': '凝光',
'岩主': '岩主',
'云堇': '云堇',
'神乐之真意': '神乐',
'息灾': '息灾',
'赤角石溃杵': '赤角',
'松籁响起之时': '松籁',
'苍古自由之誓': '苍古',
'终末嗟叹之诗': '终末',
'冬极白星': '冬极',
'不灭月华': '月华',
'薙草之稻光': '薙刀',
'飞雷之弦振': '飞雷',
'雾切之回光': '雾切',
'天空之刃': '空刃',
'狼的末路': '狼末',
'阿莫斯之弓': '痛苦',
'天空之卷': '空卷',
'天空之傲': '空傲',
'和璞鸢': '鸟枪',
'四风原典': '四风',
'天空之翼': '空翼',
'天空之脊': '空脊',
'尘世之锁': '尘锁',
'无工之剑': '无工',
'贯虹之槊': '贯虹',
'斫峰之刃': '斫峰',
'磐岩结绿': '绿剑'
}
def get_id_by_alias(name):
for c in character_alias.items():
if name in c[1]:
return c
return None
return None
def get_short_name(name):
for n in short_name.items():
if name == n[0]:
return n[1]
return name

View File

@ -1,6 +1,7 @@
from PIL import Image, ImageDraw, ImageFont
import os
from ..util import pil2b64
from ..character_alias import get_short_name
from hoshino.typing import MessageSegment
res_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'res')
@ -60,7 +61,7 @@ async def draw_gacha_log(data):
col += 1
top_draw = ImageDraw.Draw(top)
top_draw.text((348, 30), f'{data["type"]}', font=get_font(24), fill='#F8F5F1')
top_draw.text((146 - 6 * len(str(data["total_num"])), 88), f'{data["total_num"]}', font=get_font(24), fill='black')
top_draw.text((145 - 6 * len(str(data["total_num"])), 88), f'{data["total_num"]}', font=get_font(24), fill='black')
five_ave = round(sum([x[1] for x in five_star]) / len(five_star), 1) if five_star else ' '
top_draw.text((321 - 10 * len(str(five_ave)), 88), f'{five_ave}', font=get_font(24), fill='black' if five_ave != ' ' and five_ave > 60 else 'red')
five_per = round(len(five_star) / (data['total_num'] - data['5_gacha']) * 100, 2) if five_star else -1
@ -85,16 +86,18 @@ async def draw_gacha_log(data):
n = 0
for c in five_star:
avatar = await get_circle_avatar(c[0], 45)
f = 10 if data['type'] == '武器' else 0
if c[1] <= 20:
color = 'red'
elif 20 < c[1] <= 50:
elif 20 < c[1] <= 50 - f:
color = 'orangered'
elif 50 < c[1] < 70:
elif 50 - f < c[1] < 70 - f:
color = 'darkorange'
else:
color = 'black'
bg_img.alpha_composite(avatar, (30 + 120 * (n % 6), 298 + 80 * int(n / 6)))
bg_draw.text((111 + 120 * (n % 6) - 8 * len(c[0]), 298 + 80 * int(n / 6)), f'{c[0]}', font=get_font(16), fill=color)
name = get_short_name(c[0])
bg_draw.text((111 + 120 * (n % 6) - 8 * len(name), 298 + 80 * int(n / 6)), name, font=get_font(16), fill=color)
bg_draw.text((107 - 5 * len(str(c[1])) + 120 * (n % 6), 317 + 80 * int(n / 6)), f'[{c[1]}]', font=get_font(16), fill=color)
n += 1
return bg_img

View File

@ -13,26 +13,26 @@ res_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'res')
@sv.on_suffix('角色攻略')
async def genshinguide(bot,ev):
name = ev.message.extract_plain_text().strip()
chara_name = get_id_by_alias(name)
if not chara_name:
realname = get_id_by_alias(name)
if not realname:
await bot.send(ev,f'没有找到{name}的攻略',at_sender=True)
elif chara_name[1][0] == '八重神子':
elif realname[1][0] == '八重神子':
path = os.path.join(res_path, 'role_guide','八重神子.png')
cq_img = f'[CQ:image,file=file:///{path}]'
await bot.send(ev,cq_img,at_sender=True)
else:
img = f'[CQ:image,file=https://adachi-bot.oss-cn-beijing.aliyuncs.com/Version2/guide/{chara_name[1][0]}.png]'
img = f'[CQ:image,file=https://adachi-bot.oss-cn-beijing.aliyuncs.com/Version2/guide/{realname[1][0]}.png]'
await bot.send(ev,img)
@sv.on_prefix('角色材料')
@sv.on_suffix('角色材料')
async def genshinmaterial(bot,ev):
name = ev.message.extract_plain_text().strip()
name = get_id_by_alias(name)
if not name:
realname = get_id_by_alias(name)
if not realname:
await bot.send(ev,f'没有找到{name}的材料',at_sender=True)
else:
path = os.path.join(res_path, 'role_material',f'{name[1][0]}材料.png')
path = os.path.join(res_path, 'role_material',f'{realname[1][0]}材料.png')
cq_img = f'[CQ:image,file=file:///{path}]'
await bot.send(ev,cq_img,at_sender=True)
@ -40,13 +40,15 @@ async def genshinmaterial(bot,ev):
@sv.on_suffix('参考面板')
async def genshinAttribute(bot,ev):
name = ev.message.extract_plain_text().strip()
if name != '风主' or name != '岩主' or name != '雷主':
name = get_id_by_alias(name)
if not name:
if name not in ['风主', '岩主', '雷主']:
realname = get_id_by_alias(name)
if not realname:
await bot.send(ev,f'没有找到{name}的参考面板',at_sender=True)
return
name = name[1][0]
pic_data = get_blue_pic(name)
realname = realname[1][0]
else:
realname = name
pic_data = get_blue_pic(realname)
pic = Image.open(os.path.join(res_path, 'blue', f'{pic_data[0]}.jpg'))
pic = pic.crop((0, pic_data[1][0], 1080, pic_data[1][1]))
pic = pil2b64(pic, 85)
@ -58,13 +60,15 @@ async def genshinAttribute(bot,ev):
@sv.on_suffix('收益曲线')
async def genshinAttribute2(bot,ev):
name = ev.message.extract_plain_text().strip()
if name != '风主' or name != '岩主' or name != '雷主':
name = get_id_by_alias(name)
if not name:
if name not in ['风主', '岩主', '雷主']:
realname = get_id_by_alias(name)
if not realname:
await bot.send(ev,f'没有找到{name}的参考面板',at_sender=True)
return
name = name[1][0]
pic = Image.open(os.path.join(res_path, 'blue', f'{name}.png'))
realname = realname[1][0]
else:
realname = name
pic = Image.open(os.path.join(res_path, 'blue', f'{realname}.png'))
pic = pil2b64(pic, 85)
pic = MessageSegment.image(pic)
await bot.send(ev,pic,at_sender=True)

View File

@ -40,6 +40,8 @@ blue={
'': ['', (2527, 3252)],
'砂糖': ['', (3252, 3977)],
'风主': ['', (3977, 4311)],
'': ['', (3977, 4311)],
'': ['', (3977, 4311)],
'荒泷一斗': ['', (0, 741)],
'五郎': ['', (741, 1055)],
'阿贝多': ['', (1055, 1767)],