From a15dea8361ff7bb4b948afede7f153c9d84c09cf Mon Sep 17 00:00:00 2001 From: qwerdvd <2450899274@qq.com> Date: Sat, 30 Sep 2023 16:32:30 +0800 Subject: [PATCH] =?UTF-8?q?format=20=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StarRailUID/sruid_utils/api/mys/api.py | 68 +- .../starrailuid_charinfo/draw_char_img.py | 11 +- .../effect/Avatar/Avatar.py | 12 +- .../effect/Relic/Relic.py | 1488 +++---- .../starrailuid_charinfo/effect/Role.py | 4 +- .../effect/Weapon/Weapon.py | 3890 +++++++++-------- .../starrailuid_charinfo/get_char_img.py | 4 +- StarRailUID/starrailuid_charinfo/to_card.py | 4 +- .../starrailuid_config/config_default.py | 4 +- StarRailUID/starrailuid_gachalog/__init__.py | 4 +- .../starrailuid_gachalog/get_gachalogs.py | 14 +- .../starrailuid_note/draw_note_card.py | 557 +-- StarRailUID/starrailuid_resource/__init__.py | 4 +- StarRailUID/starrailuid_signin/__init__.py | 8 +- StarRailUID/starrailuid_signin/sign.py | 20 +- .../starrailuid_stamina/draw_stamina_card.py | 3 +- StarRailUID/starrailuid_user/__init__.py | 7 +- .../utils/resource/download_from_cos.py | 8 +- 18 files changed, 3099 insertions(+), 3011 deletions(-) diff --git a/StarRailUID/sruid_utils/api/mys/api.py b/StarRailUID/sruid_utils/api/mys/api.py index 63454c3..2799521 100644 --- a/StarRailUID/sruid_utils/api/mys/api.py +++ b/StarRailUID/sruid_utils/api/mys/api.py @@ -1,60 +1,70 @@ # flake8: noqa OLD_URL = "https://api-takumi.mihoyo.com" OS_OLD_URL = "https://api-os-takumi.mihoyo.com" -NEW_URL = 'https://api-takumi-record.mihoyo.com' +NEW_URL = "https://api-takumi-record.mihoyo.com" OS_URL = "https://sg-public-api.hoyolab.com" OS_INFO_URL = "https://bbs-api-os.hoyolab.com" -STAR_RAIL_SIGN_INFO_URL = f'{OLD_URL}/event/luna/info' -STAR_RAIL_SIGN_INFO_URL_OS = f'{OS_URL}/event/luna/os/info' -STAR_RAIL_SIGN_LIST_URL = f'{OLD_URL}/event/luna/home' -STAR_RAIL_SIGN_LIST_URL_OS = f'{OS_URL}/event/luna/os/home' -STAR_RAIL_SIGN_EXTRA_INFO_URL = f'{OLD_URL}/event/luna/extra_info' -STAR_RAIL_SIGN_EXTRA_REWARD_URL = f'{OLD_URL}/event/luna/extra_reward' -STAR_RAIL_SIGN_URL = f'{OLD_URL}/event/luna/sign' -STAR_RAIL_SIGN_URL_OS = f'{OS_URL}/event/luna/os/sign' -STAR_RAIL_MONTH_INFO_URL = f'{OLD_URL}/event/srledger/month_info' # 开拓阅历接口 +STAR_RAIL_SIGN_INFO_URL = f"{OLD_URL}/event/luna/info" +STAR_RAIL_SIGN_INFO_URL_OS = f"{OS_URL}/event/luna/os/info" +STAR_RAIL_SIGN_LIST_URL = f"{OLD_URL}/event/luna/home" +STAR_RAIL_SIGN_LIST_URL_OS = f"{OS_URL}/event/luna/os/home" +STAR_RAIL_SIGN_EXTRA_INFO_URL = f"{OLD_URL}/event/luna/extra_info" +STAR_RAIL_SIGN_EXTRA_REWARD_URL = f"{OLD_URL}/event/luna/extra_reward" +STAR_RAIL_SIGN_URL = f"{OLD_URL}/event/luna/sign" +STAR_RAIL_SIGN_URL_OS = f"{OS_URL}/event/luna/os/sign" +STAR_RAIL_MONTH_INFO_URL = ( + f"{OLD_URL}/event/srledger/month_info" +) # 开拓阅历接口 STAR_RAIL_MONTH_DETAIL_URL = ( - f'{OLD_URL}/event/srledger/month_detail' # 开拓阅历详情接口 + f"{OLD_URL}/event/srledger/month_detail" # 开拓阅历详情接口 ) -STAR_RAIL_NOTE_URL = f'{NEW_URL}/game_record/app/hkrpg/api/note' # 实时便签接口 -STAR_RAIL_NOTE_URL_OS = f'{OS_INFO_URL}/game_record/hkrpg/api/note' # OS实时便签接口 -STAR_RAIL_INDEX_URL = f'{NEW_URL}/game_record/app/hkrpg/api/index' # 角色橱窗接口 +STAR_RAIL_NOTE_URL = ( + f"{NEW_URL}/game_record/app/hkrpg/api/note" +) # 实时便签接口 +STAR_RAIL_NOTE_URL_OS = ( + f"{OS_INFO_URL}/game_record/hkrpg/api/note" +) # OS实时便签接口 +STAR_RAIL_INDEX_URL = ( + f"{NEW_URL}/game_record/app/hkrpg/api/index" +) # 角色橱窗接口 STAR_RAIL_INDEX_URL_OS = ( - f'{OS_INFO_URL}/game_record/hkrpg/api/index' # OS角色橱窗接口 + f"{OS_INFO_URL}/game_record/hkrpg/api/index" # OS角色橱窗接口 ) STAR_RAIL_AVATAR_BASIC_URL = ( - f'{NEW_URL}/game_record/app/hkrpg/api/avatar/basic' # 全部角色接口 + f"{NEW_URL}/game_record/app/hkrpg/api/avatar/basic" # 全部角色接口 ) STAR_RAIL_ROLE_BASIC_INFO_URL = ( - f'{NEW_URL}/game_record/app/hkrpg/api/role/basicInfo' # 角色基础信息接口 + f"{NEW_URL}/game_record/app/hkrpg/api/role/basicInfo" # 角色基础信息接口 ) -STAR_RAIL_ROLE_BASIC_INFO_URL_OS = f'{OS_INFO_URL}/game_record/hkrpg/api/index' +STAR_RAIL_ROLE_BASIC_INFO_URL_OS = f"{OS_INFO_URL}/game_record/hkrpg/api/index" STAR_RAIL_AVATAR_INFO_URL = ( - f'{NEW_URL}/game_record/app/hkrpg/api/avatar/info' # 角色详细信息接口 + f"{NEW_URL}/game_record/app/hkrpg/api/avatar/info" # 角色详细信息接口 ) STAR_RAIL_AVATAR_INFO_URL_OS = ( - f'{OS_INFO_URL}/game_record/hkrpg/api/avatar/info' # OS角色详细信息接口 + f"{OS_INFO_URL}/game_record/hkrpg/api/avatar/info" # OS角色详细信息接口 ) -CHALLENGE_INFO_URL = f'{NEW_URL}/game_record/app/hkrpg/api/challenge' -CHALLENGE_INFO_URL_OS = f'{OS_INFO_URL}/game_record/hkrpg/api/challenge' +CHALLENGE_INFO_URL = f"{NEW_URL}/game_record/app/hkrpg/api/challenge" +CHALLENGE_INFO_URL_OS = f"{OS_INFO_URL}/game_record/hkrpg/api/challenge" -ROGUE_INFO_URL = f'{NEW_URL}/game_record/app/hkrpg/api/rogue' # 角色模拟宇宙信息接口 +ROGUE_INFO_URL = ( + f"{NEW_URL}/game_record/app/hkrpg/api/rogue" +) # 角色模拟宇宙信息接口 ROGUE_LOCUST_INFO_URL = ( - f'{NEW_URL}/game_record/app/hkrpg/api/rogue_locust' # 角色寰宇蝗灾信息接口 + f"{NEW_URL}/game_record/app/hkrpg/api/rogue_locust" # 角色寰宇蝗灾信息接口 ) -STAR_RAIL_GACHA_LOG_URL = f'{OLD_URL}/common/gacha_record/api/getGachaLog' +STAR_RAIL_GACHA_LOG_URL = f"{OLD_URL}/common/gacha_record/api/getGachaLog" STAR_RAIL_GACHA_LOG_URL_OS = ( - f'{OS_OLD_URL}/common/gacha_record/api/getGachaLog' + f"{OS_OLD_URL}/common/gacha_record/api/getGachaLog" ) -GET_FP_URL = 'https://public-data-api.mihoyo.com/device-fp/api/getFp' -GET_FP_URL_OS = 'https://sg-public-data-api.hoyoverse.com/device-fp/api/getFp' +GET_FP_URL = "https://public-data-api.mihoyo.com/device-fp/api/getFp" +GET_FP_URL_OS = "https://sg-public-data-api.hoyoverse.com/device-fp/api/getFp" # CREATE_QRCODE = f'{OLD_URL}/event/bbs_sign_reward/gen_auth_code' -STAR_RAIL_WIDGRT_URL = f'{NEW_URL}/game_record/app/hkrpg/aapi/widget' +STAR_RAIL_WIDGRT_URL = f"{NEW_URL}/game_record/app/hkrpg/aapi/widget" _API = locals() diff --git a/StarRailUID/starrailuid_charinfo/draw_char_img.py b/StarRailUID/starrailuid_charinfo/draw_char_img.py index 0ba2f31..6fa3d3d 100644 --- a/StarRailUID/starrailuid_charinfo/draw_char_img.py +++ b/StarRailUID/starrailuid_charinfo/draw_char_img.py @@ -46,7 +46,16 @@ TEXT_PATH = Path(__file__).parent / 'texture2D' bg_img = Image.open(TEXT_PATH / 'bg.png') white_color = (213, 213, 213) -NUM_MAP = {0: '零', 1: '一', 2: '二', 3: '三', 4: '四', 5: '五', 6: '六', 7: '七'} +NUM_MAP = { + 0: '零', + 1: '一', + 2: '二', + 3: '三', + 4: '四', + 5: '五', + 6: '六', + 7: '七', +} RANK_MAP = { 1: '_rank1.png', diff --git a/StarRailUID/starrailuid_charinfo/effect/Avatar/Avatar.py b/StarRailUID/starrailuid_charinfo/effect/Avatar/Avatar.py index d2c020a..1699494 100644 --- a/StarRailUID/starrailuid_charinfo/effect/Avatar/Avatar.py +++ b/StarRailUID/starrailuid_charinfo/effect/Avatar/Avatar.py @@ -59,7 +59,9 @@ class JingYuan(BaseAvatar): def extra_ability(self): logger.info('额外能力') - logger.info('【神君】下回合的攻击段数大于等于6段, 则其下回合的暴击伤害提高25%。') + logger.info( + '【神君】下回合的攻击段数大于等于6段, 则其下回合的暴击伤害提高25%。' + ) self.extra_ability_attribute['CriticalDamageBase'] = 0.25 logger.info('施放战技后, 暴击率提升10%') self.extra_ability_attribute['CriticalChanceBase'] = 0.1 @@ -118,7 +120,9 @@ class Danhengil(BaseAvatar): def extra_ability(self): logger.info('额外能力') - logger.info('对拥有虚数属性弱点的敌方目标造成伤害时, 暴击伤害提高24%。') + logger.info( + '对拥有虚数属性弱点的敌方目标造成伤害时, 暴击伤害提高24%。' + ) self.extra_ability_attribute['CriticalDamageBase'] = 0.24 @@ -316,7 +320,9 @@ class Welt(BaseAvatar): def extra_ability(self): logger.info('额外能力') - logger.info('施放终结技时, 有100%基础概率使目标受到的伤害提高12%, 持续2回合。') + logger.info( + '施放终结技时, 有100%基础概率使目标受到的伤害提高12%, 持续2回合。' + ) logger.info('对被弱点击破的敌方目标造成的伤害提高20') self.extra_ability_attribute['AllDamageAddedRatio'] = 0.32 diff --git a/StarRailUID/starrailuid_charinfo/effect/Relic/Relic.py b/StarRailUID/starrailuid_charinfo/effect/Relic/Relic.py index 7a7f001..cf40c97 100644 --- a/StarRailUID/starrailuid_charinfo/effect/Relic/Relic.py +++ b/StarRailUID/starrailuid_charinfo/effect/Relic/Relic.py @@ -1,744 +1,744 @@ -from collections import Counter -from typing import Dict, List, Union - -from gsuid_core.logger import logger - -from ..utils import merge_attribute -from ..Base.model import DamageInstanceRelic -from ..Base.RelicBase import SingleRelic, BaseRelicSetSkill - - -class Relic101(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 在战斗开始时 - """ - logger.info('Relic101 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - pass - return attribute_bonus - - -class Relic102(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 无 - """ - logger.info('Relic102 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - a_dmg = attribute_bonus.get('NormalDmgAdd', 0) - attribute_bonus['NormalDmgAdd'] = a_dmg + 0.10000000018626451 - return attribute_bonus - - -class Relic103(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 战斗中生效:装备者提供的护盾量提高 - """ - logger.info('Relic103 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - shield_added_ratio = attribute_bonus.get('shield_added_ratio', 0) - attribute_bonus['shield_added_ratio'] = ( - shield_added_ratio + 0.20000000018626451 - ) - return attribute_bonus - - -class Relic104(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者施放终结技 - """ - logger.info('Relic104 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - critical_damage_base = attribute_bonus.get('CriticalDamageBase', 0) - attribute_bonus['CriticalDamageBase'] = ( - critical_damage_base + 0.25000000023283064 - ) - return attribute_bonus - - -class Relic105(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 施放攻击或受到攻击时, 默认叠满 - """ - logger.info('Relic105 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio + 0.05000000004656613 * 5 - ) - return attribute_bonus - - -class Relic106(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 无 - """ - logger.info('Relic106 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - pass - return attribute_bonus - - -class Relic107(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - TODO: 检查是否是火属性伤害 - """ - logger.info('Relic107 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4: - e_dmg = attribute_bonus.get('BPSkillDmgAdd', 0) - attribute_bonus['BPSkillDmgAdd'] = e_dmg + 0.12000000011175871 - if self.pieces4 and await self.check(base_attr, attribute_bonus): - fire_added_ratio = attribute_bonus.get('FireAddedRatio', 0) - attribute_bonus['FireAddedRatio'] = ( - fire_added_ratio + 0.12000000011175871 - ) - return attribute_bonus - - -class Relic108(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者对敌方目标造成伤害 - 目标拥有量子属性弱点 - """ - logger.info('Relic108 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - logger.info(attribute_bonus) - ignore_defence = attribute_bonus.get('ignore_defence', 0) - attribute_bonus['ignore_defence'] = ( - ignore_defence + 0.10000000009313226 * 2 - ) - return attribute_bonus - - -class Relic109(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - TODO: 检查是否释放战技 - """ - logger.info('Relic109 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - logger.info(attribute_bonus) - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio + 0.20000000018626451 - ) - return attribute_bonus - - -class Relic110(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者施放终结技 - """ - logger.info('Relic110 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - logger.info('ModifyActionDelay') - pass - return attribute_bonus - - -class Relic111(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - self._count = count - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者击破敌方目标弱点 - """ - logger.info('Relic111 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - logger.info('ModifySPNew') - pass - return attribute_bonus - - -class Relic112(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - self._count = count - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者对陷入负面效果的敌方目标造成伤害 - 对陷入禁锢状态的敌方目标造成伤害 - """ - logger.info('Relic111 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - logger.info('对陷入负面效果的敌方目标造成伤害') - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base + 0.10000000009313226 - ) - if self.pieces4 and await self.check(base_attr, attribute_bonus): - logger.info('对陷入禁锢状态的敌方目标造成伤害') - critical_damage_base = attribute_bonus.get('CriticalDamageBase', 0) - attribute_bonus['CriticalDamageBase'] = ( - critical_damage_base + 0.20000000018626451 - ) - return attribute_bonus - - -class Relic113(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - self._count = count - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 当装备者受到攻击或被我方目标消耗生命值后, 暴击率提高8%, 持续2回合, 该效果最多叠加2层。 - """ - logger.info('Relic113 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - logger.info('当装备者受到攻击或被我方目标消耗生命值后') - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base + 0.08000000009313226 * 2 - ) - return attribute_bonus - - -class Relic114(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - self._count = count - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 当装备者对我方目标施放终结技时, 我方全体速度提高12%, 持续1回合, 该效果无法叠加。 - """ - logger.info('Relic114 check success') - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces4 and await self.check(base_attr, attribute_bonus): - speed_added_ratio = attribute_bonus.get('SpeedAddedRatio', 0) - attribute_bonus['SpeedAddedRatio'] = ( - speed_added_ratio + 0.12000000011175871 - ) - return attribute_bonus - - -class Relic301(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者的速度大于等于120 - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['speed'] >= 120: - logger.info('Relic306 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio + 0.12000000011175871 - ) - return attribute_bonus - - -class Relic302(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者的速度大于等于120 - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['speed'] >= 120: - logger.info('Relic306 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio + 0.0800000000745058 - ) - return attribute_bonus - - -class Relic303(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - # 提高装备者等同于当前效果命中25%的攻击力,最多提高25% - return True - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - merged_attr = await merge_attribute(base_attr, attribute_bonus) - status_probability = merged_attr.get('StatusProbabilityBase', 0) - # 提高装备者等同于当前效果命中25%的攻击力,最多提高25% - attribute_bonus['AttackAddedRatio'] = attack_added_ratio + min( - 0.25000000023283064, status_probability / 0.25 - ) - return attribute_bonus - - -class Relic304(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 备者的效果命中大于等于50% - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['StatusResistanceBase'] >= 0.5000000004656613: - logger.info('Relic306 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - defence_added_ratio = attribute_bonus.get('DefenceAddedRatio', 0) - attribute_bonus['DefenceAddedRatio'] = ( - defence_added_ratio + 0.1500000001396984 - ) - return attribute_bonus - - -class Relic305(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者的暴击伤害大于等于120% - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['CriticalDamageBase'] >= 1.2000000001862645: - logger.info('Relic306 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base + 0.6000000005587935 - ) - return attribute_bonus - - -class Relic306(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者当前暴击率大于等于50% - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['CriticalChanceBase'] >= 0.5: - logger.info('Relic306 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - q_dmg = attribute_bonus.get('UltraDmgAdd', 0) - attribute_bonus['UltraDmgAdd'] = q_dmg + 0.1500000001396984 - a3_dmg = attribute_bonus.get('TalentDmgAdd', 0) - attribute_bonus['TalentDmgAdd'] = a3_dmg + 0.1500000001396984 - return attribute_bonus - - -class Relic307(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者的速度大于等于145 - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['speed'] >= 145: - logger.info('Relic306 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - break_damage_added_ratio_base = attribute_bonus.get( - 'BreakDamageAddedRatioBase', 0 - ) - attribute_bonus['BreakDamageAddedRatioBase'] = ( - break_damage_added_ratio_base + 0.20000000018626451 - ) - return attribute_bonus - - -class Relic308(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 装备者的速度大于等于120 - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['speed'] >= 120: - logger.info('Relic306 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - logger.info('ModifyActionDelay') - return attribute_bonus - - -class Relic309(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 当装备者的当前暴击率大于等于70%时, 普攻和战技造成的伤害提高20%。 - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['CriticalChanceBase'] >= 0.7: - logger.info('Relic309 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - a_dmg = attribute_bonus.get('NormalDmgAdd', 0) - attribute_bonus['NormalDmgAdd'] = a_dmg + 0.20000000018626451 - a2_dmg = attribute_bonus.get('BPSkillDmgAdd', 0) - attribute_bonus['BPSkillDmgAdd'] = a2_dmg + 0.20000000018626451 - return attribute_bonus - - -class Relic310(BaseRelicSetSkill): - def __init__(self, set_id: int, count: int): - super().__init__(set_id, count) - - async def check( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - """ - 当装备者的效果抵抗大于等于30%时, 我方全体暴击伤害提高10%。 - """ - merged_attr = await merge_attribute(base_attr, attribute_bonus) - if merged_attr['StatusResistanceBase'] >= 0.3: - logger.info('Relic310 check success') - return True - return False - - async def set_skill_ability( - self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] - ): - if self.pieces2 and await self.check(base_attr, attribute_bonus): - critical_damage_base = attribute_bonus.get('CriticalDamageBase', 0) - attribute_bonus['CriticalDamageBase'] = ( - critical_damage_base + 0.10000000018626451 - ) - return attribute_bonus - - -class RelicSet: - HEAD: SingleRelic - HAND: SingleRelic - BODY: SingleRelic - FOOT: SingleRelic - NECK: SingleRelic - OBJECT: SingleRelic - Unknow: SingleRelic - - SetSkill: List[ - Union[ - Relic101, - Relic102, - Relic103, - Relic104, - Relic105, - Relic106, - Relic107, - Relic108, - Relic109, - Relic110, - Relic111, - Relic112, - Relic113, - Relic114, - Relic301, - Relic302, - Relic303, - Relic304, - Relic305, - Relic306, - Relic307, - Relic308, - Relic309, - Relic310, - ] - ] - - def create(self, relic_list: List[DamageInstanceRelic]): - set_id_list: List[int] = [] - for relic in relic_list: - set_id_list.append(relic.SetId) - - if relic.Type == 1: - self.HEAD = SingleRelic(relic) - elif relic.Type == 2: - self.HAND = SingleRelic(relic) - elif relic.Type == 3: - self.BODY = SingleRelic(relic) - elif relic.Type == 4: - self.FOOT = SingleRelic(relic) - elif relic.Type == 5: - self.NECK = SingleRelic(relic) - elif relic.Type == 6: - self.OBJECT = SingleRelic(relic) - else: - self.Unknow = SingleRelic(relic) - - self.set_id_counter = Counter(set_id_list).most_common() - self.check_set() - self.get_attribute() - return self - - def get_attribute(self): - for item in self.__dict__: - if type(self.__dict__[item]) == SingleRelic: - itme__: SingleRelic = self.__dict__[item] - itme__.get_attribute_() - - def check_set(self): - self.SetSkill = [] - for item in self.set_id_counter: - set_id = item[0] - count = item[1] - - if set_id == 101: - self.SetSkill.append(Relic101(set_id, count)) - elif set_id == 102: - self.SetSkill.append(Relic102(set_id, count)) - elif set_id == 103: - self.SetSkill.append(Relic103(set_id, count)) - elif set_id == 104: - self.SetSkill.append(Relic104(set_id, count)) - elif set_id == 105: - self.SetSkill.append(Relic105(set_id, count)) - elif set_id == 106: - self.SetSkill.append(Relic106(set_id, count)) - elif set_id == 107: - self.SetSkill.append(Relic107(set_id, count)) - elif set_id == 108: - self.SetSkill.append(Relic108(set_id, count)) - elif set_id == 109: - self.SetSkill.append(Relic109(set_id, count)) - elif set_id == 110: - self.SetSkill.append(Relic110(set_id, count)) - elif set_id == 111: - self.SetSkill.append(Relic111(set_id, count)) - elif set_id == 112: - self.SetSkill.append(Relic112(set_id, count)) - elif set_id == 113: - self.SetSkill.append(Relic113(set_id, count)) - elif set_id == 114: - self.SetSkill.append(Relic114(set_id, count)) - elif set_id == 301: - self.SetSkill.append(Relic301(set_id, count)) - elif set_id == 302: - self.SetSkill.append(Relic302(set_id, count)) - elif set_id == 303: - self.SetSkill.append(Relic303(set_id, count)) - elif set_id == 304: - self.SetSkill.append(Relic304(set_id, count)) - elif set_id == 305: - self.SetSkill.append(Relic305(set_id, count)) - elif set_id == 306: - self.SetSkill.append(Relic306(set_id, count)) - elif set_id == 307: - self.SetSkill.append(Relic307(set_id, count)) - elif set_id == 308: - self.SetSkill.append(Relic308(set_id, count)) - elif set_id == 309: - self.SetSkill.append(Relic309(set_id, count)) - elif set_id == 310: - self.SetSkill.append(Relic310(set_id, count)) - else: - raise Exception(f'Unknow SetId: {set_id}') +from collections import Counter +from typing import Dict, List, Union + +from gsuid_core.logger import logger + +from ..utils import merge_attribute +from ..Base.model import DamageInstanceRelic +from ..Base.RelicBase import SingleRelic, BaseRelicSetSkill + + +class Relic101(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 在战斗开始时 + """ + logger.info('Relic101 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + pass + return attribute_bonus + + +class Relic102(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 无 + """ + logger.info('Relic102 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + a_dmg = attribute_bonus.get('NormalDmgAdd', 0) + attribute_bonus['NormalDmgAdd'] = a_dmg + 0.10000000018626451 + return attribute_bonus + + +class Relic103(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 战斗中生效:装备者提供的护盾量提高 + """ + logger.info('Relic103 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + shield_added_ratio = attribute_bonus.get('shield_added_ratio', 0) + attribute_bonus['shield_added_ratio'] = ( + shield_added_ratio + 0.20000000018626451 + ) + return attribute_bonus + + +class Relic104(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者施放终结技 + """ + logger.info('Relic104 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + critical_damage_base = attribute_bonus.get('CriticalDamageBase', 0) + attribute_bonus['CriticalDamageBase'] = ( + critical_damage_base + 0.25000000023283064 + ) + return attribute_bonus + + +class Relic105(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 施放攻击或受到攻击时, 默认叠满 + """ + logger.info('Relic105 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + 0.05000000004656613 * 5 + ) + return attribute_bonus + + +class Relic106(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 无 + """ + logger.info('Relic106 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + pass + return attribute_bonus + + +class Relic107(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + TODO: 检查是否是火属性伤害 + """ + logger.info('Relic107 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4: + e_dmg = attribute_bonus.get('BPSkillDmgAdd', 0) + attribute_bonus['BPSkillDmgAdd'] = e_dmg + 0.12000000011175871 + if self.pieces4 and await self.check(base_attr, attribute_bonus): + fire_added_ratio = attribute_bonus.get('FireAddedRatio', 0) + attribute_bonus['FireAddedRatio'] = ( + fire_added_ratio + 0.12000000011175871 + ) + return attribute_bonus + + +class Relic108(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者对敌方目标造成伤害 + 目标拥有量子属性弱点 + """ + logger.info('Relic108 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + logger.info(attribute_bonus) + ignore_defence = attribute_bonus.get('ignore_defence', 0) + attribute_bonus['ignore_defence'] = ( + ignore_defence + 0.10000000009313226 * 2 + ) + return attribute_bonus + + +class Relic109(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + TODO: 检查是否释放战技 + """ + logger.info('Relic109 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + logger.info(attribute_bonus) + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + 0.20000000018626451 + ) + return attribute_bonus + + +class Relic110(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者施放终结技 + """ + logger.info('Relic110 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + logger.info('ModifyActionDelay') + pass + return attribute_bonus + + +class Relic111(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + self._count = count + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者击破敌方目标弱点 + """ + logger.info('Relic111 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + logger.info('ModifySPNew') + pass + return attribute_bonus + + +class Relic112(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + self._count = count + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者对陷入负面效果的敌方目标造成伤害 + 对陷入禁锢状态的敌方目标造成伤害 + """ + logger.info('Relic111 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + logger.info('对陷入负面效果的敌方目标造成伤害') + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + 0.10000000009313226 + ) + if self.pieces4 and await self.check(base_attr, attribute_bonus): + logger.info('对陷入禁锢状态的敌方目标造成伤害') + critical_damage_base = attribute_bonus.get('CriticalDamageBase', 0) + attribute_bonus['CriticalDamageBase'] = ( + critical_damage_base + 0.20000000018626451 + ) + return attribute_bonus + + +class Relic113(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + self._count = count + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 当装备者受到攻击或被我方目标消耗生命值后, 暴击率提高8%, 持续2回合, 该效果最多叠加2层。 + """ + logger.info('Relic113 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + logger.info('当装备者受到攻击或被我方目标消耗生命值后') + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + 0.08000000009313226 * 2 + ) + return attribute_bonus + + +class Relic114(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + self._count = count + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 当装备者对我方目标施放终结技时, 我方全体速度提高12%, 持续1回合, 该效果无法叠加。 + """ + logger.info('Relic114 check success') + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces4 and await self.check(base_attr, attribute_bonus): + speed_added_ratio = attribute_bonus.get('SpeedAddedRatio', 0) + attribute_bonus['SpeedAddedRatio'] = ( + speed_added_ratio + 0.12000000011175871 + ) + return attribute_bonus + + +class Relic301(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者的速度大于等于120 + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['speed'] >= 120: + logger.info('Relic306 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + 0.12000000011175871 + ) + return attribute_bonus + + +class Relic302(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者的速度大于等于120 + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['speed'] >= 120: + logger.info('Relic306 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + 0.0800000000745058 + ) + return attribute_bonus + + +class Relic303(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + # 提高装备者等同于当前效果命中25%的攻击力,最多提高25% + return True + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + merged_attr = await merge_attribute(base_attr, attribute_bonus) + status_probability = merged_attr.get('StatusProbabilityBase', 0) + # 提高装备者等同于当前效果命中25%的攻击力,最多提高25% + attribute_bonus['AttackAddedRatio'] = attack_added_ratio + min( + 0.25000000023283064, status_probability / 0.25 + ) + return attribute_bonus + + +class Relic304(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 备者的效果命中大于等于50% + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['StatusResistanceBase'] >= 0.5000000004656613: + logger.info('Relic306 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + defence_added_ratio = attribute_bonus.get('DefenceAddedRatio', 0) + attribute_bonus['DefenceAddedRatio'] = ( + defence_added_ratio + 0.1500000001396984 + ) + return attribute_bonus + + +class Relic305(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者的暴击伤害大于等于120% + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['CriticalDamageBase'] >= 1.2000000001862645: + logger.info('Relic306 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + 0.6000000005587935 + ) + return attribute_bonus + + +class Relic306(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者当前暴击率大于等于50% + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['CriticalChanceBase'] >= 0.5: + logger.info('Relic306 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + q_dmg = attribute_bonus.get('UltraDmgAdd', 0) + attribute_bonus['UltraDmgAdd'] = q_dmg + 0.1500000001396984 + a3_dmg = attribute_bonus.get('TalentDmgAdd', 0) + attribute_bonus['TalentDmgAdd'] = a3_dmg + 0.1500000001396984 + return attribute_bonus + + +class Relic307(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者的速度大于等于145 + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['speed'] >= 145: + logger.info('Relic306 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + break_damage_added_ratio_base = attribute_bonus.get( + 'BreakDamageAddedRatioBase', 0 + ) + attribute_bonus['BreakDamageAddedRatioBase'] = ( + break_damage_added_ratio_base + 0.20000000018626451 + ) + return attribute_bonus + + +class Relic308(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 装备者的速度大于等于120 + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['speed'] >= 120: + logger.info('Relic306 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + logger.info('ModifyActionDelay') + return attribute_bonus + + +class Relic309(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 当装备者的当前暴击率大于等于70%时, 普攻和战技造成的伤害提高20%。 + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['CriticalChanceBase'] >= 0.7: + logger.info('Relic309 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + a_dmg = attribute_bonus.get('NormalDmgAdd', 0) + attribute_bonus['NormalDmgAdd'] = a_dmg + 0.20000000018626451 + a2_dmg = attribute_bonus.get('BPSkillDmgAdd', 0) + attribute_bonus['BPSkillDmgAdd'] = a2_dmg + 0.20000000018626451 + return attribute_bonus + + +class Relic310(BaseRelicSetSkill): + def __init__(self, set_id: int, count: int): + super().__init__(set_id, count) + + async def check( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + """ + 当装备者的效果抵抗大于等于30%时, 我方全体暴击伤害提高10%。 + """ + merged_attr = await merge_attribute(base_attr, attribute_bonus) + if merged_attr['StatusResistanceBase'] >= 0.3: + logger.info('Relic310 check success') + return True + return False + + async def set_skill_ability( + self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] + ): + if self.pieces2 and await self.check(base_attr, attribute_bonus): + critical_damage_base = attribute_bonus.get('CriticalDamageBase', 0) + attribute_bonus['CriticalDamageBase'] = ( + critical_damage_base + 0.10000000018626451 + ) + return attribute_bonus + + +class RelicSet: + HEAD: SingleRelic + HAND: SingleRelic + BODY: SingleRelic + FOOT: SingleRelic + NECK: SingleRelic + OBJECT: SingleRelic + Unknow: SingleRelic + + SetSkill: List[ + Union[ + Relic101, + Relic102, + Relic103, + Relic104, + Relic105, + Relic106, + Relic107, + Relic108, + Relic109, + Relic110, + Relic111, + Relic112, + Relic113, + Relic114, + Relic301, + Relic302, + Relic303, + Relic304, + Relic305, + Relic306, + Relic307, + Relic308, + Relic309, + Relic310, + ] + ] + + def create(self, relic_list: List[DamageInstanceRelic]): + set_id_list: List[int] = [] + for relic in relic_list: + set_id_list.append(relic.SetId) + + if relic.Type == 1: + self.HEAD = SingleRelic(relic) + elif relic.Type == 2: + self.HAND = SingleRelic(relic) + elif relic.Type == 3: + self.BODY = SingleRelic(relic) + elif relic.Type == 4: + self.FOOT = SingleRelic(relic) + elif relic.Type == 5: + self.NECK = SingleRelic(relic) + elif relic.Type == 6: + self.OBJECT = SingleRelic(relic) + else: + self.Unknow = SingleRelic(relic) + + self.set_id_counter = Counter(set_id_list).most_common() + self.check_set() + self.get_attribute() + return self + + def get_attribute(self): + for item in self.__dict__: + if type(self.__dict__[item]) == SingleRelic: + itme__: SingleRelic = self.__dict__[item] + itme__.get_attribute_() + + def check_set(self): + self.SetSkill = [] + for item in self.set_id_counter: + set_id = item[0] + count = item[1] + + if set_id == 101: + self.SetSkill.append(Relic101(set_id, count)) + elif set_id == 102: + self.SetSkill.append(Relic102(set_id, count)) + elif set_id == 103: + self.SetSkill.append(Relic103(set_id, count)) + elif set_id == 104: + self.SetSkill.append(Relic104(set_id, count)) + elif set_id == 105: + self.SetSkill.append(Relic105(set_id, count)) + elif set_id == 106: + self.SetSkill.append(Relic106(set_id, count)) + elif set_id == 107: + self.SetSkill.append(Relic107(set_id, count)) + elif set_id == 108: + self.SetSkill.append(Relic108(set_id, count)) + elif set_id == 109: + self.SetSkill.append(Relic109(set_id, count)) + elif set_id == 110: + self.SetSkill.append(Relic110(set_id, count)) + elif set_id == 111: + self.SetSkill.append(Relic111(set_id, count)) + elif set_id == 112: + self.SetSkill.append(Relic112(set_id, count)) + elif set_id == 113: + self.SetSkill.append(Relic113(set_id, count)) + elif set_id == 114: + self.SetSkill.append(Relic114(set_id, count)) + elif set_id == 301: + self.SetSkill.append(Relic301(set_id, count)) + elif set_id == 302: + self.SetSkill.append(Relic302(set_id, count)) + elif set_id == 303: + self.SetSkill.append(Relic303(set_id, count)) + elif set_id == 304: + self.SetSkill.append(Relic304(set_id, count)) + elif set_id == 305: + self.SetSkill.append(Relic305(set_id, count)) + elif set_id == 306: + self.SetSkill.append(Relic306(set_id, count)) + elif set_id == 307: + self.SetSkill.append(Relic307(set_id, count)) + elif set_id == 308: + self.SetSkill.append(Relic308(set_id, count)) + elif set_id == 309: + self.SetSkill.append(Relic309(set_id, count)) + elif set_id == 310: + self.SetSkill.append(Relic310(set_id, count)) + else: + raise Exception(f'Unknow SetId: {set_id}') diff --git a/StarRailUID/starrailuid_charinfo/effect/Role.py b/StarRailUID/starrailuid_charinfo/effect/Role.py index 905ca60..7f128d8 100644 --- a/StarRailUID/starrailuid_charinfo/effect/Role.py +++ b/StarRailUID/starrailuid_charinfo/effect/Role.py @@ -295,7 +295,9 @@ class RoleInstance: # 检查是否有某一属性的抗性穿透 attr_name = attr.split('ResistancePenetration')[0] if attr_name in (self.avatar.avatar_element, 'AllDamage'): - logger.info(f'{attr_name}属性有{merged_attr[attr]}穿透加成') + logger.info( + f'{attr_name}属性有{merged_attr[attr]}穿透加成' + ) enemy_status_resistance += merged_attr[attr] # 检查是否有某一技能属性的抗性穿透 if attr_name.__contains__('_'): diff --git a/StarRailUID/starrailuid_charinfo/effect/Weapon/Weapon.py b/StarRailUID/starrailuid_charinfo/effect/Weapon/Weapon.py index 58f641b..0b4e9b8 100644 --- a/StarRailUID/starrailuid_charinfo/effect/Weapon/Weapon.py +++ b/StarRailUID/starrailuid_charinfo/effect/Weapon/Weapon.py @@ -1,1937 +1,1953 @@ -import json -from typing import Dict -from pathlib import Path - -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: - weapon_effect = json.load(f) - - -class Arrows(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者消灭敌方目标 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - critical_chance_base = attribute_bonus.get('CriticalChance', 0) - attribute_bonus['CriticalChance'] = ( - critical_chance_base - + weapon_effect['20000']['Param']['CriticalChance'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -class ReturntoDarkness(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者消灭敌方目标 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - pass - return attribute_bonus - - -class Swordplay(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者多次击中同一敌方目标时, 每次造成的伤害提高8%, 该效果最多叠加5层 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + ( - weapon_effect['21010']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 5 - ) - return attribute_bonus - - -class DartingArrow(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者消灭敌方目标 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio - + weapon_effect['20007']['Param']['AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -class Adversarial(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者消灭敌方目标 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - speed_added_ratio = attribute_bonus.get('SpeedAddedRatio', 0) - attribute_bonus['SpeedAddedRatio'] = ( - speed_added_ratio - + weapon_effect['20014']['Param']['SpeedAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - return attribute_bonus - - -class SubscribeforMore(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者的当前能量值等于其能量上限 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - normal_dmg_add = attribute_bonus.get('NormalDmgAdd', 0) - attribute_bonus['NormalDmgAdd'] = ( - normal_dmg_add - + ( - weapon_effect['21017']['Param']['a_dmg'][ - self.weapon_rank - 1 - ] - ) - * 2 - ) - bp_skill_dmg_add = attribute_bonus.get('BPSkillDmgAdd', 0) - attribute_bonus['BPSkillDmgAdd'] = ( - bp_skill_dmg_add - + ( - weapon_effect['21017']['Param']['e_dmg'][ - self.weapon_rank - 1 - ] - ) - * 2 - ) - return attribute_bonus - return attribute_bonus - - -class RiverFlowsinSpring(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 进入战斗后,使装备者速度提高8%,造成的伤害提高12%。 - # 当装备者受到伤害后该效果失效,下个回合结束时该效果恢复。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - speed_added_ratio = attribute_bonus.get('SpeedAddedRatio', 0) - attribute_bonus['SpeedAddedRatio'] = ( - speed_added_ratio - + weapon_effect['21024']['Param']['SpeedAddedRatio'][ - self.weapon_rank - 1 - ] - ) - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['21024']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - return attribute_bonus - - -class OnlySilenceRemains(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当场上的敌方目标数量小于等于2时 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base - + weapon_effect['21003']['Param']['CriticalChance'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - return attribute_bonus - - -# 拂晓之前 -class BeforeDawn(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - bp_skill_dmg_add = attribute_bonus.get('BPSkillDmgAdd', 0) - attribute_bonus['BPSkillDmgAdd'] = bp_skill_dmg_add + ( - weapon_effect['23010']['Param']['e_dmg'][self.weapon_rank - 1] - ) - ultra_dmg_add = attribute_bonus.get('UltraDmgAdd', 0) - attribute_bonus['UltraDmgAdd'] = ultra_dmg_add + ( - weapon_effect['23010']['Param']['r_dmg'][self.weapon_rank - 1] - ) - talent_dmg_add = attribute_bonus.get('TalentDmgAdd', 0) - attribute_bonus['TalentDmgAdd'] = talent_dmg_add + ( - weapon_effect['23010']['Param']['t_dmg'][self.weapon_rank - 1] - ) - return attribute_bonus - - -class IntheNight(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - char_speed = ( - base_attr.get('speed', 0) + attribute_bonus.get('SpeedDelta', 0) - ) * (attribute_bonus.get('SpeedAddedRatio', 0) + 1) - count_ = min(6, int((char_speed - 100) / 10)) - normal_dmg_add = attribute_bonus.get('NormalDmgAdd', 0) - attribute_bonus['NormalDmgAdd'] = ( - normal_dmg_add - + (weapon_effect['23001']['Param']['a_dmg'][self.weapon_rank - 1]) - * count_ - ) - bp_skill_dmg_add = attribute_bonus.get('BPSkillDmgAdd', 0) - attribute_bonus['BPSkillDmgAdd'] = ( - bp_skill_dmg_add - + (weapon_effect['23001']['Param']['e_dmg'][self.weapon_rank - 1]) - * count_ - ) - ultra_critical_chance_base = attribute_bonus.get( - 'Ultra_CriticalDamageBase', 0 - ) - attribute_bonus['Ultra_CriticalDamageBase'] = ( - ultra_critical_chance_base - + ( - weapon_effect['23001']['Param']['q_crit_dmg'][ - self.weapon_rank - 1 - ] - ) - * count_ - ) - return attribute_bonus - - -class CruisingintheStellarSea(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者对生命值百分比小于等于50%的敌方目标 - # 装备者消灭敌方目标 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base - + weapon_effect['24001']['Param']['CriticalChance'][ - self.weapon_rank - 1 - ] - ) - if await self.check(): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio - + weapon_effect['24001']['Param']['AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -class SeriousnessofBreakfast(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者造成伤害提高12% - # 每消灭1个敌方目标, 装备者的攻击力提高4%, 该效果最多叠加3层。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - all_damage_added_ratio = attribute_bonus.get('AllDamageAddedRatio', 0) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['21027']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - if await self.check(): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio - + ( - weapon_effect['21027']['Param']['AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 3 - ) - return attribute_bonus - - -# 银河铁道之夜 -class NightontheMilkyWay(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 场上每有1个敌方目标, 使装备者的攻击力提高9% - # 敌方目标的弱点被击破时, 装备者造成的伤害提高30% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio - + weapon_effect['23000']['Param']['AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['23000']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - return attribute_bonus - - -# 今日亦是和平的一日 -class TodayIsAnotherPeacefulDay(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 根据装备者的能量上限, 提高装备者造成的伤害: 每点能量提高0.2%, 最多计入160点 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - all_damage_added_ratio = attribute_bonus.get('AllDamageAddedRatio', 0) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + ( - weapon_effect['21034']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * Ultra_Use - ) - return attribute_bonus - - -# 天才们的休憩 -class GeniusesRepose(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者攻击力提高16% - # 当装备者消灭敌方目标后, 暴击伤害提高24% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - critical_chance_base = attribute_bonus.get('CriticalDamageBase', 0) - attribute_bonus['CriticalDamageBase'] = critical_chance_base + ( - weapon_effect['21020']['Param']['CriticalDamageBase'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 别让世界静下来 -class MaketheWorldClamor(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 终结技造成的伤害提高32%。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - ultra_dmg_add = attribute_bonus.get('UltraDmgAdd', 0) - attribute_bonus['UltraDmgAdd'] = ultra_dmg_add + ( - weapon_effect['21013']['Param']['r_dmg'][self.weapon_rank - 1] - ) - return attribute_bonus - - -# 「我」的诞生 -class TheBirthoftheSelf(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 追加攻击造成的伤害提高30% - # 若该敌方目标当前生命值百分比小于等于50%, 则追加攻击造成的伤害额外提高30%。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - talent_dmg_add = attribute_bonus.get('TalentDmgAdd', 0) - attribute_bonus['TalentDmgAdd'] = talent_dmg_add + ( - weapon_effect['21006']['Param']['t_dmg'][self.weapon_rank - 1] - ) - return attribute_bonus - return attribute_bonus - - -# 秘密誓心 -class ASecretVow(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 造成的伤害提高20% - # 对当前生命值百分比大于等于装备者自身当前生命值百分比的敌方目标 - # 造成的伤害额外提高20% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['21012']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - return attribute_bonus - - -# 比阳光更明亮的 -class BrighterThantheSun(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者的暴击率提高18% - # 当装备者施放普攻时, 获得1层【龙吟】, 持续2回合。 - # 每层【龙吟】使装备者的攻击力提高18%,【龙吟】最多叠加2层 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio - + ( - weapon_effect['23015']['Param']['AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 2 - ) - return attribute_bonus - - -# 到不了的彼岸 -class TheUnreachableSide(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者的暴击率提高30%, 生命上限提高30% - # 当装备者受到攻击或装备者消耗自身生命值后, 造成的伤害提高40% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['23009']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 无可取代的东西 -class SomethingIrreplaceable(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者的攻击力提高24% - # 当装备者消灭敌方目标或受到攻击后, 造成的伤害提高24% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['23002']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 记一位星神的陨落 -class OntheFallofanAeon(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者施放攻击时, 使装备者本场战斗中的攻击力提高8%, 该效果最多叠加4层 - # 当装备者击破敌方目标弱点后, 造成的伤害提高12% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio - + ( - weapon_effect['24000']['Param']['AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 4 - ) - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['24000']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 无处可逃 -class NowheretoRun(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者的攻击力提高24% - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - # attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - # attribute_bonus['AttackAddedRatio'] = attack_added_ratio + mp.mpf( - # weapon_effect['21033']['Param']['AttackAddedRatio'][ - # self.weapon_rank - 1 - # ] - # ) - return attribute_bonus - - -# 汪! 散步时间! -class WoofWalkTime(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者的攻击力提高10% - # 对处于灼烧或裂伤状态的敌方目标造成的伤害提高16% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - # attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - # attribute_bonus['AttackAddedRatio'] = attack_added_ratio + mp.mpf( - # weapon_effect['21026']['Param']['AttackAddedRatio'][ - # self.weapon_rank - 1 - # ] - # ) - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['21026']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 在蓝天下 -class UndertheBlueSky(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者攻击力提高16% - # 当装备者消灭敌方目标后, 暴击率提高12% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - # attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - # attribute_bonus['AttackAddedRatio'] = attack_added_ratio + mp.mpf( - # weapon_effect['21019']['Param']['AttackAddedRatio'][ - # self.weapon_rank - 1 - # ] - # ) - if await self.check(): - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base - + weapon_effect['21019']['Param']['CriticalChance'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 鼹鼠党欢迎你 -class TheMolesWelcomeYou(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者施放普攻、战技或终结技攻击敌方目标后, - # 分别获取一层【淘气值】。每层使装备者的攻击力提高12%。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) - attribute_bonus['AttackAddedRatio'] = ( - attack_added_ratio - + ( - weapon_effect['21005']['Param']['AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 3 - ) - return attribute_bonus - - -# 雨一直下 -class IncessantRain(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者对同时处于大于等于3个负面效果的敌方目标造成伤害时, 暴击率提高12% - # 持有【以太编码】的目标受到的伤害提高12% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - damage_ratio = attribute_bonus.get('DmgRatio', 0) - attribute_bonus['DmgRatio'] = ( - damage_ratio - + weapon_effect['23007']['Param']['DmgRatio'][ - self.weapon_rank - 1 - ] - ) - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base - + weapon_effect['23007']['Param']['CriticalChance'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 只需等待 -class PatienceIsAllYouNeed(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者造成的伤害提高24% - # 装备者每次施放攻击后, 速度提高4.8%, 最多叠加3层。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['23006']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - - speed_added_ratio = attribute_bonus.get('SpeedAddedRatio', 0) - attribute_bonus['SpeedAddedRatio'] = ( - speed_added_ratio - + ( - weapon_effect['23006']['Param']['SpeedAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 3 - ) - return attribute_bonus - - -# 以世界之名 -class IntheNameoftheWorld(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者对陷入负面效果的敌方目标造成的伤害提高24% - # 当装备者施放战技时, 装备者此次攻击的效果命中提高18% - # 当装备者施放战技时, 装备者此次攻击的攻击力提高24%。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['23004']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - - a2_status_probability = attribute_bonus.get( - 'BPSkillStatusProbabilityBase', 0 - ) - attribute_bonus['BPSkillStatusProbabilityBase'] = ( - a2_status_probability - + weapon_effect['23004']['Param']['A2_StatusProbability'][ - self.weapon_rank - 1 - ] - ) - - a2_attack_added_ratio = attribute_bonus.get( - 'BPSkillAttackAddedRatio', 0 - ) - attribute_bonus['BPSkillAttackAddedRatio'] = ( - a2_attack_added_ratio - + weapon_effect['23004']['Param']['A2_AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 孤独的疗愈 -class SolitaryHealing(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者的击破特攻提高20% - # 装备者施放终结技时, 使装备者造成的持续伤害提高24% - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 新手任务开始前 -class BeforetheTutorialMissionStarts(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者攻击防御力被降低的敌方目标后, 恢复4点能量。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 后会有期 -class WeWillMeetAgain(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者施放普攻或战技后, - # 对随机1个受到攻击的敌方目标造成等同于自身48%攻击力的附加伤害。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 延长记号 -class Fermata(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 对处于触电或风化状态的敌方目标造成的伤害提高16% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['21022']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 决心如汗珠般闪耀 -class ResolutionShinesAsPearlsofSweat(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 对处于触电或风化状态的敌方目标造成的伤害提高16% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - ignore_defence = attribute_bonus.get('ignore_defence', 0) - attribute_bonus['ignore_defence'] = ( - ignore_defence - + weapon_effect['21015']['Param']['ignore_defence'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 猎物的视线 -class EyesofthePrey(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 造成的持续伤害提高24%。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 晚安与睡颜 -class GoodNightandSleepWell(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 敌方目标每承受1个负面效果, 装备者对其造成的伤害提高12%, 最多叠加3层 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + ( - weapon_effect['21001']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 3 - ) - return attribute_bonus - - -# 她已闭上双眼 -class SheAlreadyShutHerEyes(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者的生命值降低时, 使我方全体造成的伤害提高15% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + ( - weapon_effect['23011']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 3 - ) - return attribute_bonus - - -# 制胜的瞬间 -class MomentofVictory(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者受到攻击后, 防御力额外提高24% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - defence_added_ratio = attribute_bonus.get('DefenceAddedRatio', 0) - attribute_bonus['DefenceAddedRatio'] = ( - defence_added_ratio - + weapon_effect['23005']['Param']['DefenceAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 记忆的质料 -class TextureofMemories(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # ... - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 这就是我啦 -class ThisIsMe(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者施放终结技时造成的伤害值提高, 提高数值等同于装备者防御力的60% - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 我们是地火 -class WeAreWildfire(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 战斗开始时, 使我方全体受到的伤害降低8% - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 宇宙市场趋势 -class TrendoftheUniversalMarket(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者受到攻击后, 有100%的基础概率使敌方目标陷入灼烧状态, - # 每回合造成等同于装备者40%防御力的持续伤害 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 朗道的选择 -class LandausChoice(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者受到攻击的概率提高, 同时受到的伤害降低16%。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 余生的第一天 -class DayOneofMyNewLife(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 进入战斗后, 使我方全体的全属性抗性提高8% - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 开疆 -class Pioneering(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 进入战斗后, 使我方全体的全属性抗性提高8% - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 戍御 -class Defense(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 进入战斗后, 使我方全体的全属性抗性提高8% - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 琥珀 -class Amber(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者当前生命值百分比小于50%时, 其防御力额外提高16%。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - defence_added_ratio = attribute_bonus.get('DefenceAddedRatio', 0) - attribute_bonus['DefenceAddedRatio'] = ( - defence_added_ratio - + weapon_effect['20003']['Param']['DefenceAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 俱殁 -class MutualDemise(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者当前生命值百分比小于80%时, 暴击率提高12% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base - + weapon_effect['20016']['Param']['CriticalChance'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 乐圮 -class ShatteredHome(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者对当前生命值百分比大于50%的敌方目标造成的伤害提高20%。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['20009']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 天倾 -class CollapsingSky(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者普攻和战技造成的伤害提高20%。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - normal_dmg_add = attribute_bonus.get('NormalDmgAdd', 0) - attribute_bonus['NormalDmgAdd'] = normal_dmg_add + ( - weapon_effect['20002']['Param']['a_dmg'][self.weapon_rank - 1] - ) - bp_skill_dmg_add = attribute_bonus.get('BPSkillDmgAdd', 0) - attribute_bonus['BPSkillDmgAdd'] = bp_skill_dmg_add + ( - weapon_effect['20002']['Param']['e_dmg'][self.weapon_rank - 1] - ) - return attribute_bonus - - -# 匿影 -class HiddenShadow(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 施放战技后, 使装备者的下一次普攻对敌方目标造成等同于自身60%攻击力的附加伤害。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 渊环 -class Loop(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者对减速状态下的敌方目标造成的伤害提高24%。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - all_damage_added_ratio = attribute_bonus.get( - 'AllDamageAddedRatio', 0 - ) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + weapon_effect['20009']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 幽邃 -class Void(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 战斗开始时, 使装备者的效果命中提高20%, 持续3回合。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - status_probability = attribute_bonus.get( - 'StatusProbabilityBase', 0 - ) - attribute_bonus['StatusProbabilityBase'] = ( - status_probability - + weapon_effect['20004']['Param']['StatusProbability'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 睿见 -class Sagacity(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者施放终结技时, 攻击力提高24%, 持续2回合。 - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - a3_attack_added_ratio = attribute_bonus.get( - 'UltraAttackAddedRatio', 0 - ) - attribute_bonus['UltraAttackAddedRatio'] = ( - a3_attack_added_ratio - + weapon_effect['20020']['Param']['A3_AttackAddedRatio'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 灵钥 -class Passkey(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者施放战技后额外恢复8点能量 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - return attribute_bonus - - -# 智库 -class DataBank(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 使装备者终结技造成的伤害提高28%。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - ultra_dmg_add = attribute_bonus.get('UltraDmgAdd', 0) - attribute_bonus['UltraDmgAdd'] = ultra_dmg_add + ( - weapon_effect['20006']['Param']['r_dmg'][self.weapon_rank - 1] - ) - return attribute_bonus - - -# 此身为剑 -class Thisbodyisasword(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当队友受到攻击或消耗生命值后, 装备者获得1层【月蚀】, - # 最多叠加3层。每层【月蚀】使装备者下一次攻击造成的伤害提高14%。 - # 叠满3层时, 额外使该次攻击无视目标12%的防御力。该效果在装备者施放攻击后解除。 - pass - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - all_damage_added_ratio = attribute_bonus.get('AllDamageAddedRatio', 0) - attribute_bonus['AllDamageAddedRatio'] = ( - all_damage_added_ratio - + ( - weapon_effect['23014']['Param']['AllDamageAddedRatio'][ - self.weapon_rank - 1 - ] - ) - * 3 - ) - - resistance_penetration = attribute_bonus.get( - 'AllResistancePenetration', 0 - ) - attribute_bonus[ - 'AllResistancePenetration' - ] = resistance_penetration + ( - weapon_effect['23014']['Param']['ResistancePenetration'][ - self.weapon_rank - 1 - ] - ) - - return attribute_bonus - - -# 如泥酣眠 -class SleepLiketheDead(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 当装备者的普攻或战技伤害未造成暴击时,使自身暴击率提高36% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - if await self.check(): - critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) - attribute_bonus['CriticalChanceBase'] = ( - critical_chance_base - + weapon_effect['23012']['Param']['CriticalChance'][ - self.weapon_rank - 1 - ] - ) - return attribute_bonus - - -# 烦恼着,幸福着 -class WorrisomeBlissf(BaseWeapon): - weapon_base_attributes: Dict - - def __init__(self, weapon: DamageInstanceWeapon): - super().__init__(weapon) - - async def check(self): - # 装备者施放追加攻击后,使目标陷入【温驯】状态,该效果最多叠加2层.我方目标击中【温驯】状态下的敌方目标时,每层【温驯】使造成的暴击伤害提高12% - return True - - async def weapon_ability( - self, - Ultra_Use: float, - base_attr: Dict[str, float], - attribute_bonus: Dict[str, float], - ): - critical_chance_base = attribute_bonus.get('TalentDmgAdd', 0) - attribute_bonus['TalentDmgAdd'] = ( - critical_chance_base - + weapon_effect['23016']['Param']['TalentDmgAdd'][ - self.weapon_rank - 1 - ] - ) - if await self.check(): - critical_chance_base = attribute_bonus.get('CriticalDamageBase', 0) - attribute_bonus['CriticalDamageBase'] = ( - critical_chance_base - + ( - weapon_effect['23016']['Param']['CriticalDamageBase'][ - self.weapon_rank - 1 - ] - ) - * 2 - ) - return attribute_bonus - - -class Weapon: - @classmethod - def create(cls, weapon: DamageInstanceWeapon): - if weapon.id_ in [ - 23011, - 23007, - 21005, - 21019, - 21026, - 21033, - 24000, - 23002, - 23009, - 23015, - 21012, - 21006, - 21013, - 21027, - 21020, - 21034, - 23000, - 23010, - 23001, - 21003, - 23012, - 24001, - 21024, - 21017, - 20014, - 20007, - 21010, - 21031, - 20000, - 23006, - 23004, - 24003, - 22000, - 21029, - 21022, - 21015, - 21008, - 21001, - 23005, - 24002, - 21030, - 21023, - 21016, - 21009, - 21002, - 20017, - 20010, - 20003, - 20016, - 20009, - 20002, - 20018, - 20011, - 20004, - 20020, - 20013, - 20006, - 23014, - 23016, - ]: - if weapon.id_ == 23016: - return WorrisomeBlissf(weapon) - if weapon.id_ == 23012: - return SleepLiketheDead(weapon) - if weapon.id_ == 23014: - return Thisbodyisasword(weapon) - if weapon.id_ == 20006: - return DataBank(weapon) - if weapon.id_ == 20013: - return Passkey(weapon) - if weapon.id_ == 20020: - return Sagacity(weapon) - if weapon.id_ == 20004: - return Void(weapon) - if weapon.id_ == 20011: - return Loop(weapon) - if weapon.id_ == 20018: - return HiddenShadow(weapon) - if weapon.id_ == 20002: - return CollapsingSky(weapon) - if weapon.id_ == 20009: - return ShatteredHome(weapon) - if weapon.id_ == 20016: - return MutualDemise(weapon) - if weapon.id_ == 20003: - return Amber(weapon) - if weapon.id_ == 20010: - return Defense(weapon) - if weapon.id_ == 20017: - return Pioneering(weapon) - if weapon.id_ == 21002: - return DayOneofMyNewLife(weapon) - if weapon.id_ == 21009: - return LandausChoice(weapon) - if weapon.id_ == 21016: - return TrendoftheUniversalMarket(weapon) - if weapon.id_ == 21023: - return WeAreWildfire(weapon) - if weapon.id_ == 21030: - return ThisIsMe(weapon) - if weapon.id_ == 24002: - return TextureofMemories(weapon) - if weapon.id_ == 23005: - return MomentofVictory(weapon) - if weapon.id_ == 23011: - return SheAlreadyShutHerEyes(weapon) - if weapon.id_ == 21001: - return GoodNightandSleepWell(weapon) - if weapon.id_ == 21008: - return EyesofthePrey(weapon) - if weapon.id_ == 21015: - return ResolutionShinesAsPearlsofSweat(weapon) - if weapon.id_ == 21022: - return Fermata(weapon) - if weapon.id_ == 21029: - return WeWillMeetAgain(weapon) - if weapon.id_ == 22000: - return BeforetheTutorialMissionStarts(weapon) - if weapon.id_ == 24003: - return SolitaryHealing(weapon) - if weapon.id_ == 23004: - return IntheNameoftheWorld(weapon) - if weapon.id_ == 23006: - return PatienceIsAllYouNeed(weapon) - if weapon.id_ == 23007: - return IncessantRain(weapon) - if weapon.id_ == 21005: - return TheMolesWelcomeYou(weapon) - if weapon.id_ == 21019: - return UndertheBlueSky(weapon) - if weapon.id_ == 21026: - return WoofWalkTime(weapon) - if weapon.id_ == 21033: - return NowheretoRun(weapon) - if weapon.id_ == 24000: - return OntheFallofanAeon(weapon) - if weapon.id_ == 23002: - return SomethingIrreplaceable(weapon) - if weapon.id_ == 23009: - return TheUnreachableSide(weapon) - if weapon.id_ == 23015: - return BrighterThantheSun(weapon) - if weapon.id_ == 21012: - return ASecretVow(weapon) - if weapon.id_ == 21006: - return TheBirthoftheSelf(weapon) - if weapon.id_ == 21013: - return MaketheWorldClamor(weapon) - if weapon.id_ == 21020: - return GeniusesRepose(weapon) - if weapon.id_ == 21027: - return SeriousnessofBreakfast(weapon) - if weapon.id_ == 21034: - return TodayIsAnotherPeacefulDay(weapon) - if weapon.id_ == 23000: - return NightontheMilkyWay(weapon) - if weapon.id_ == 23010: - return BeforeDawn(weapon) - if weapon.id_ == 24001: - return CruisingintheStellarSea(weapon) - if weapon.id_ == 23001: - return IntheNight(weapon) - if weapon.id_ == 21003: - return OnlySilenceRemains(weapon) - if weapon.id_ == 21024: - return RiverFlowsinSpring(weapon) - if weapon.id_ == 20014: - return Adversarial(weapon) - if weapon.id_ == 20007: - return DartingArrow(weapon) - if weapon.id_ == 21010: - return Swordplay(weapon) - if weapon.id_ == 21031: - return ReturntoDarkness(weapon) - if weapon.id_ == 20000: - return Arrows(weapon) - raise ValueError(f'未知武器id: {weapon.id_}') - raise ValueError(f'不支持的武器种类: {weapon.id_}') +import json +from typing import Dict +from pathlib import Path + +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: + weapon_effect = json.load(f) + + +class Arrows(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者消灭敌方目标 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + critical_chance_base = attribute_bonus.get('CriticalChance', 0) + attribute_bonus['CriticalChance'] = ( + critical_chance_base + + weapon_effect['20000']['Param']['CriticalChance'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +class ReturntoDarkness(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者消灭敌方目标 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + pass + return attribute_bonus + + +class Swordplay(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者多次击中同一敌方目标时, 每次造成的伤害提高8%, 该效果最多叠加5层 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + ( + weapon_effect['21010']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 5 + ) + return attribute_bonus + + +class DartingArrow(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者消灭敌方目标 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + + weapon_effect['20007']['Param']['AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +class Adversarial(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者消灭敌方目标 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + speed_added_ratio = attribute_bonus.get('SpeedAddedRatio', 0) + attribute_bonus['SpeedAddedRatio'] = ( + speed_added_ratio + + weapon_effect['20014']['Param']['SpeedAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + return attribute_bonus + + +class SubscribeforMore(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者的当前能量值等于其能量上限 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + normal_dmg_add = attribute_bonus.get('NormalDmgAdd', 0) + attribute_bonus['NormalDmgAdd'] = ( + normal_dmg_add + + ( + weapon_effect['21017']['Param']['a_dmg'][ + self.weapon_rank - 1 + ] + ) + * 2 + ) + bp_skill_dmg_add = attribute_bonus.get('BPSkillDmgAdd', 0) + attribute_bonus['BPSkillDmgAdd'] = ( + bp_skill_dmg_add + + ( + weapon_effect['21017']['Param']['e_dmg'][ + self.weapon_rank - 1 + ] + ) + * 2 + ) + return attribute_bonus + return attribute_bonus + + +class RiverFlowsinSpring(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 进入战斗后,使装备者速度提高8%,造成的伤害提高12%。 + # 当装备者受到伤害后该效果失效,下个回合结束时该效果恢复。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + speed_added_ratio = attribute_bonus.get('SpeedAddedRatio', 0) + attribute_bonus['SpeedAddedRatio'] = ( + speed_added_ratio + + weapon_effect['21024']['Param']['SpeedAddedRatio'][ + self.weapon_rank - 1 + ] + ) + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['21024']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + return attribute_bonus + + +class OnlySilenceRemains(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当场上的敌方目标数量小于等于2时 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + + weapon_effect['21003']['Param']['CriticalChance'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + return attribute_bonus + + +# 拂晓之前 +class BeforeDawn(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + bp_skill_dmg_add = attribute_bonus.get('BPSkillDmgAdd', 0) + attribute_bonus['BPSkillDmgAdd'] = ( + bp_skill_dmg_add + + (weapon_effect['23010']['Param']['e_dmg'][self.weapon_rank - 1]) + ) + ultra_dmg_add = attribute_bonus.get('UltraDmgAdd', 0) + attribute_bonus['UltraDmgAdd'] = ( + ultra_dmg_add + + (weapon_effect['23010']['Param']['r_dmg'][self.weapon_rank - 1]) + ) + talent_dmg_add = attribute_bonus.get('TalentDmgAdd', 0) + attribute_bonus['TalentDmgAdd'] = ( + talent_dmg_add + + (weapon_effect['23010']['Param']['t_dmg'][self.weapon_rank - 1]) + ) + return attribute_bonus + + +class IntheNight(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + char_speed = ( + base_attr.get('speed', 0) + attribute_bonus.get('SpeedDelta', 0) + ) * (attribute_bonus.get('SpeedAddedRatio', 0) + 1) + count_ = min(6, int((char_speed - 100) / 10)) + normal_dmg_add = attribute_bonus.get('NormalDmgAdd', 0) + attribute_bonus['NormalDmgAdd'] = ( + normal_dmg_add + + (weapon_effect['23001']['Param']['a_dmg'][self.weapon_rank - 1]) + * count_ + ) + bp_skill_dmg_add = attribute_bonus.get('BPSkillDmgAdd', 0) + attribute_bonus['BPSkillDmgAdd'] = ( + bp_skill_dmg_add + + (weapon_effect['23001']['Param']['e_dmg'][self.weapon_rank - 1]) + * count_ + ) + ultra_critical_chance_base = attribute_bonus.get( + 'Ultra_CriticalDamageBase', 0 + ) + attribute_bonus['Ultra_CriticalDamageBase'] = ( + ultra_critical_chance_base + + ( + weapon_effect['23001']['Param']['q_crit_dmg'][ + self.weapon_rank - 1 + ] + ) + * count_ + ) + return attribute_bonus + + +class CruisingintheStellarSea(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者对生命值百分比小于等于50%的敌方目标 + # 装备者消灭敌方目标 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + + weapon_effect['24001']['Param']['CriticalChance'][ + self.weapon_rank - 1 + ] + ) + if await self.check(): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + + weapon_effect['24001']['Param']['AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +class SeriousnessofBreakfast(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者造成伤害提高12% + # 每消灭1个敌方目标, 装备者的攻击力提高4%, 该效果最多叠加3层。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + all_damage_added_ratio = attribute_bonus.get('AllDamageAddedRatio', 0) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['21027']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + if await self.check(): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + + ( + weapon_effect['21027']['Param']['AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 3 + ) + return attribute_bonus + + +# 银河铁道之夜 +class NightontheMilkyWay(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 场上每有1个敌方目标, 使装备者的攻击力提高9% + # 敌方目标的弱点被击破时, 装备者造成的伤害提高30% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + + weapon_effect['23000']['Param']['AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['23000']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + return attribute_bonus + + +# 今日亦是和平的一日 +class TodayIsAnotherPeacefulDay(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 根据装备者的能量上限, 提高装备者造成的伤害: 每点能量提高0.2%, 最多计入160点 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + all_damage_added_ratio = attribute_bonus.get('AllDamageAddedRatio', 0) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + ( + weapon_effect['21034']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * Ultra_Use + ) + return attribute_bonus + + +# 天才们的休憩 +class GeniusesRepose(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者攻击力提高16% + # 当装备者消灭敌方目标后, 暴击伤害提高24% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + critical_chance_base = attribute_bonus.get('CriticalDamageBase', 0) + attribute_bonus['CriticalDamageBase'] = ( + critical_chance_base + + ( + weapon_effect['21020']['Param']['CriticalDamageBase'][ + self.weapon_rank - 1 + ] + ) + ) + return attribute_bonus + + +# 别让世界静下来 +class MaketheWorldClamor(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 终结技造成的伤害提高32%。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + ultra_dmg_add = attribute_bonus.get('UltraDmgAdd', 0) + attribute_bonus['UltraDmgAdd'] = ( + ultra_dmg_add + + (weapon_effect['21013']['Param']['r_dmg'][self.weapon_rank - 1]) + ) + return attribute_bonus + + +# 「我」的诞生 +class TheBirthoftheSelf(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 追加攻击造成的伤害提高30% + # 若该敌方目标当前生命值百分比小于等于50%, 则追加攻击造成的伤害额外提高30%。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + talent_dmg_add = attribute_bonus.get('TalentDmgAdd', 0) + attribute_bonus['TalentDmgAdd'] = ( + talent_dmg_add + + ( + weapon_effect['21006']['Param']['t_dmg'][ + self.weapon_rank - 1 + ] + ) + ) + return attribute_bonus + return attribute_bonus + + +# 秘密誓心 +class ASecretVow(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 造成的伤害提高20% + # 对当前生命值百分比大于等于装备者自身当前生命值百分比的敌方目标 + # 造成的伤害额外提高20% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['21012']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + return attribute_bonus + + +# 比阳光更明亮的 +class BrighterThantheSun(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者的暴击率提高18% + # 当装备者施放普攻时, 获得1层【龙吟】, 持续2回合。 + # 每层【龙吟】使装备者的攻击力提高18%,【龙吟】最多叠加2层 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + + ( + weapon_effect['23015']['Param']['AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 2 + ) + return attribute_bonus + + +# 到不了的彼岸 +class TheUnreachableSide(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者的暴击率提高30%, 生命上限提高30% + # 当装备者受到攻击或装备者消耗自身生命值后, 造成的伤害提高40% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['23009']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 无可取代的东西 +class SomethingIrreplaceable(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者的攻击力提高24% + # 当装备者消灭敌方目标或受到攻击后, 造成的伤害提高24% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['23002']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 记一位星神的陨落 +class OntheFallofanAeon(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者施放攻击时, 使装备者本场战斗中的攻击力提高8%, 该效果最多叠加4层 + # 当装备者击破敌方目标弱点后, 造成的伤害提高12% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + + ( + weapon_effect['24000']['Param']['AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 4 + ) + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['24000']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 无处可逃 +class NowheretoRun(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者的攻击力提高24% + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + # attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + # attribute_bonus['AttackAddedRatio'] = attack_added_ratio + mp.mpf( + # weapon_effect['21033']['Param']['AttackAddedRatio'][ + # self.weapon_rank - 1 + # ] + # ) + return attribute_bonus + + +# 汪! 散步时间! +class WoofWalkTime(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者的攻击力提高10% + # 对处于灼烧或裂伤状态的敌方目标造成的伤害提高16% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + # attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + # attribute_bonus['AttackAddedRatio'] = attack_added_ratio + mp.mpf( + # weapon_effect['21026']['Param']['AttackAddedRatio'][ + # self.weapon_rank - 1 + # ] + # ) + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['21026']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 在蓝天下 +class UndertheBlueSky(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者攻击力提高16% + # 当装备者消灭敌方目标后, 暴击率提高12% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + # attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + # attribute_bonus['AttackAddedRatio'] = attack_added_ratio + mp.mpf( + # weapon_effect['21019']['Param']['AttackAddedRatio'][ + # self.weapon_rank - 1 + # ] + # ) + if await self.check(): + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + + weapon_effect['21019']['Param']['CriticalChance'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 鼹鼠党欢迎你 +class TheMolesWelcomeYou(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者施放普攻、战技或终结技攻击敌方目标后, + # 分别获取一层【淘气值】。每层使装备者的攻击力提高12%。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + attack_added_ratio = attribute_bonus.get('AttackAddedRatio', 0) + attribute_bonus['AttackAddedRatio'] = ( + attack_added_ratio + + ( + weapon_effect['21005']['Param']['AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 3 + ) + return attribute_bonus + + +# 雨一直下 +class IncessantRain(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者对同时处于大于等于3个负面效果的敌方目标造成伤害时, 暴击率提高12% + # 持有【以太编码】的目标受到的伤害提高12% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + damage_ratio = attribute_bonus.get('DmgRatio', 0) + attribute_bonus['DmgRatio'] = ( + damage_ratio + + weapon_effect['23007']['Param']['DmgRatio'][ + self.weapon_rank - 1 + ] + ) + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + + weapon_effect['23007']['Param']['CriticalChance'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 只需等待 +class PatienceIsAllYouNeed(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者造成的伤害提高24% + # 装备者每次施放攻击后, 速度提高4.8%, 最多叠加3层。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['23006']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + + speed_added_ratio = attribute_bonus.get('SpeedAddedRatio', 0) + attribute_bonus['SpeedAddedRatio'] = ( + speed_added_ratio + + ( + weapon_effect['23006']['Param']['SpeedAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 3 + ) + return attribute_bonus + + +# 以世界之名 +class IntheNameoftheWorld(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者对陷入负面效果的敌方目标造成的伤害提高24% + # 当装备者施放战技时, 装备者此次攻击的效果命中提高18% + # 当装备者施放战技时, 装备者此次攻击的攻击力提高24%。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['23004']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + + a2_status_probability = attribute_bonus.get( + 'BPSkillStatusProbabilityBase', 0 + ) + attribute_bonus['BPSkillStatusProbabilityBase'] = ( + a2_status_probability + + weapon_effect['23004']['Param']['A2_StatusProbability'][ + self.weapon_rank - 1 + ] + ) + + a2_attack_added_ratio = attribute_bonus.get( + 'BPSkillAttackAddedRatio', 0 + ) + attribute_bonus['BPSkillAttackAddedRatio'] = ( + a2_attack_added_ratio + + weapon_effect['23004']['Param']['A2_AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 孤独的疗愈 +class SolitaryHealing(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者的击破特攻提高20% + # 装备者施放终结技时, 使装备者造成的持续伤害提高24% + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 新手任务开始前 +class BeforetheTutorialMissionStarts(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者攻击防御力被降低的敌方目标后, 恢复4点能量。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 后会有期 +class WeWillMeetAgain(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者施放普攻或战技后, + # 对随机1个受到攻击的敌方目标造成等同于自身48%攻击力的附加伤害。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 延长记号 +class Fermata(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 对处于触电或风化状态的敌方目标造成的伤害提高16% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['21022']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 决心如汗珠般闪耀 +class ResolutionShinesAsPearlsofSweat(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 对处于触电或风化状态的敌方目标造成的伤害提高16% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + ignore_defence = attribute_bonus.get('ignore_defence', 0) + attribute_bonus['ignore_defence'] = ( + ignore_defence + + weapon_effect['21015']['Param']['ignore_defence'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 猎物的视线 +class EyesofthePrey(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 造成的持续伤害提高24%。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 晚安与睡颜 +class GoodNightandSleepWell(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 敌方目标每承受1个负面效果, 装备者对其造成的伤害提高12%, 最多叠加3层 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + ( + weapon_effect['21001']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 3 + ) + return attribute_bonus + + +# 她已闭上双眼 +class SheAlreadyShutHerEyes(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者的生命值降低时, 使我方全体造成的伤害提高15% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + ( + weapon_effect['23011']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 3 + ) + return attribute_bonus + + +# 制胜的瞬间 +class MomentofVictory(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者受到攻击后, 防御力额外提高24% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + defence_added_ratio = attribute_bonus.get('DefenceAddedRatio', 0) + attribute_bonus['DefenceAddedRatio'] = ( + defence_added_ratio + + weapon_effect['23005']['Param']['DefenceAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 记忆的质料 +class TextureofMemories(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # ... + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 这就是我啦 +class ThisIsMe(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者施放终结技时造成的伤害值提高, 提高数值等同于装备者防御力的60% + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 我们是地火 +class WeAreWildfire(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 战斗开始时, 使我方全体受到的伤害降低8% + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 宇宙市场趋势 +class TrendoftheUniversalMarket(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者受到攻击后, 有100%的基础概率使敌方目标陷入灼烧状态, + # 每回合造成等同于装备者40%防御力的持续伤害 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 朗道的选择 +class LandausChoice(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者受到攻击的概率提高, 同时受到的伤害降低16%。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 余生的第一天 +class DayOneofMyNewLife(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 进入战斗后, 使我方全体的全属性抗性提高8% + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 开疆 +class Pioneering(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 进入战斗后, 使我方全体的全属性抗性提高8% + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 戍御 +class Defense(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 进入战斗后, 使我方全体的全属性抗性提高8% + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 琥珀 +class Amber(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者当前生命值百分比小于50%时, 其防御力额外提高16%。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + defence_added_ratio = attribute_bonus.get('DefenceAddedRatio', 0) + attribute_bonus['DefenceAddedRatio'] = ( + defence_added_ratio + + weapon_effect['20003']['Param']['DefenceAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 俱殁 +class MutualDemise(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者当前生命值百分比小于80%时, 暴击率提高12% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + + weapon_effect['20016']['Param']['CriticalChance'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 乐圮 +class ShatteredHome(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者对当前生命值百分比大于50%的敌方目标造成的伤害提高20%。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['20009']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 天倾 +class CollapsingSky(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者普攻和战技造成的伤害提高20%。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + normal_dmg_add = attribute_bonus.get('NormalDmgAdd', 0) + attribute_bonus['NormalDmgAdd'] = ( + normal_dmg_add + + (weapon_effect['20002']['Param']['a_dmg'][self.weapon_rank - 1]) + ) + bp_skill_dmg_add = attribute_bonus.get('BPSkillDmgAdd', 0) + attribute_bonus['BPSkillDmgAdd'] = ( + bp_skill_dmg_add + + (weapon_effect['20002']['Param']['e_dmg'][self.weapon_rank - 1]) + ) + return attribute_bonus + + +# 匿影 +class HiddenShadow(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 施放战技后, 使装备者的下一次普攻对敌方目标造成等同于自身60%攻击力的附加伤害。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 渊环 +class Loop(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者对减速状态下的敌方目标造成的伤害提高24%。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + all_damage_added_ratio = attribute_bonus.get( + 'AllDamageAddedRatio', 0 + ) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + weapon_effect['20009']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 幽邃 +class Void(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 战斗开始时, 使装备者的效果命中提高20%, 持续3回合。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + status_probability = attribute_bonus.get( + 'StatusProbabilityBase', 0 + ) + attribute_bonus['StatusProbabilityBase'] = ( + status_probability + + weapon_effect['20004']['Param']['StatusProbability'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 睿见 +class Sagacity(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者施放终结技时, 攻击力提高24%, 持续2回合。 + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + a3_attack_added_ratio = attribute_bonus.get( + 'UltraAttackAddedRatio', 0 + ) + attribute_bonus['UltraAttackAddedRatio'] = ( + a3_attack_added_ratio + + weapon_effect['20020']['Param']['A3_AttackAddedRatio'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 灵钥 +class Passkey(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者施放战技后额外恢复8点能量 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + return attribute_bonus + + +# 智库 +class DataBank(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 使装备者终结技造成的伤害提高28%。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + ultra_dmg_add = attribute_bonus.get('UltraDmgAdd', 0) + attribute_bonus['UltraDmgAdd'] = ( + ultra_dmg_add + + (weapon_effect['20006']['Param']['r_dmg'][self.weapon_rank - 1]) + ) + return attribute_bonus + + +# 此身为剑 +class Thisbodyisasword(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当队友受到攻击或消耗生命值后, 装备者获得1层【月蚀】, + # 最多叠加3层。每层【月蚀】使装备者下一次攻击造成的伤害提高14%。 + # 叠满3层时, 额外使该次攻击无视目标12%的防御力。该效果在装备者施放攻击后解除。 + pass + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + all_damage_added_ratio = attribute_bonus.get('AllDamageAddedRatio', 0) + attribute_bonus['AllDamageAddedRatio'] = ( + all_damage_added_ratio + + ( + weapon_effect['23014']['Param']['AllDamageAddedRatio'][ + self.weapon_rank - 1 + ] + ) + * 3 + ) + + resistance_penetration = attribute_bonus.get( + 'AllResistancePenetration', 0 + ) + attribute_bonus['AllResistancePenetration'] = ( + resistance_penetration + + ( + weapon_effect['23014']['Param']['ResistancePenetration'][ + self.weapon_rank - 1 + ] + ) + ) + + return attribute_bonus + + +# 如泥酣眠 +class SleepLiketheDead(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 当装备者的普攻或战技伤害未造成暴击时,使自身暴击率提高36% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + if await self.check(): + critical_chance_base = attribute_bonus.get('CriticalChanceBase', 0) + attribute_bonus['CriticalChanceBase'] = ( + critical_chance_base + + weapon_effect['23012']['Param']['CriticalChance'][ + self.weapon_rank - 1 + ] + ) + return attribute_bonus + + +# 烦恼着,幸福着 +class WorrisomeBlissf(BaseWeapon): + weapon_base_attributes: Dict + + def __init__(self, weapon: DamageInstanceWeapon): + super().__init__(weapon) + + async def check(self): + # 装备者施放追加攻击后,使目标陷入【温驯】状态,该效果最多叠加2层.我方目标击中【温驯】状态下的敌方目标时,每层【温驯】使造成的暴击伤害提高12% + return True + + async def weapon_ability( + self, + Ultra_Use: float, + base_attr: Dict[str, float], + attribute_bonus: Dict[str, float], + ): + critical_chance_base = attribute_bonus.get('TalentDmgAdd', 0) + attribute_bonus['TalentDmgAdd'] = ( + critical_chance_base + + weapon_effect['23016']['Param']['TalentDmgAdd'][ + self.weapon_rank - 1 + ] + ) + if await self.check(): + critical_chance_base = attribute_bonus.get('CriticalDamageBase', 0) + attribute_bonus['CriticalDamageBase'] = ( + critical_chance_base + + ( + weapon_effect['23016']['Param']['CriticalDamageBase'][ + self.weapon_rank - 1 + ] + ) + * 2 + ) + return attribute_bonus + + +class Weapon: + @classmethod + def create(cls, weapon: DamageInstanceWeapon): + if weapon.id_ in [ + 23011, + 23007, + 21005, + 21019, + 21026, + 21033, + 24000, + 23002, + 23009, + 23015, + 21012, + 21006, + 21013, + 21027, + 21020, + 21034, + 23000, + 23010, + 23001, + 21003, + 23012, + 24001, + 21024, + 21017, + 20014, + 20007, + 21010, + 21031, + 20000, + 23006, + 23004, + 24003, + 22000, + 21029, + 21022, + 21015, + 21008, + 21001, + 23005, + 24002, + 21030, + 21023, + 21016, + 21009, + 21002, + 20017, + 20010, + 20003, + 20016, + 20009, + 20002, + 20018, + 20011, + 20004, + 20020, + 20013, + 20006, + 23014, + 23016, + ]: + if weapon.id_ == 23016: + return WorrisomeBlissf(weapon) + if weapon.id_ == 23012: + return SleepLiketheDead(weapon) + if weapon.id_ == 23014: + return Thisbodyisasword(weapon) + if weapon.id_ == 20006: + return DataBank(weapon) + if weapon.id_ == 20013: + return Passkey(weapon) + if weapon.id_ == 20020: + return Sagacity(weapon) + if weapon.id_ == 20004: + return Void(weapon) + if weapon.id_ == 20011: + return Loop(weapon) + if weapon.id_ == 20018: + return HiddenShadow(weapon) + if weapon.id_ == 20002: + return CollapsingSky(weapon) + if weapon.id_ == 20009: + return ShatteredHome(weapon) + if weapon.id_ == 20016: + return MutualDemise(weapon) + if weapon.id_ == 20003: + return Amber(weapon) + if weapon.id_ == 20010: + return Defense(weapon) + if weapon.id_ == 20017: + return Pioneering(weapon) + if weapon.id_ == 21002: + return DayOneofMyNewLife(weapon) + if weapon.id_ == 21009: + return LandausChoice(weapon) + if weapon.id_ == 21016: + return TrendoftheUniversalMarket(weapon) + if weapon.id_ == 21023: + return WeAreWildfire(weapon) + if weapon.id_ == 21030: + return ThisIsMe(weapon) + if weapon.id_ == 24002: + return TextureofMemories(weapon) + if weapon.id_ == 23005: + return MomentofVictory(weapon) + if weapon.id_ == 23011: + return SheAlreadyShutHerEyes(weapon) + if weapon.id_ == 21001: + return GoodNightandSleepWell(weapon) + if weapon.id_ == 21008: + return EyesofthePrey(weapon) + if weapon.id_ == 21015: + return ResolutionShinesAsPearlsofSweat(weapon) + if weapon.id_ == 21022: + return Fermata(weapon) + if weapon.id_ == 21029: + return WeWillMeetAgain(weapon) + if weapon.id_ == 22000: + return BeforetheTutorialMissionStarts(weapon) + if weapon.id_ == 24003: + return SolitaryHealing(weapon) + if weapon.id_ == 23004: + return IntheNameoftheWorld(weapon) + if weapon.id_ == 23006: + return PatienceIsAllYouNeed(weapon) + if weapon.id_ == 23007: + return IncessantRain(weapon) + if weapon.id_ == 21005: + return TheMolesWelcomeYou(weapon) + if weapon.id_ == 21019: + return UndertheBlueSky(weapon) + if weapon.id_ == 21026: + return WoofWalkTime(weapon) + if weapon.id_ == 21033: + return NowheretoRun(weapon) + if weapon.id_ == 24000: + return OntheFallofanAeon(weapon) + if weapon.id_ == 23002: + return SomethingIrreplaceable(weapon) + if weapon.id_ == 23009: + return TheUnreachableSide(weapon) + if weapon.id_ == 23015: + return BrighterThantheSun(weapon) + if weapon.id_ == 21012: + return ASecretVow(weapon) + if weapon.id_ == 21006: + return TheBirthoftheSelf(weapon) + if weapon.id_ == 21013: + return MaketheWorldClamor(weapon) + if weapon.id_ == 21020: + return GeniusesRepose(weapon) + if weapon.id_ == 21027: + return SeriousnessofBreakfast(weapon) + if weapon.id_ == 21034: + return TodayIsAnotherPeacefulDay(weapon) + if weapon.id_ == 23000: + return NightontheMilkyWay(weapon) + if weapon.id_ == 23010: + return BeforeDawn(weapon) + if weapon.id_ == 24001: + return CruisingintheStellarSea(weapon) + if weapon.id_ == 23001: + return IntheNight(weapon) + if weapon.id_ == 21003: + return OnlySilenceRemains(weapon) + if weapon.id_ == 21024: + return RiverFlowsinSpring(weapon) + if weapon.id_ == 20014: + return Adversarial(weapon) + if weapon.id_ == 20007: + return DartingArrow(weapon) + if weapon.id_ == 21010: + return Swordplay(weapon) + if weapon.id_ == 21031: + return ReturntoDarkness(weapon) + if weapon.id_ == 20000: + return Arrows(weapon) + raise ValueError(f'未知武器id: {weapon.id_}') + raise ValueError(f'不支持的武器种类: {weapon.id_}') diff --git a/StarRailUID/starrailuid_charinfo/get_char_img.py b/StarRailUID/starrailuid_charinfo/get_char_img.py index 4afebb2..533cbca 100644 --- a/StarRailUID/starrailuid_charinfo/get_char_img.py +++ b/StarRailUID/starrailuid_charinfo/get_char_img.py @@ -130,7 +130,9 @@ async def get_char_args( if isinstance(char_data, str): return char_data else: - for i, s in enumerate(['头部', '手部', '躯干', '腿部', '位面球', '连结绳']): + for i, s in enumerate( + ['头部', '手部', '躯干', '腿部', '位面球', '连结绳'] + ): if '赤沙' in part: continue if part[-1] in PieceName_ilst[i]: diff --git a/StarRailUID/starrailuid_charinfo/to_card.py b/StarRailUID/starrailuid_charinfo/to_card.py index 09eae2e..13551d7 100644 --- a/StarRailUID/starrailuid_charinfo/to_card.py +++ b/StarRailUID/starrailuid_charinfo/to_card.py @@ -54,7 +54,9 @@ async def draw_enka_card(uid: str, char_list: List, showfrom: int = 0): return await convert_img(Image.new('RGBA', (0, 1), (255, 255, 255))) else: line1 = f'UID {uid} 刷新成功' - line2 = f'可以使用 sr查询{char_data_list[0]["avatarName"]} 查询详情角色面板' + line2 = ( + f'可以使用 sr查询{char_data_list[0]["avatarName"]} 查询详情角色面板' + ) char_num = len(char_data_list) if char_num <= 4: based_w, based_h = 1380, 926 diff --git a/StarRailUID/starrailuid_config/config_default.py b/StarRailUID/starrailuid_config/config_default.py index d0d4beb..a025653 100644 --- a/StarRailUID/starrailuid_config/config_default.py +++ b/StarRailUID/starrailuid_config/config_default.py @@ -8,7 +8,9 @@ from gsuid_core.utils.plugins_config.models import ( ) CONIFG_DEFAULT: Dict[str, GSC] = { - 'SignTime': GsListStrConfig('每晚签到时间设置', '每晚米游社签到时间设置(时,分)', ['0', '38']), + 'SignTime': GsListStrConfig( + '每晚签到时间设置', '每晚米游社签到时间设置(时,分)', ['0', '38'] + ), 'SignReportSimple': GsBoolConfig( '简洁签到报告', '开启后可以大大减少每日签到报告字数', diff --git a/StarRailUID/starrailuid_gachalog/__init__.py b/StarRailUID/starrailuid_gachalog/__init__.py index 2c126c1..e852088 100644 --- a/StarRailUID/starrailuid_gachalog/__init__.py +++ b/StarRailUID/starrailuid_gachalog/__init__.py @@ -39,6 +39,8 @@ async def get_gachalog_by_link(bot: Bot, ev: Event): if ev.command.startswith('强制'): await bot.logger.info('[WARNING]本次为强制刷新') is_force = True - await bot.send(f'UID{uid}开始执行[刷新抽卡记录],需要一定时间...请勿重复触发!') + await bot.send( + f'UID{uid}开始执行[刷新抽卡记录],需要一定时间...请勿重复触发!' + ) im = await save_gachalogs(uid, gacha_url, None, is_force) return await bot.send(im) diff --git a/StarRailUID/starrailuid_gachalog/get_gachalogs.py b/StarRailUID/starrailuid_gachalog/get_gachalogs.py index be86cc5..eec5419 100644 --- a/StarRailUID/starrailuid_gachalog/get_gachalogs.py +++ b/StarRailUID/starrailuid_gachalog/get_gachalogs.py @@ -112,7 +112,12 @@ async def save_gachalogs( uid, gacha_url, gachalogs_history, is_force ) else: - new_data = {'始发跃迁': [], '群星跃迁': [], '角色跃迁': [], '光锥跃迁': []} + new_data = { + '始发跃迁': [], + '群星跃迁': [], + '角色跃迁': [], + '光锥跃迁': [], + } if gachalogs_history: for i in ['始发跃迁', '群星跃迁', '角色跃迁', '光锥跃迁']: for item in raw_data[i]: @@ -128,7 +133,12 @@ async def save_gachalogs( if raw_data == {} or not raw_data: return '请给出正确的抽卡记录链接或链接已失效' - temp_data = {'始发跃迁': [], '群星跃迁': [], '角色跃迁': [], '光锥跃迁': []} + temp_data = { + '始发跃迁': [], + '群星跃迁': [], + '角色跃迁': [], + '光锥跃迁': [], + } for i in ['始发跃迁', '群星跃迁', '角色跃迁', '光锥跃迁']: for item in raw_data[i]: if item not in temp_data[i]: diff --git a/StarRailUID/starrailuid_note/draw_note_card.py b/StarRailUID/starrailuid_note/draw_note_card.py index 9458be4..2fe36ac 100644 --- a/StarRailUID/starrailuid_note/draw_note_card.py +++ b/StarRailUID/starrailuid_note/draw_note_card.py @@ -1,278 +1,279 @@ -import json -from pathlib import Path -from typing import Union -from datetime import datetime - -from PIL import Image, ImageDraw -from msgspec import json as msgjson -from gsuid_core.logger import logger - -from ..utils.mys_api import mys_api -from ..utils.error_reply import get_error -from ..utils.image.convert import convert_img -from ..utils.resource.RESOURCE_PATH import PLAYER_PATH -from ..utils.fonts.starrail_fonts import sr_font_20, sr_font_28, sr_font_34 - -TEXT_PATH = Path(__file__).parent / 'texture2d' - -monthly_bg = Image.open(TEXT_PATH / 'monthly_bg.png') -avatar_default = Image.open(TEXT_PATH / '200101.png') - -first_color = (29, 29, 29) -second_color = (67, 61, 56) -second_color2 = (98, 98, 98) -black_color = (54, 54, 54) -white_color = (213, 213, 213) - -COLOR_MAP = { - '每日活跃': (248, 227, 157), - '活动奖励': (99, 231, 176), - '冒险奖励': (114, 205, 251), - '模拟宇宙奖励': (160, 149, 248), - '忘却之庭奖励': (221, 119, 250), - '邮件奖励': (244, 110, 104), - '其他': (255, 242, 200), - 'Daily Activity': (248, 227, 157), - 'Events': (99, 231, 176), - 'Adventure': (114, 205, 251), - 'moni': (160, 149, 248), - 'Spiral Abyss': (221, 119, 250), - 'Quests': (244, 110, 104), - 'Other': (255, 242, 200), -} - - -async def draw_note_img(sr_uid: str) -> Union[bytes, str]: - path = PLAYER_PATH / str(sr_uid) - if not path.exists(): - path.mkdir(parents=True, exist_ok=True) - - # 获取当前时间 - now = datetime.now() - current_year_mon = now.strftime('%Y-%m') - add_month = '' - if int(now.month) < 10: - add_month = '0' - now_month = str(now.year) + str(add_month) + str(now.month) - # 获取数据 - data = await mys_api.get_award(sr_uid, now_month) - if isinstance(data, int): - return get_error(data) - - # 保存数据 - with Path.open( - path / f'monthly_{current_year_mon}.json', 'w', encoding='utf-8' - ) as f: - save_json_data = msgjson.format(msgjson.encode(data), indent=4) - save_data = json.dumps( - { - 'data_time': now.strftime('%Y-%m-%d %H:%M:%S'), - 'data': save_json_data.decode('utf-8'), - }, - ensure_ascii=False, - ) - f.write(save_data) - - # 获取上月数据 - last_month = now.month - 1 - last_year = now.year - if last_month == 0: - last_month = 12 - last_year -= 1 - last_year_mon = f'{last_year}-{last_month:02d}' - last_monthly_path = path / f'monthly_{last_year_mon}.json' - if last_monthly_path.exists(): - with Path.open(last_monthly_path, encoding='utf-8') as f: - last_monthly_data = json.load(f) - last_monthly_data = last_monthly_data['data'] - else: - add_month = '' - if int(last_month) < 10: - add_month = '0' - find_last_month = str(last_year) + str(add_month) + str(last_month) - last_monthly_data = await mys_api.get_award(sr_uid, find_last_month) - if isinstance(last_monthly_data, int): - return get_error(last_monthly_data) - - # nickname and level - role_basic_info = await mys_api.get_role_basic_info(sr_uid) - if isinstance(role_basic_info, int): - return get_error(role_basic_info) - nickname = role_basic_info.nickname - - day_hcoin = data.day_data.current_hcoin - day_rails_pass = data.day_data.current_rails_pass - lastday_hcoin = 0 - lastday_rails_pass = 0 - if int(sr_uid[0]) < 6: - lastday_hcoin = data.day_data.last_hcoin - lastday_rails_pass = data.day_data.last_rails_pass - month_hcoin = data.month_data.current_hcoin - month_rails_pass = data.month_data.current_rails_pass - lastmonth_hcoin = data.month_data.last_hcoin - lastmonth_rails_pass = data.month_data.last_rails_pass - - day_hcoin_str = await int_carry(day_hcoin) - day_rails_pass_str = await int_carry(day_rails_pass) - month_hcoin_str = await int_carry(month_hcoin) - month_rails_pass_str = await int_carry(month_rails_pass) - lastday_hcoin_str = await int_carry(lastday_hcoin) - lastday_rails_pass_str = await int_carry(lastday_rails_pass) - lastmonth_hcoin_str = await int_carry(lastmonth_hcoin) - lastmonth_rails_pass_str = await int_carry(lastmonth_rails_pass) - - img = monthly_bg.copy() - avatar_img = avatar_default.copy() - char_pic = avatar_img.convert('RGBA').resize( - (125, 125), Image.Resampling.LANCZOS # type: ignore - ) - img.paste(char_pic, (115, 133), char_pic) - img_draw = ImageDraw.Draw(img) - - # 写Nickname - img_draw.text( - (310, 184), nickname, font=sr_font_34, fill=first_color, anchor='lm' - ) - - # 写UID - img_draw.text( - (267, 219), - f'UID {sr_uid}', - font=sr_font_20, - fill=second_color2, - anchor='lm', - ) - - # 写本日星琼 - img_draw.text( - (283, 326), - day_hcoin_str, - font=sr_font_28, - fill=white_color, - anchor='lm', - ) - - # 写本月星琼 - img_draw.text( - (513, 326), - month_hcoin_str, - font=sr_font_28, - fill=white_color, - anchor='lm', - ) - - # 写昨日星琼 - img_draw.text( - (283, 366), - lastday_hcoin_str, - font=sr_font_28, - fill=black_color, - anchor='lm', - ) - - # 写上月星琼 - img_draw.text( - (513, 366), - lastmonth_hcoin_str, - font=sr_font_28, - fill=black_color, - anchor='lm', - ) - - # 写本日铁票 - img_draw.text( - (283, 431), - day_rails_pass_str, - font=sr_font_28, - fill=white_color, - anchor='lm', - ) - - # 写本月铁票 - img_draw.text( - (513, 431), - month_rails_pass_str, - font=sr_font_28, - fill=white_color, - anchor='lm', - ) - - # 写昨日铁票 - img_draw.text( - (283, 473), - lastday_rails_pass_str, - font=sr_font_28, - fill=black_color, - anchor='lm', - ) - - # 写上月铁票 - img_draw.text( - (513, 473), - lastmonth_rails_pass_str, - font=sr_font_28, - fill=black_color, - anchor='lm', - ) - xy = ((0, 0), (2100, 2100)) - temp = -90 - if not data.month_data.group_by: - pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) - pie_image_draw = ImageDraw.Draw(pie_image) - pie_image_draw.ellipse(xy, fill=(128, 128, 128)) - else: - pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) - pie_image_draw = ImageDraw.Draw(pie_image) - for _index, i in enumerate(data.month_data.group_by): - pie_image_draw.pieslice( - xy, - temp, - temp + (i.percent / 100) * 360, - COLOR_MAP[i.action_name], - ) - temp = temp + (i.percent / 100) * 360 - # 绘制蒙版圆形 - new_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) - pie_image_draw.ellipse((150, 150, 1950, 1950), fill=(255, 255, 255, 0)) - - position = (1050, 1050) - pie_image.paste(new_image, position, mask=new_image) - result_pie = pie_image.resize((210, 210)) - img.paste(result_pie, (138, 618), result_pie) - - if last_monthly_data: - pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) - pie_image_draw = ImageDraw.Draw(pie_image) - for _index, i in enumerate(last_monthly_data.month_data.group_by): - pie_image_draw.pieslice( - xy, - temp, - temp + (i.percent / 100) * 360, - COLOR_MAP[i.action_name], - ) - temp = temp + (i.percent / 100) * 360 - else: - pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) - pie_image_draw = ImageDraw.Draw(pie_image) - pie_image_draw.ellipse(xy, fill=(128, 128, 128)) - - # 绘制蒙版圆形 - new_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) - pie_image_draw.ellipse((150, 150, 1950, 1950), fill=(255, 255, 255, 0)) - - position = (1050, 1050) - pie_image.paste(new_image, position, mask=new_image) - result_pie = pie_image.resize((210, 210)) - img.paste(result_pie, (138, 618 + 350), result_pie) - - img = await convert_img(img) - logger.info('[开拓月历] 图片绘制完成!等待发送...') - return img - - -async def int_carry(i: int) -> str: - if i >= 100000: - i_str = f'{i / 10000:.1f}W' - else: - i_str = str(i) - return i_str +import json +from pathlib import Path +from typing import Union +from datetime import datetime + +from PIL import Image, ImageDraw +from msgspec import json as msgjson +from gsuid_core.logger import logger + +from ..utils.mys_api import mys_api +from ..utils.error_reply import get_error +from ..utils.image.convert import convert_img +from ..utils.resource.RESOURCE_PATH import PLAYER_PATH +from ..utils.fonts.starrail_fonts import sr_font_20, sr_font_28, sr_font_34 + +TEXT_PATH = Path(__file__).parent / 'texture2d' + +monthly_bg = Image.open(TEXT_PATH / 'monthly_bg.png') +avatar_default = Image.open(TEXT_PATH / '200101.png') + +first_color = (29, 29, 29) +second_color = (67, 61, 56) +second_color2 = (98, 98, 98) +black_color = (54, 54, 54) +white_color = (213, 213, 213) + +COLOR_MAP = { + '每日活跃': (248, 227, 157), + '活动奖励': (99, 231, 176), + '冒险奖励': (114, 205, 251), + '模拟宇宙奖励': (160, 149, 248), + '忘却之庭奖励': (221, 119, 250), + '邮件奖励': (244, 110, 104), + '其他': (255, 242, 200), + 'Daily Activity': (248, 227, 157), + 'Events': (99, 231, 176), + 'Adventure': (114, 205, 251), + 'moni': (160, 149, 248), + 'Spiral Abyss': (221, 119, 250), + 'Quests': (244, 110, 104), + 'Other': (255, 242, 200), +} + + +async def draw_note_img(sr_uid: str) -> Union[bytes, str]: + path = PLAYER_PATH / str(sr_uid) + if not path.exists(): + path.mkdir(parents=True, exist_ok=True) + + # 获取当前时间 + now = datetime.now() + current_year_mon = now.strftime('%Y-%m') + add_month = '' + if int(now.month) < 10: + add_month = '0' + now_month = str(now.year) + str(add_month) + str(now.month) + # 获取数据 + data = await mys_api.get_award(sr_uid, now_month) + if isinstance(data, int): + return get_error(data) + + # 保存数据 + with Path.open( + path / f'monthly_{current_year_mon}.json', 'w', encoding='utf-8' + ) as f: + save_json_data = msgjson.format(msgjson.encode(data), indent=4) + save_data = json.dumps( + { + 'data_time': now.strftime('%Y-%m-%d %H:%M:%S'), + 'data': save_json_data.decode('utf-8'), + }, + ensure_ascii=False, + ) + f.write(save_data) + + # 获取上月数据 + last_month = now.month - 1 + last_year = now.year + if last_month == 0: + last_month = 12 + last_year -= 1 + last_year_mon = f'{last_year}-{last_month:02d}' + last_monthly_path = path / f'monthly_{last_year_mon}.json' + if last_monthly_path.exists(): + with Path.open(last_monthly_path, encoding='utf-8') as f: + last_monthly_data = json.load(f) + last_monthly_data = last_monthly_data['data'] + else: + add_month = '' + if int(last_month) < 10: + add_month = '0' + find_last_month = str(last_year) + str(add_month) + str(last_month) + last_monthly_data = await mys_api.get_award(sr_uid, find_last_month) + if isinstance(last_monthly_data, int): + return get_error(last_monthly_data) + + # nickname and level + role_basic_info = await mys_api.get_role_basic_info(sr_uid) + if isinstance(role_basic_info, int): + return get_error(role_basic_info) + nickname = role_basic_info.nickname + + day_hcoin = data.day_data.current_hcoin + day_rails_pass = data.day_data.current_rails_pass + lastday_hcoin = 0 + lastday_rails_pass = 0 + if int(sr_uid[0]) < 6: + lastday_hcoin = data.day_data.last_hcoin + lastday_rails_pass = data.day_data.last_rails_pass + month_hcoin = data.month_data.current_hcoin + month_rails_pass = data.month_data.current_rails_pass + lastmonth_hcoin = data.month_data.last_hcoin + lastmonth_rails_pass = data.month_data.last_rails_pass + + day_hcoin_str = await int_carry(day_hcoin) + day_rails_pass_str = await int_carry(day_rails_pass) + month_hcoin_str = await int_carry(month_hcoin) + month_rails_pass_str = await int_carry(month_rails_pass) + lastday_hcoin_str = await int_carry(lastday_hcoin) + lastday_rails_pass_str = await int_carry(lastday_rails_pass) + lastmonth_hcoin_str = await int_carry(lastmonth_hcoin) + lastmonth_rails_pass_str = await int_carry(lastmonth_rails_pass) + + img = monthly_bg.copy() + avatar_img = avatar_default.copy() + char_pic = avatar_img.convert('RGBA').resize( + (125, 125), + Image.Resampling.LANCZOS, # type: ignore + ) + img.paste(char_pic, (115, 133), char_pic) + img_draw = ImageDraw.Draw(img) + + # 写Nickname + img_draw.text( + (310, 184), nickname, font=sr_font_34, fill=first_color, anchor='lm' + ) + + # 写UID + img_draw.text( + (267, 219), + f'UID {sr_uid}', + font=sr_font_20, + fill=second_color2, + anchor='lm', + ) + + # 写本日星琼 + img_draw.text( + (283, 326), + day_hcoin_str, + font=sr_font_28, + fill=white_color, + anchor='lm', + ) + + # 写本月星琼 + img_draw.text( + (513, 326), + month_hcoin_str, + font=sr_font_28, + fill=white_color, + anchor='lm', + ) + + # 写昨日星琼 + img_draw.text( + (283, 366), + lastday_hcoin_str, + font=sr_font_28, + fill=black_color, + anchor='lm', + ) + + # 写上月星琼 + img_draw.text( + (513, 366), + lastmonth_hcoin_str, + font=sr_font_28, + fill=black_color, + anchor='lm', + ) + + # 写本日铁票 + img_draw.text( + (283, 431), + day_rails_pass_str, + font=sr_font_28, + fill=white_color, + anchor='lm', + ) + + # 写本月铁票 + img_draw.text( + (513, 431), + month_rails_pass_str, + font=sr_font_28, + fill=white_color, + anchor='lm', + ) + + # 写昨日铁票 + img_draw.text( + (283, 473), + lastday_rails_pass_str, + font=sr_font_28, + fill=black_color, + anchor='lm', + ) + + # 写上月铁票 + img_draw.text( + (513, 473), + lastmonth_rails_pass_str, + font=sr_font_28, + fill=black_color, + anchor='lm', + ) + xy = ((0, 0), (2100, 2100)) + temp = -90 + if not data.month_data.group_by: + pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) + pie_image_draw = ImageDraw.Draw(pie_image) + pie_image_draw.ellipse(xy, fill=(128, 128, 128)) + else: + pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) + pie_image_draw = ImageDraw.Draw(pie_image) + for _index, i in enumerate(data.month_data.group_by): + pie_image_draw.pieslice( + xy, + temp, + temp + (i.percent / 100) * 360, + COLOR_MAP[i.action_name], + ) + temp = temp + (i.percent / 100) * 360 + # 绘制蒙版圆形 + new_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) + pie_image_draw.ellipse((150, 150, 1950, 1950), fill=(255, 255, 255, 0)) + + position = (1050, 1050) + pie_image.paste(new_image, position, mask=new_image) + result_pie = pie_image.resize((210, 210)) + img.paste(result_pie, (138, 618), result_pie) + + if last_monthly_data: + pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) + pie_image_draw = ImageDraw.Draw(pie_image) + for _index, i in enumerate(last_monthly_data.month_data.group_by): + pie_image_draw.pieslice( + xy, + temp, + temp + (i.percent / 100) * 360, + COLOR_MAP[i.action_name], + ) + temp = temp + (i.percent / 100) * 360 + else: + pie_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) + pie_image_draw = ImageDraw.Draw(pie_image) + pie_image_draw.ellipse(xy, fill=(128, 128, 128)) + + # 绘制蒙版圆形 + new_image = Image.new('RGBA', (2100, 2100), color=(255, 255, 255, 0)) + pie_image_draw.ellipse((150, 150, 1950, 1950), fill=(255, 255, 255, 0)) + + position = (1050, 1050) + pie_image.paste(new_image, position, mask=new_image) + result_pie = pie_image.resize((210, 210)) + img.paste(result_pie, (138, 618 + 350), result_pie) + + img = await convert_img(img) + logger.info('[开拓月历] 图片绘制完成!等待发送...') + return img + + +async def int_carry(i: int) -> str: + if i >= 100000: + i_str = f'{i / 10000:.1f}W' + else: + i_str = str(i) + return i_str diff --git a/StarRailUID/starrailuid_resource/__init__.py b/StarRailUID/starrailuid_resource/__init__.py index 1fae1cd..dac9052 100644 --- a/StarRailUID/starrailuid_resource/__init__.py +++ b/StarRailUID/starrailuid_resource/__init__.py @@ -17,5 +17,7 @@ async def send_download_resource_msg(bot: Bot, ev: Event): async def startup(): - logger.info('[sr资源文件下载] 正在检查与下载缺失的资源文件,可能需要较长时间,请稍等') + logger.info( + '[sr资源文件下载] 正在检查与下载缺失的资源文件,可能需要较长时间,请稍等' + ) logger.info(f'[sr资源文件下载] {await download_all_resource()}') diff --git a/StarRailUID/starrailuid_signin/__init__.py b/StarRailUID/starrailuid_signin/__init__.py index c3c7991..466afc5 100644 --- a/StarRailUID/starrailuid_signin/__init__.py +++ b/StarRailUID/starrailuid_signin/__init__.py @@ -65,7 +65,9 @@ async def send_daily_sign(): single['msg'], 'direct', qid, single['bot_id'], '', '' ) except Exception as e: - logger.warning(f'[SR每日全部签到] QQ {qid} 私聊推送失败!错误信息:{e}') + logger.warning( + f'[SR每日全部签到] QQ {qid} 私聊推送失败!错误信息:{e}' + ) await asyncio.sleep(0.5) logger.info('[SR每日全部签到]私聊推送完成') @@ -74,7 +76,9 @@ async def send_daily_sign(): # 根据succee数判断是否为简洁推送 if group_msg_list[gid]['success'] >= 0: report = ( - '以下为签到失败报告:{}'.format(group_msg_list[gid]['push_message']) + '以下为签到失败报告:{}'.format( + group_msg_list[gid]['push_message'] + ) if group_msg_list[gid]['push_message'] != '' else '' ) diff --git a/StarRailUID/starrailuid_signin/sign.py b/StarRailUID/starrailuid_signin/sign.py index c014b64..16c92b4 100644 --- a/StarRailUID/starrailuid_signin/sign.py +++ b/StarRailUID/starrailuid_signin/sign.py @@ -57,11 +57,15 @@ async def sign_in(sr_uid: str) -> str: Header['x-rpc-challenge'] = ch Header['x-rpc-validate'] = vl Header['x-rpc-seccode'] = f'{vl}|jordan' - logger.info(f'[SR签到] {sr_uid} 已获取验证码, 等待时间{delay}秒') + logger.info( + f'[SR签到] {sr_uid} 已获取验证码, 等待时间{delay}秒' + ) await asyncio.sleep(delay) else: delay = 605 + random.randint(1, 120) - logger.info(f'[SR签到] {sr_uid} 未获取验证码,等待{delay}秒后重试...') + logger.info( + f'[SR签到] {sr_uid} 未获取验证码,等待{delay}秒后重试...' + ) await asyncio.sleep(delay) continue logger.info('配置文件暂未开启[跳过无感验证],结束本次任务...') @@ -70,7 +74,9 @@ async def sign_in(sr_uid: str) -> str: if index == 0: logger.info(f'[SR签到] {sr_uid} 该用户无校验码!') else: - logger.info(f'[SR签到] [无感验证] {sr_uid} 该用户重试 {index} 次验证成功!') + logger.info( + f'[SR签到] [无感验证] {sr_uid} 该用户重试 {index} 次验证成功!' + ) break if (int(str(sr_uid)[0]) > 5) and (sign_data.code == 'ok'): # 国际服签到无risk_code字段 @@ -103,7 +109,9 @@ async def sign_in(sr_uid: str) -> str: sign_missed -= 1 sign_missed = sign_info.sign_cnt_missed or sign_missed im = f'{mes_im}!\n{get_im}\n本月漏签次数:{sign_missed}' - logger.info(f'[SR签到] {sr_uid} 签到完成, 结果: {mes_im}, 漏签次数: {sign_missed}') + logger.info( + f'[SR签到] {sr_uid} 签到完成, 结果: {mes_im}, 漏签次数: {sign_missed}' + ) return im @@ -163,7 +171,9 @@ async def daily_sign(): delay = 1 else: delay = 50 + random.randint(3, 45) - logger.info(f'[SR签到] 已签到{len(tasks)}个用户, 等待{delay}秒进行下一次签到') + logger.info( + f'[SR签到] 已签到{len(tasks)}个用户, 等待{delay}秒进行下一次签到' + ) tasks.clear() already = 0 await asyncio.sleep(delay) diff --git a/StarRailUID/starrailuid_stamina/draw_stamina_card.py b/StarRailUID/starrailuid_stamina/draw_stamina_card.py index 2e1fe67..8c8202c 100644 --- a/StarRailUID/starrailuid_stamina/draw_stamina_card.py +++ b/StarRailUID/starrailuid_stamina/draw_stamina_card.py @@ -69,7 +69,8 @@ async def _draw_task_img( avatar_url = char.avatars[i] image = await download_image(avatar_url) char_pic = image.convert('RGBA').resize( - (40, 40), Image.Resampling.LANCZOS # type: ignore + (40, 40), + Image.Resampling.LANCZOS, # type: ignore ) note_travel_img.paste(char_pic, (495 + 68 * i, 20), char_pic) img.paste(note_travel_img, (0, 790 + index * 80), note_travel_img) diff --git a/StarRailUID/starrailuid_user/__init__.py b/StarRailUID/starrailuid_user/__init__.py index 61b66db..19f7cc3 100644 --- a/StarRailUID/starrailuid_user/__init__.py +++ b/StarRailUID/starrailuid_user/__init__.py @@ -27,7 +27,12 @@ async def send_bind_card(bot: Bot, ev: Event): @sv_user_info.on_command( - (f'{PREFIX}绑定uid', f'{PREFIX}切换uid', f'{PREFIX}删除uid', f'{PREFIX}解绑uid') + ( + f'{PREFIX}绑定uid', + f'{PREFIX}切换uid', + f'{PREFIX}删除uid', + f'{PREFIX}解绑uid', + ) ) async def send_link_uid_msg(bot: Bot, ev: Event): await bot.logger.info('sr开始执行[绑定/解绑用户信息]') diff --git a/StarRailUID/utils/resource/download_from_cos.py b/StarRailUID/utils/resource/download_from_cos.py index 038e3b6..841f70e 100644 --- a/StarRailUID/utils/resource/download_from_cos.py +++ b/StarRailUID/utils/resource/download_from_cos.py @@ -81,7 +81,9 @@ async def download_all_file_from_cos(): or not Path.stat(path).st_size or not is_diff ): - logger.info(f'[cos]开始下载[{resource_type}]_[{name}]...') + logger.info( + f'[cos]开始下载[{resource_type}]_[{name}]...' + ) temp_num += 1 if isinstance(url, int): logger.error( @@ -119,4 +121,6 @@ async def download_all_file_from_cos(): await _download(TASKS) await _download(TASKS) if count := len(failed_list): - logger.error(f'[cos]仍有{count}个文件未下载,请使用命令 `下载全部资源` 重新下载') + logger.error( + f'[cos]仍有{count}个文件未下载,请使用命令 `下载全部资源` 重新下载' + )