mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
ysd
新增魈
伤害计算
This commit is contained in:
parent
4a89541387
commit
32b6405a54
@ -1,17 +1,6 @@
|
||||
from utils.enka_util import get_artifact_suit
|
||||
|
||||
|
||||
def attribute(base_attribute: float, increase_attribute: float = 0, fixed_attribute: float = 0):
|
||||
"""
|
||||
计算属性
|
||||
:param base_attribute: 基础属性
|
||||
:param increase_attribute: 百分比增加系数
|
||||
:param fixed_attribute: 固定增加系数
|
||||
:return: 最终属性
|
||||
"""
|
||||
return base_attribute * (1 + increase_attribute) + fixed_attribute
|
||||
|
||||
|
||||
def resistance_coefficient(base_resistance: float = 0.1, reduction_rate: float = 0):
|
||||
"""
|
||||
计算抗性系数
|
||||
|
@ -1,12 +1,14 @@
|
||||
from .zhongli import draw_zhongli_dmg
|
||||
from .hutao import draw_hutao_dmg
|
||||
from .leishen import draw_leishen_dmg
|
||||
from .xiao import draw_xiao_dmg
|
||||
|
||||
# 支持的角色列表
|
||||
roles_list = {
|
||||
'钟离': draw_zhongli_dmg,
|
||||
'胡桃': draw_hutao_dmg,
|
||||
'雷电将军': draw_leishen_dmg
|
||||
'雷电将军': draw_leishen_dmg,
|
||||
'魈': draw_xiao_dmg
|
||||
}
|
||||
|
||||
|
||||
|
110
Paimon_Info/damage_cal/xiao.py
Normal file
110
Paimon_Info/damage_cal/xiao.py
Normal file
@ -0,0 +1,110 @@
|
||||
from copy import deepcopy
|
||||
from pathlib import Path
|
||||
from typing import Tuple
|
||||
from PIL import Image, ImageDraw
|
||||
from utils.PIL_util import get_font, draw_center_text
|
||||
from utils.file_handler import load_json, load_image
|
||||
from .common import resistance_coefficient as rc, defense_coefficient as dc, attr_common_fix, e_fix, a_fix
|
||||
|
||||
mask_top = load_image(path=Path(__file__).parent.parent.parent / 'res' / 'player_card2' / '遮罩top.png')
|
||||
mask_body = load_image(path=Path(__file__).parent.parent.parent / 'res' / 'player_card2' / '遮罩body.png')
|
||||
mask_bottom = load_image(path=Path(__file__).parent.parent.parent / 'res' / 'player_card2' / '遮罩bottom.png')
|
||||
skill_data = load_json(path=Path(__file__).parent.parent.parent / 'utils' / 'json' / 'roles_data.json')['魈']['skill']
|
||||
|
||||
|
||||
def cal_attack_dmg(data: dict, extra: dict, type: str) -> Tuple[float, float]:
|
||||
"""
|
||||
计算魈下落攻击的伤害
|
||||
:param data: 角色数据
|
||||
:param extra: 针对重击的额外数值
|
||||
:param type: 类型
|
||||
:return: 期望伤害和暴击后伤害
|
||||
"""
|
||||
role_level = data['等级']
|
||||
skill_level = data['天赋'][0]['等级'] - 1
|
||||
attack = data['属性']['基础攻击'] + data['属性']['额外攻击']
|
||||
cr = data['属性']['暴击率'] + extra['下落攻击暴击率']
|
||||
cd = data['属性']['暴击伤害']
|
||||
dmg_bonus = 1 + data['属性']['伤害加成'][5] + extra['下落攻击增伤']
|
||||
percent_value = skill_data['普通攻击·卷积微尘']['数值']['低空/高空坠地冲击伤害'][skill_level].split('/')
|
||||
if type.startswith('低空下落'):
|
||||
percent_value = float(percent_value[0].replace('%', '')) / 100
|
||||
else:
|
||||
percent_value = float(percent_value[1].replace('%', '')) / 100
|
||||
if role_level >= 40:
|
||||
dmg_bonus += 0.25 if '首戳' not in type else 0
|
||||
q_skill_level = data['天赋'][2]['等级'] - 1
|
||||
q_bonus = float(skill_data['靖妖傩舞']['数值']['普通攻击/重击/下落攻击伤害提升'][q_skill_level].replace('%', '')) / 100
|
||||
dmg_bonus += q_bonus
|
||||
damage = (attack * percent_value) * (1 + cr * cd) * dmg_bonus * rc() * dc(role_level)
|
||||
return damage, damage / (1 + cr * cd) * (1 + cd)
|
||||
|
||||
|
||||
def cal_e_dmg(data: dict, extra: dict) -> Tuple[float, float]:
|
||||
"""
|
||||
计算魈元素战技的伤害
|
||||
:param data: 角色数据
|
||||
:param extra: 针对元素战技的额外数值
|
||||
:return: 期望伤害和暴击后伤害
|
||||
"""
|
||||
role_level = data['等级']
|
||||
skill_level = data['天赋'][1]['等级'] - 1
|
||||
attack = data['属性']['基础攻击'] + data['属性']['额外攻击']
|
||||
cr = data['属性']['暴击率'] + extra['暴击率']
|
||||
cd = data['属性']['暴击伤害']
|
||||
dmg_bonus = 1 + data['属性']['伤害加成'][5] + extra['增伤']
|
||||
|
||||
percent_value = float(skill_data['风轮两立']['数值']['技能伤害'][skill_level].replace('%', '')) / 100.0
|
||||
damage = (attack * percent_value) * (1 + cr * cd) * dmg_bonus * rc() * dc(role_level)
|
||||
return damage, damage / (1 + cr * cd) * (1 + cd)
|
||||
|
||||
|
||||
def draw_xiao_dmg(data: dict):
|
||||
data = deepcopy(data)
|
||||
height = 3 * 60 - 20
|
||||
if '伤害描述' in data and data['伤害描述']:
|
||||
height += 60
|
||||
data = attr_common_fix(data)
|
||||
data, e_value = e_fix(data)
|
||||
data, a_value = a_fix(data)
|
||||
|
||||
bg = Image.new('RGBA', (948, height + 80), (0, 0, 0, 0))
|
||||
bg.alpha_composite(mask_top, (0, 0))
|
||||
bg.alpha_composite(mask_body.resize((948, height)), (0, 60))
|
||||
bg.alpha_composite(mask_bottom, (0, height + 60))
|
||||
bg_draw = ImageDraw.Draw(bg)
|
||||
# 画线
|
||||
bg_draw.line((250, 0, 250, 948), (255, 255, 255, 75), 2)
|
||||
bg_draw.line((599, 0, 599, 300), (255, 255, 255, 75), 2)
|
||||
bg_draw.line((0, 60, 948, 60), (255, 255, 255, 75), 2)
|
||||
bg_draw.line((0, 120, 948, 120), (255, 255, 255, 75), 2)
|
||||
bg_draw.line((0, 180, 948, 180), (255, 255, 255, 75), 2)
|
||||
# 顶栏
|
||||
draw_center_text(bg_draw, '伤害计算', 0, 250, 11, 'white', get_font(30))
|
||||
draw_center_text(bg_draw, '期望伤害', 250, 599, 11, 'white', get_font(30))
|
||||
draw_center_text(bg_draw, '暴击伤害', 599, 948, 11, 'white', get_font(30))
|
||||
|
||||
# e
|
||||
draw_center_text(bg_draw, '风轮两立', 0, 250, 73, 'white', get_font(30))
|
||||
expect_dmg, crit_dmg = cal_e_dmg(data, e_value)
|
||||
draw_center_text(bg_draw, str(int(expect_dmg)), 250, 599, 76, 'white', get_font(30, 'number.ttf'))
|
||||
draw_center_text(bg_draw, str(int(crit_dmg)), 599, 948, 76, 'white', get_font(30, 'number.ttf'))
|
||||
|
||||
# 重击蒸发
|
||||
draw_center_text(bg_draw, '低空下落首戳', 0, 250, 133, 'white', get_font(30))
|
||||
expect_dmg, crit_dmg = cal_attack_dmg(data, a_value, '低空下落首戳')
|
||||
draw_center_text(bg_draw, str(int(expect_dmg)), 250, 599, 136, 'white', get_font(30, 'number.ttf'))
|
||||
draw_center_text(bg_draw, str(int(crit_dmg)), 599, 948, 136, 'white', get_font(30, 'number.ttf'))
|
||||
|
||||
# 大招蒸发
|
||||
draw_center_text(bg_draw, '高空下落首戳', 0, 250, 193, 'white', get_font(30))
|
||||
expect_dmg, crit_dmg = cal_attack_dmg(data, a_value, '高空下落首戳')
|
||||
draw_center_text(bg_draw, str(int(expect_dmg)), 250, 599, 196, 'white', get_font(30, 'number.ttf'))
|
||||
draw_center_text(bg_draw, str(int(crit_dmg)), 599, 948, 196, 'white', get_font(30, 'number.ttf'))
|
||||
|
||||
# 额外说明
|
||||
if data['伤害描述']:
|
||||
bg_draw.line((0, 240, 948, 240), (255, 255, 255, 75), 2)
|
||||
draw_center_text(bg_draw, '额外说明', 0, 250, 256, 'white', get_font(30))
|
||||
draw_center_text(bg_draw, ','.join(data['伤害描述']), 250, 948, 256, 'white', get_font(30))
|
||||
return bg
|
@ -1,4 +1,4 @@
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from PIL import Image, ImageDraw
|
||||
from pathlib import Path
|
||||
|
||||
from utils.file_handler import load_image, load_json
|
||||
@ -56,12 +56,11 @@ async def draw_role_card(uid, data):
|
||||
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((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))
|
||||
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'))
|
||||
@ -282,10 +281,8 @@ async def draw_role_card(uid, data):
|
||||
else:
|
||||
bg.alpha_composite(load_image(path=paint_path), (695, 234))
|
||||
|
||||
# 伤害计算
|
||||
|
||||
# 更新时间和Paimon标志
|
||||
bg_draw.text((50, bg.size[1] - 50), f'更新于{data["更新时间"].replace("2022-", "")}', fill='white', font=get_font(36, '优设标题黑.ttf'))
|
||||
bg_draw.text((560, bg.size[1] - 51), 'Created by LittlePaimon', fill='white', font=get_font(36, '优设标题黑.ttf'))
|
||||
draw_center_text(bg_draw, f'更新于{data["更新时间"].replace("2022-", "")[:-3]}', 0, 1080, bg.size[1] - 95, '#afafaf', get_font(33, '优设标题黑.ttf'))
|
||||
bg_draw.text((24, bg.size[1] - 50), 'Created by LittlePaimon | Powered by Enka.Network', fill='white',
|
||||
font=get_font(36, '优设标题黑.ttf'))
|
||||
|
||||
return MessageBuild.Image(bg, quality=75, mode='RGB')
|
||||
|
@ -67,7 +67,9 @@
|
||||
- `原神猜语音`新的角色也能正确匹配识别[#82](https://github.com/CMHopeSunshine/LittlePaimon/pull/82)
|
||||
- 修复`获取抽卡记录`问题[#81](https://github.com/CMHopeSunshine/LittlePaimon/issues/81)
|
||||
+ 6.30
|
||||
- `ysd`支持查看`钟离、胡桃、雷电将军`的伤害计算beta(~~可能BUG有点多~~)
|
||||
- `ysd`支持查看`钟离、胡桃、雷电将军`的伤害计算(~~如果不准请反馈~~)
|
||||
+ 7.1
|
||||
- 伤害计算新增`魈`
|
||||
## 丨功能列表
|
||||
|
||||
详见我的博客[功能列表](https://blog.cherishmoon.fun/posts/nonebot2funclist.html) <br>
|
||||
|
@ -58,4 +58,6 @@
|
||||
- `原神猜语音`新的角色也能正确匹配识别[#82](https://github.com/CMHopeSunshine/LittlePaimon/pull/82)
|
||||
- 修复`获取抽卡记录`问题[#81](https://github.com/CMHopeSunshine/LittlePaimon/issues/81)
|
||||
+ 6.30
|
||||
- `ysd`支持查看`钟离、胡桃、雷电将军`的伤害计算beta(~~可能BUG有点多~~)
|
||||
- `ysd`支持查看`钟离、胡桃、雷电将军`的伤害计算(~~如果不准请反馈~~)
|
||||
+ 7.1
|
||||
- 伤害计算新增`魈`
|
Loading…
x
Reference in New Issue
Block a user