🚨 pre-commit-ci修复格式错误

This commit is contained in:
pre-commit-ci[bot] 2023-10-27 06:47:22 +00:00
parent 163644a15d
commit b7734598d4
6 changed files with 374 additions and 269 deletions

View File

@ -1,18 +1,16 @@
import re
from pathlib import Path
from typing import Tuple, cast
import asyncio
from PIL import Image
from gsuid_core.sv import SV
from gsuid_core.bot import Bot
from gsuid_core.models import Event
from .cal_damage import cal_info
from .to_card import api_to_card
from ..utils.convert import get_uid
from ..utils.sr_prefix import PREFIX
from ..utils.error_reply import UID_HINT
from .draw_char_img import get_char_data
from .get_char_img import draw_char_info_img
from ..utils.image.convert import convert_img
from ..utils.resource.RESOURCE_PATH import TEMP_PATH
@ -21,6 +19,7 @@ sv_char_info_config = SV('sr面板设置', pm=2)
sv_get_char_info = SV('sr面板查询', priority=10)
sv_get_sr_original_pic = SV('sr查看面板原图', priority=5)
@sv_get_char_info.on_prefix(f'{PREFIX}查询')
async def send_char_info(bot: Bot, ev: Event):
im = await _get_char_info(bot, ev, ev.text)

View File

@ -1,9 +1,9 @@
import json
from pathlib import Path
from typing import Dict, List, Union
from typing import Dict
from .mono.Character import Character
from .damage.Avatar import AvatarInstance
async def cal_char_info(char_data: Dict):
char: Character = Character(char_data)
await char.get_equipment_info()
@ -11,6 +11,7 @@ async def cal_char_info(char_data: Dict):
await char.get_relic_info()
return char
async def cal_info(char_data: Dict):
char = await cal_char_info(char_data)
avatar = AvatarInstance(char)

View File

@ -1,20 +1,22 @@
from typing import Dict
import copy
from typing import Dict
from gsuid_core.logger import logger
from .utils import merge_attribute
async def calculate_heal(
base_attr: Dict[str, float],
attribute_bonus: Dict[str, float],
skill_type: str,
skill_multiplier: float,
skill_num: float,
is_atk = 0,
is_atk=0,
):
add_attr_bonus = copy.deepcopy(attribute_bonus)
merged_attr = await merge_attribute(base_attr, add_attr_bonus)
if is_atk == 1:
hp = merged_attr.get('attack', 0)
else:
@ -29,23 +31,21 @@ async def calculate_heal(
heal_ratio = heal_ratio_base + 1
logger.info(f'治疗量加成: {heal_ratio}')
heal_num = (
hp * skill_multiplier + skill_num
) * heal_ratio
heal_num = (hp * skill_multiplier + skill_num) * heal_ratio
return [heal_num]
skill_info_list = [heal_num]
return skill_info_list
async def calculate_shield(
base_attr: Dict[str, float],
attribute_bonus: Dict[str, float],
skill_multiplier: float,
skill_num: float,
is_atk = 0,
is_atk=0,
):
add_attr_bonus = copy.deepcopy(attribute_bonus)
merged_attr = await merge_attribute(base_attr, add_attr_bonus)
if is_atk == 1:
defence = merged_attr.get('attack', 0)
else:
@ -57,13 +57,11 @@ async def calculate_shield(
shield_added = shield_added_ratio + 1
logger.info(f'护盾加成: {shield_added}')
defence_num = (
defence * skill_multiplier + skill_num
) * shield_added
defence_num = (defence * skill_multiplier + skill_num) * shield_added
return [defence_num]
skill_info_list = [defence_num]
return skill_info_list
async def calculate_damage(
base_attr: Dict[str, float],
attribute_bonus: Dict[str, float],
@ -72,15 +70,15 @@ async def calculate_damage(
element: str,
skill_multiplier: float,
level: int,
is_hp = 0,
is_hp=0,
):
logger.info(f'Skill Multiplier: {skill_multiplier}')
logger.info(f'Skill Type: {skill_type}')
logger.info(f'Level: {level}')
# logger.info(f'attribute_bonus: {attribute_bonus}')
add_attr_bonus = copy.deepcopy(attribute_bonus)
add_attr_bonus = apply_attribute_bonus(
add_attr_bonus, skill_type, add_skill_type
)

View File

@ -1,9 +1,9 @@
import json
from pathlib import Path
from typing import Dict
from pathlib import Path
from ..Base.model import DamageInstanceWeapon
from ..Base.WeaponBase import BaseWeapon
from ..Base.model import DamageInstanceWeapon
path = Path(__file__).parent.parent
with Path.open(path / 'Excel' / 'weapon_effect.json', encoding='utf-8') as f:
@ -1747,6 +1747,7 @@ class WorrisomeBlissf(BaseWeapon):
)
return attribute_bonus
# 片刻,留在眼底
class AnInstanceBeforeAGaze(BaseWeapon):
weapon_base_attributes: Dict
@ -1777,6 +1778,7 @@ class AnInstanceBeforeAGaze(BaseWeapon):
)
return attribute_bonus
# 时节不居
class TimeWaitsforNoOne(BaseWeapon):
weapon_base_attributes: Dict
@ -1796,6 +1798,7 @@ class TimeWaitsforNoOne(BaseWeapon):
):
return attribute_bonus
# 棺的回响
class EchoesoftheCoffin(BaseWeapon):
weapon_base_attributes: Dict
@ -1815,16 +1818,12 @@ class EchoesoftheCoffin(BaseWeapon):
):
if await self.check():
speed_delta = attribute_bonus.get('SpeedDelta', 0)
attribute_bonus['SpeedDelta'] = (
speed_delta
+ (
weapon_effect['23008']['Param']['speed'][
self.weapon_rank - 1
]
)
attribute_bonus['SpeedDelta'] = speed_delta + (
weapon_effect['23008']['Param']['speed'][self.weapon_rank - 1]
)
return attribute_bonus
# 惊魂夜
class NightofFright(BaseWeapon):
weapon_base_attributes: Dict
@ -1855,6 +1854,7 @@ class NightofFright(BaseWeapon):
)
return attribute_bonus
# 一场术后对话
class PostOpConversation(BaseWeapon):
weapon_base_attributes: Dict
@ -1874,16 +1874,14 @@ class PostOpConversation(BaseWeapon):
):
if await self.check():
Ultra_HealRatioBase = attribute_bonus.get('Ultra_HealRatioBase', 0)
attribute_bonus['Ultra_HealRatioBase'] = (
Ultra_HealRatioBase
+ (
weapon_effect['21000']['Param']['Ultra_HealRatioBase'][
self.weapon_rank - 1
]
)
attribute_bonus['Ultra_HealRatioBase'] = Ultra_HealRatioBase + (
weapon_effect['21000']['Param']['Ultra_HealRatioBase'][
self.weapon_rank - 1
]
)
return attribute_bonus
# 同一种心情
class SharedFeeling(BaseWeapon):
weapon_base_attributes: Dict
@ -1903,6 +1901,7 @@ class SharedFeeling(BaseWeapon):
):
return attribute_bonus
# 此时恰好
class PerfectTiming(BaseWeapon):
weapon_base_attributes: Dict
@ -1922,12 +1921,22 @@ class PerfectTiming(BaseWeapon):
):
if await self.check():
StatusResistance = attribute_bonus.get('StatusResistance', 0)
HealRatioBase_maxadd = weapon_effect['21000']['Param']['HealRatioBase'][self.weapon_rank - 1]
HealRatioBaseadd = StatusResistance * weapon_effect['21000']['Param']['StatusResistance'][self.weapon_rank - 1]
HealRatioBase_maxadd = weapon_effect['21000']['Param'][
'HealRatioBase'
][self.weapon_rank - 1]
HealRatioBaseadd = (
StatusResistance
* weapon_effect['21000']['Param']['StatusResistance'][
self.weapon_rank - 1
]
)
HealRatioBase = attribute_bonus.get('HealRatioBase', 0)
attribute_bonus['HealRatioBase'] = HealRatioBase + min(HealRatioBaseadd, HealRatioBase_maxadd)
attribute_bonus['HealRatioBase'] = HealRatioBase + min(
HealRatioBaseadd, HealRatioBase_maxadd
)
return attribute_bonus
# 等价交换
class QuidProQuo(BaseWeapon):
weapon_base_attributes: Dict
@ -1947,6 +1956,7 @@ class QuidProQuo(BaseWeapon):
):
return attribute_bonus
# 暖夜不会漫长
class WarmthShortensColdNights(BaseWeapon):
weapon_base_attributes: Dict
@ -1966,6 +1976,7 @@ class WarmthShortensColdNights(BaseWeapon):
):
return attribute_bonus
# 嘿,我在这儿
class HeyOverHere(BaseWeapon):
weapon_base_attributes: Dict
@ -1985,16 +1996,14 @@ class HeyOverHere(BaseWeapon):
):
if await self.check():
HealRatioBase = attribute_bonus.get('HealRatioBase', 0)
attribute_bonus['HealRatioBase'] = (
HealRatioBase
+ (
weapon_effect['22001']['Param']['HealRatioBase'][
self.weapon_rank - 1
]
)
attribute_bonus['HealRatioBase'] = HealRatioBase + (
weapon_effect['22001']['Param']['HealRatioBase'][
self.weapon_rank - 1
]
)
return attribute_bonus
# 物穰
class Cornucopia(BaseWeapon):
weapon_base_attributes: Dict
@ -2014,25 +2023,24 @@ class Cornucopia(BaseWeapon):
):
if await self.check():
Ultra_HealRatioBase = attribute_bonus.get('Ultra_HealRatioBase', 0)
attribute_bonus['Ultra_HealRatioBase'] = (
Ultra_HealRatioBase
+ (
weapon_effect['20001']['Param']['HealRatioBase'][
self.weapon_rank - 1
]
)
attribute_bonus['Ultra_HealRatioBase'] = Ultra_HealRatioBase + (
weapon_effect['20001']['Param']['HealRatioBase'][
self.weapon_rank - 1
]
)
BPSkill_HealRatioBase = attribute_bonus.get('BPSkill_HealRatioBase', 0)
attribute_bonus['BPSkill_HealRatioBase'] = (
BPSkill_HealRatioBase
+ (
weapon_effect['20001']['Param']['HealRatioBase'][
self.weapon_rank - 1
]
)
BPSkill_HealRatioBase = attribute_bonus.get(
'BPSkill_HealRatioBase', 0
)
attribute_bonus[
'BPSkill_HealRatioBase'
] = BPSkill_HealRatioBase + (
weapon_effect['20001']['Param']['HealRatioBase'][
self.weapon_rank - 1
]
)
return attribute_bonus
# 嘉果
class FineFruit(BaseWeapon):
weapon_base_attributes: Dict
@ -2052,6 +2060,7 @@ class FineFruit(BaseWeapon):
):
return attribute_bonus
# 蕃息
class Multiplication(BaseWeapon):
weapon_base_attributes: Dict
@ -2071,6 +2080,7 @@ class Multiplication(BaseWeapon):
):
return attribute_bonus
# 但战斗还未结束
class ButtheBattleIsnotOver(BaseWeapon):
weapon_base_attributes: Dict
@ -2090,6 +2100,7 @@ class ButtheBattleIsnotOver(BaseWeapon):
):
return attribute_bonus
# 记忆中的模样
class MemoriesofthePast(BaseWeapon):
weapon_base_attributes: Dict
@ -2109,6 +2120,7 @@ class MemoriesofthePast(BaseWeapon):
):
return attribute_bonus
# 与行星相会
class PlanetaryRendezvous(BaseWeapon):
weapon_base_attributes: Dict
@ -2127,16 +2139,14 @@ class PlanetaryRendezvous(BaseWeapon):
attribute_bonus: Dict[str, float],
):
all_damage_added_ratio = attribute_bonus.get('AllDamageAddedRatio', 0)
attribute_bonus['AllDamageAddedRatio'] = (
all_damage_added_ratio
+ (
weapon_effect['21011']['Param']['AllDamageAddedRatio'][
self.weapon_rank - 1
]
)
attribute_bonus['AllDamageAddedRatio'] = all_damage_added_ratio + (
weapon_effect['21011']['Param']['AllDamageAddedRatio'][
self.weapon_rank - 1
]
)
return attribute_bonus
# 舞!舞!舞!
class DanceDanceDance(BaseWeapon):
weapon_base_attributes: Dict
@ -2156,6 +2166,7 @@ class DanceDanceDance(BaseWeapon):
):
return attribute_bonus
# 过往未来
class PastandFuture(BaseWeapon):
weapon_base_attributes: Dict
@ -2175,6 +2186,7 @@ class PastandFuture(BaseWeapon):
):
return attribute_bonus
# 镂月裁云之意
class CarvetheMoonWeavetheClouds(BaseWeapon):
weapon_base_attributes: Dict
@ -2196,16 +2208,14 @@ class CarvetheMoonWeavetheClouds(BaseWeapon):
attribute_bonus: Dict[str, float],
):
AttackAddedRatio = attribute_bonus.get('AttackAddedRatio', 0)
attribute_bonus['AttackAddedRatio'] = (
AttackAddedRatio
+ (
weapon_effect['21032']['Param']['AttackAddedRatio'][
self.weapon_rank - 1
]
)
attribute_bonus['AttackAddedRatio'] = AttackAddedRatio + (
weapon_effect['21032']['Param']['AttackAddedRatio'][
self.weapon_rank - 1
]
)
return attribute_bonus
# 齐颂
class Chorus(BaseWeapon):
weapon_base_attributes: Dict
@ -2224,16 +2234,14 @@ class Chorus(BaseWeapon):
attribute_bonus: Dict[str, float],
):
AttackAddedRatio = attribute_bonus.get('AttackAddedRatio', 0)
attribute_bonus['AttackAddedRatio'] = (
AttackAddedRatio
+ (
weapon_effect['20005']['Param']['AttackAddedRatio'][
self.weapon_rank - 1
]
)
attribute_bonus['AttackAddedRatio'] = AttackAddedRatio + (
weapon_effect['20005']['Param']['AttackAddedRatio'][
self.weapon_rank - 1
]
)
return attribute_bonus
# 轮契
class MeshingCogs(BaseWeapon):
weapon_base_attributes: Dict
@ -2253,6 +2261,7 @@ class MeshingCogs(BaseWeapon):
):
return attribute_bonus
# 调和
class Mediation(BaseWeapon):
weapon_base_attributes: Dict
@ -2272,16 +2281,12 @@ class Mediation(BaseWeapon):
):
if await self.check():
speed_delta = attribute_bonus.get('SpeedDelta', 0)
attribute_bonus['SpeedDelta'] = (
speed_delta
+ (
weapon_effect['20019']['Param']['speed'][
self.weapon_rank - 1
]
)
attribute_bonus['SpeedDelta'] = speed_delta + (
weapon_effect['20019']['Param']['speed'][self.weapon_rank - 1]
)
return attribute_bonus
class Weapon:
@classmethod
def create(cls, weapon: DamageInstanceWeapon):

View File

@ -5,14 +5,29 @@ import textwrap
from pathlib import Path
from typing import Dict, Union
from PIL import Image, ImageDraw
from gsuid_core.logger import logger
from gsuid_core.utils.image.convert import convert_img
from gsuid_core.utils.image.image_tools import draw_text_by_line
from PIL import Image, ImageDraw
from .to_data import api_to_dict
from ..utils.error_reply import CHAR_HINT
from ..utils.excel.read_excel import light_cone_ranks
from .cal_damage import cal_info, cal_char_info
from ..utils.fonts.first_world import fw_font_28
from ..utils.excel.read_excel import light_cone_ranks
from ..utils.map.name_covert import name_to_avatar_id, alias_to_char_name
from ..utils.map.SR_MAP_PATH import (
RelicId2Rarity,
AvatarRelicScore,
avatarId2Name,
)
from ..utils.resource.RESOURCE_PATH import (
RELIC_PATH,
SKILL_PATH,
PLAYER_PATH,
WEAPON_PATH,
CHAR_PORTRAIT_PATH,
)
from ..utils.fonts.starrail_fonts import (
sr_font_18,
sr_font_20,
@ -23,21 +38,6 @@ from ..utils.fonts.starrail_fonts import (
sr_font_34,
sr_font_38,
)
from ..utils.map.name_covert import alias_to_char_name, name_to_avatar_id
from ..utils.map.SR_MAP_PATH import (
AvatarRelicScore,
RelicId2Rarity,
avatarId2Name,
)
from ..utils.resource.RESOURCE_PATH import (
CHAR_PORTRAIT_PATH,
PLAYER_PATH,
RELIC_PATH,
SKILL_PATH,
WEAPON_PATH,
)
from .cal_damage import cal_char_info, cal_info
from .to_data import api_to_dict
Excel_path = Path(__file__).parent / 'damage'
with Path.open(Excel_path / 'Excel' / 'SkillData.json', encoding='utf-8') as f:
@ -300,9 +300,11 @@ async def draw_char_img(char_data: Dict, sr_uid: str, msg: str):
rank_bg = Image.open(TEXT_PATH / 'mz_bg.png')
rank_no_bg = Image.open(TEXT_PATH / 'mz_no_bg.png')
if rank < char.char_rank:
rank_img = Image.open(
SKILL_PATH / f'{char.char_id}{RANK_MAP[rank + 1]}'
).convert('RGBA').resize((50, 50))
rank_img = (
Image.open(SKILL_PATH / f'{char.char_id}{RANK_MAP[rank + 1]}')
.convert('RGBA')
.resize((50, 50))
)
rank_bg.paste(rank_img, (19, 19), rank_img)
char_info.paste(rank_bg, (20 + rank * 80, 630), rank_bg)
else:
@ -325,10 +327,14 @@ async def draw_char_img(char_data: Dict, sr_uid: str, msg: str):
for skill in char.char_skill:
skill_attr_img = Image.open(TEXT_PATH / f'skill_attr{i + 1}.png')
skill_panel_img = Image.open(TEXT_PATH / 'skill_panel.png')
skill_img = Image.open(
SKILL_PATH / f'{char.char_id}_'
f'{skill_type_map[skill["skillAttackType"]][1]}.png'
).convert('RGBA').resize((55, 55))
skill_img = (
Image.open(
SKILL_PATH / f'{char.char_id}_'
f'{skill_type_map[skill["skillAttackType"]][1]}.png'
)
.convert('RGBA')
.resize((55, 55))
)
skill_panel_img.paste(skill_img, (18, 15), skill_img)
skill_panel_img.paste(skill_attr_img, (80, 10), skill_attr_img)
skill_panel_img_draw = ImageDraw.Draw(skill_panel_img)
@ -781,7 +787,15 @@ async def get_relic_score(
if weight_dict == {}:
return 0
if is_main:
elementlist = ['Quantum', 'Thunder', 'Wind', 'Physical', 'Imaginary', 'Ice', 'Fire']
elementlist = [
'Quantum',
'Thunder',
'Wind',
'Physical',
'Imaginary',
'Ice',
'Fire',
]
if relicType in [3, 4, 5, 6]:
if subProperty.__contains__('AddedRatio') and relicType == 5:
if subProperty.split('AddedRatio')[0] in elementlist: