From 580f844524b2ab903e8f2d04e71cf8ac751983eb Mon Sep 17 00:00:00 2001 From: qwerdvd <105906879+qwerdvd@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:17:55 +0800 Subject: [PATCH] bump to v1.0.9 --- pyproject.toml | 2 +- starrail_damage_cal/cal_damage.py | 2 +- .../damage/AvatarDamage/AvatarDamage.py | 47 +++++++++++----- starrail_damage_cal/damage/Relic/Relic.py | 33 ++++++++--- starrail_damage_cal/damage/Role.py | 56 ++++++++++++------- starrail_damage_cal/damage/Weapon/Weapon.py | 41 +++++++++++--- 6 files changed, 127 insertions(+), 54 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9710819..42ee164 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "starrail_damage_cal" -version = "1.0.8" +version = "1.0.9" description = "For StarRail Role Damage Cal" authors = [ {name = "qwerdvd", email = "105906879+qwerdvd@users.noreply.github.com"}, diff --git a/starrail_damage_cal/cal_damage.py b/starrail_damage_cal/cal_damage.py index da09954..1c1e2f3 100644 --- a/starrail_damage_cal/cal_damage.py +++ b/starrail_damage_cal/cal_damage.py @@ -104,7 +104,7 @@ class DamageCal: @classmethod async def get_all_damage_data_by_uid(cls, uid: str): - char_id_list, char_data_dict = await api_to_dict(sr_uid=uid) + char_id_list, char_data_dict = await api_to_dict(uid=uid) if isinstance(char_id_list, str): raise MihomoRequestError diff --git a/starrail_damage_cal/damage/AvatarDamage/AvatarDamage.py b/starrail_damage_cal/damage/AvatarDamage/AvatarDamage.py index f245eb2..6e81b71 100644 --- a/starrail_damage_cal/damage/AvatarDamage/AvatarDamage.py +++ b/starrail_damage_cal/damage/AvatarDamage/AvatarDamage.py @@ -7,11 +7,11 @@ from starrail_damage_cal.damage.Base.model import ( DamageInstanceSkill, ) from starrail_damage_cal.damage.Role import ( + break_damage, calculate_damage, calculate_heal, calculate_shield, get_damage, - break_damage, ) from starrail_damage_cal.logger import logger @@ -4371,6 +4371,7 @@ class Hanya(BaseAvatar): return skill_info_list + class DrRatio(BaseAvatar): Buff: BaseAvatarBuff @@ -4401,16 +4402,23 @@ class DrRatio(BaseAvatar): CC_ADD = self.Skill_num("Talent", "Talent_CC") CD_ADD = self.Skill_num("Talent", "Talent_CD") SPD_ADD = self.Skill_num("Talent", "Talent_S") - + buff_num = 3 if self.avatar_rank >= 1: buff_num = 5 - - attribute_bonus["AttackAddedRatio"] = attribute_bonus.get("AttackAddedRatio",0) + ATK_ADD * buff_num - attribute_bonus["CriticalChanceBase"] = attribute_bonus.get("CriticalChanceBase",0) + CC_ADD * buff_num - attribute_bonus["CriticalDamageBase"] = attribute_bonus.get("CriticalDamageBase",0) + CD_ADD * buff_num - attribute_bonus["SpeedAddedRatio"] = attribute_bonus.get("SpeedAddedRatio",0) + SPD_ADD * buff_num - + + attribute_bonus["AttackAddedRatio"] = ( + attribute_bonus.get("AttackAddedRatio", 0) + ATK_ADD * buff_num + ) + attribute_bonus["CriticalChanceBase"] = ( + attribute_bonus.get("CriticalChanceBase", 0) + CC_ADD * buff_num + ) + attribute_bonus["CriticalDamageBase"] = ( + attribute_bonus.get("CriticalDamageBase", 0) + CD_ADD * buff_num + ) + attribute_bonus["SpeedAddedRatio"] = ( + attribute_bonus.get("SpeedAddedRatio", 0) + SPD_ADD * buff_num + ) damage1, damage2, damage3 = await calculate_damage( base_attr, @@ -4464,7 +4472,7 @@ class DrRatio(BaseAvatar): ) damagelist3[2] += damage3 skill_info_list.append({"name": "终结技", "damagelist": damagelist3}) - + # 计算天赋追伤伤害 skill_multiplier = self.Skill_num("Talent", "Talent") damagelist4 = await calculate_damage( @@ -4494,6 +4502,7 @@ class DrRatio(BaseAvatar): return skill_info_list + class RuanMei(BaseAvatar): Buff: BaseAvatarBuff @@ -4524,10 +4533,15 @@ class RuanMei(BaseAvatar): attribute_bonus: Dict[str, float], ): # 计算属性加成 - attribute_bonus["SpeedAddedRatio"] = attribute_bonus.get("SpeedAddedRatio",0) + self.Skill_num("BPSkill", "BPSkill") - attribute_bonus["ResistancePenetration"] = attribute_bonus.get("ResistancePenetration",0) + self.Skill_num("Ultra", "Ultra_P") - attribute_bonus["AllDamageAddedRatio"] = attribute_bonus.get("AllDamageAddedRatio",0) + self.Skill_num("Talent", "Talent_A") - + attribute_bonus["SpeedAddedRatio"] = attribute_bonus.get( + "SpeedAddedRatio", 0 + ) + self.Skill_num("BPSkill", "BPSkill") + attribute_bonus["ResistancePenetration"] = attribute_bonus.get( + "ResistancePenetration", 0 + ) + self.Skill_num("Ultra", "Ultra_P") + attribute_bonus["AllDamageAddedRatio"] = attribute_bonus.get( + "AllDamageAddedRatio", 0 + ) + self.Skill_num("Talent", "Talent_A") damage1, damage2, damage3 = await calculate_damage( base_attr, @@ -4557,7 +4571,9 @@ class RuanMei(BaseAvatar): # 计算终结技伤害 skill_multiplier = self.Skill_num("Ultra", "Ultra") if self.avatar_rank >= 6: - break_damage_added_ratio_base = attribute_bonus.get("BreakDamageAddedRatioBase", 0) + break_damage_added_ratio_base = attribute_bonus.get( + "BreakDamageAddedRatioBase", 0 + ) if break_damage_added_ratio_base >= 1.8: break_damage_added_ratio = break_damage_added_ratio_base - 1.8 skill_multiplier_add = int((break_damage_added_ratio * 100) / 10) * 0.24 @@ -4582,7 +4598,7 @@ class RuanMei(BaseAvatar): ) damagelist3[2] += damage3 skill_info_list.append({"name": "残梅绽附加伤害", "damagelist": damagelist3}) - + # 计算天赋追伤伤害 skill_multiplier = self.Skill_num("Talent", "Talent") damagelist4 = await get_damage( @@ -4599,6 +4615,7 @@ class RuanMei(BaseAvatar): return skill_info_list + class AvatarDamage: @classmethod def create(cls, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]): diff --git a/starrail_damage_cal/damage/Relic/Relic.py b/starrail_damage_cal/damage/Relic/Relic.py index 778aced..29918db 100644 --- a/starrail_damage_cal/damage/Relic/Relic.py +++ b/starrail_damage_cal/damage/Relic/Relic.py @@ -371,6 +371,7 @@ class Relic114(BaseRelicSetSkill): attribute_bonus["SpeedAddedRatio"] = speed_added_ratio + 0.12000000011175871 return attribute_bonus + class Relic115(BaseRelicSetSkill): def __init__(self, set_id: int, count: int): super().__init__(set_id, count) @@ -382,7 +383,7 @@ class Relic115(BaseRelicSetSkill): attribute_bonus: Dict[str, float], ): """追加攻击造成的伤害提高20%。""" - """每次造成伤害时使装备者的攻击力提高6%,最多叠加8次,持续3回合。该效果在装备者下一次施放追加攻击时移除。""" + """每次造成伤害时使装备者的攻击力提高6%, 最多叠加8次, 持续3回合。该效果在装备者下一次施放追加攻击时移除。""" logger.info("Relic114 check success") return True @@ -392,12 +393,17 @@ class Relic115(BaseRelicSetSkill): attribute_bonus: Dict[str, float], ): if self.pieces2: - attribute_bonus["TalentDmgAdd"] = attribute_bonus.get("TalentDmgAdd", 0) + 0.20000000011175871 + attribute_bonus["TalentDmgAdd"] = ( + attribute_bonus.get("TalentDmgAdd", 0) + 0.20000000011175871 + ) 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.06000000009313226 * 8 + attribute_bonus["AttackAddedRatio"] = ( + attack_added_ratio + 0.06000000009313226 * 8 + ) return attribute_bonus + class Relic116(BaseRelicSetSkill): def __init__(self, set_id: int, count: int): super().__init__(set_id, count) @@ -408,7 +414,7 @@ class Relic116(BaseRelicSetSkill): base_attr: Dict[str, float], attribute_bonus: Dict[str, float], ): - """敌方目标每承受1个持续伤害效果,装备者对其造成伤害时就无视其6%的防御力,最多计入3个持续伤害效果。""" + """敌方目标每承受1个持续伤害效果, 装备者对其造成伤害时就无视其6%的防御力, 最多计入3个持续伤害效果。""" logger.info("Relic114 check success") return True @@ -422,6 +428,7 @@ class Relic116(BaseRelicSetSkill): attribute_bonus["ignore_defence"] = ignore_defence + 0.06000000009313226 * 3 return attribute_bonus + class Relic301(BaseRelicSetSkill): def __init__(self, set_id: int, count: int): super().__init__(set_id, count) @@ -711,6 +718,7 @@ class Relic310(BaseRelicSetSkill): ) return attribute_bonus + class Relic311(BaseRelicSetSkill): def __init__(self, set_id: int, count: int): super().__init__(set_id, count) @@ -720,7 +728,7 @@ class Relic311(BaseRelicSetSkill): base_attr: Dict[str, float], attribute_bonus: Dict[str, float], ): - """当装备者的速度大于等于135/160时,使装备者造成的伤害提高12%/18%。""" + """当装备者的速度大于等于135/160时, 使装备者造成的伤害提高12%/18%。""" merged_attr = await merge_attribute(base_attr, attribute_bonus) if merged_attr["speed"] >= 135: logger.info("Relic306 check success") @@ -734,14 +742,18 @@ class Relic311(BaseRelicSetSkill): ): if self.pieces2 and await self.check(base_attr, attribute_bonus): merged_attr = await merge_attribute(base_attr, attribute_bonus) + add_damage_base = 0 if merged_attr["speed"] >= 135: add_damage_base = 0.12000000018626451 if merged_attr["speed"] >= 160: add_damage_base = 0.18000000018626451 - attribute_bonus["AllDamageAddedRatio"] = attribute_bonus.get("AllDamageAddedRatio", 0) + add_damage_base - + attribute_bonus["AllDamageAddedRatio"] = ( + attribute_bonus.get("AllDamageAddedRatio", 0) + add_damage_base + ) + return attribute_bonus + class Relic312(BaseRelicSetSkill): def __init__(self, set_id: int, count: int): super().__init__(set_id, count) @@ -760,10 +772,13 @@ class Relic312(BaseRelicSetSkill): attribute_bonus: Dict[str, float], ): if self.pieces2 and await self.check(base_attr, attribute_bonus): - attribute_bonus["AllDamageAddedRatio"] = attribute_bonus.get("AllDamageAddedRatio", 0) + 0.10000000018626451 - + attribute_bonus["AllDamageAddedRatio"] = ( + attribute_bonus.get("AllDamageAddedRatio", 0) + 0.10000000018626451 + ) + return attribute_bonus + class RelicSet: HEAD: SingleRelic HAND: SingleRelic diff --git a/starrail_damage_cal/damage/Role.py b/starrail_damage_cal/damage/Role.py index d54f9e0..3297117 100644 --- a/starrail_damage_cal/damage/Role.py +++ b/starrail_damage_cal/damage/Role.py @@ -52,6 +52,7 @@ async def calculate_shield( return [defence_num] + async def get_damage( damege: int, base_attr: Dict[str, float], @@ -66,7 +67,7 @@ async def get_damage( add_attr_bonus = apply_attribute_bonus(add_attr_bonus, skill_type, add_skill_type) merged_attr = await merge_attribute(base_attr, add_attr_bonus) - + injury_area, element_area = calculate_injury_area( merged_attr, skill_type, @@ -81,13 +82,20 @@ async def get_damage( expected_damage = calculate_expected_damage(critical_chance, critical_damage) damage_cd = damege * skill_multiplier * injury_area * critical_damage - + damage_qw = damege * skill_multiplier * injury_area * expected_damage - - damage_tz = damege * skill_multiplier * (injury_area + 2.626) * (critical_damage + 1.794) * 10 + + damage_tz = ( + damege + * skill_multiplier + * (injury_area + 2.626) + * (critical_damage + 1.794) + * 10 + ) return [damage_cd, damage_qw, damage_tz] + async def break_damage( base_attr: Dict[str, float], attribute_bonus: Dict[str, float], @@ -97,23 +105,23 @@ async def break_damage( level: int, ): break_element = { - 'Ice': 1, - 'Imaginary': 1, - 'Quantum': 1, - 'Thunder': 2, - 'Wind': 3, - 'Physical': 4, - 'Fire': 5, + "Ice": 1, + "Imaginary": 1, + "Quantum": 1, + "Thunder": 2, + "Wind": 3, + "Physical": 4, + "Fire": 5, } - + add_attr_bonus = copy.deepcopy(attribute_bonus) add_attr_bonus = apply_attribute_bonus(add_attr_bonus, skill_type, add_skill_type) merged_attr = await merge_attribute(base_attr, add_attr_bonus) - - break_atk = 3767.55 #80级敌人击破伤害基数,我也不知道为什么是这个,反正都说是这个 - + + break_atk = 3767.55 # 80级敌人击破伤害基数, 我也不知道为什么是这个, 反正都说是这个 + damage_reduction = calculate_damage_reduction(level) resistance_area = calculate_resistance_area( @@ -124,15 +132,25 @@ async def break_damage( ) defence_multiplier = calculate_defence_multiplier(level, merged_attr) - + damage_ratio = calculate_damage_ratio(merged_attr, skill_type, add_skill_type) - + break_damage = merged_attr.get("BreakDamageAddedRatioBase", 0) + 1 - - damage_cd = break_atk * break_element[element] * 2 * break_damage * damage_ratio * damage_reduction * resistance_area * defence_multiplier + + damage_cd = ( + break_atk + * break_element[element] + * 2 + * break_damage + * damage_ratio + * damage_reduction + * resistance_area + * defence_multiplier + ) return [damage_cd] + async def calculate_damage( base_attr: Dict[str, float], attribute_bonus: Dict[str, float], diff --git a/starrail_damage_cal/damage/Weapon/Weapon.py b/starrail_damage_cal/damage/Weapon/Weapon.py index 2cad957..c8e1b9d 100644 --- a/starrail_damage_cal/damage/Weapon/Weapon.py +++ b/starrail_damage_cal/damage/Weapon/Weapon.py @@ -2261,6 +2261,7 @@ class Mediation(BaseWeapon): ) return attribute_bonus + # 纯粹思维的洗礼 class BaptismofPureThought(BaseWeapon): weapon_base_attributes: Dict @@ -2282,23 +2283,36 @@ class BaptismofPureThought(BaseWeapon): critical_damage_base = attribute_bonus.get("CriticalDamageBase", 0) attribute_bonus["CriticalDamageBase"] = ( critical_damage_base - + (weapon_effect["23020"]["Param"]["CriticalDamageBase"][self.weapon_rank - 1]) + + ( + weapon_effect["23020"]["Param"]["CriticalDamageBase"][ + self.weapon_rank - 1 + ] + ) * 3 ) - + all_damage_added_ratio = attribute_bonus.get("AllDamageAddedRatio", 0) attribute_bonus["AllDamageAddedRatio"] = ( all_damage_added_ratio - + (weapon_effect["23020"]["Param"]["AllDamageAddedRatio"][self.weapon_rank - 1]) + + ( + weapon_effect["23020"]["Param"]["AllDamageAddedRatio"][ + self.weapon_rank - 1 + ] + ) ) - + resistance_penetration = attribute_bonus.get("ignore_defence", 0) attribute_bonus["ignore_defence"] = ( resistance_penetration - + (weapon_effect["23020"]["Param"]["ignore_defence"][self.weapon_rank - 1]) + + ( + weapon_effect["23020"]["Param"]["ignore_defence"][ + self.weapon_rank - 1 + ] + ) ) return attribute_bonus + # 镜中故我 class PastSelfinMirror(BaseWeapon): weapon_base_attributes: Dict @@ -2307,7 +2321,7 @@ class PastSelfinMirror(BaseWeapon): super().__init__(weapon) async def check(self): - # 当装备者施放战技后,使我方全体造成的伤害提高15%,使处于加速状态的我方目标的全属性穿透提高6%,持续3回合。 + # 当装备者施放战技后, 使我方全体造成的伤害提高15%, 使处于加速状态的我方目标的全属性穿透提高6%, 持续3回合。 return True async def weapon_ability( @@ -2320,16 +2334,25 @@ class PastSelfinMirror(BaseWeapon): all_damage_added_ratio = attribute_bonus.get("AllDamageAddedRatio", 0) attribute_bonus["AllDamageAddedRatio"] = ( all_damage_added_ratio - + (weapon_effect["23019"]["Param"]["AllDamageAddedRatio"][self.weapon_rank - 1]) + + ( + weapon_effect["23019"]["Param"]["AllDamageAddedRatio"][ + self.weapon_rank - 1 + ] + ) ) - + resistance_penetration = attribute_bonus.get("ResistancePenetration", 0) attribute_bonus["ResistancePenetration"] = ( resistance_penetration - + (weapon_effect["23019"]["Param"]["ResistancePenetration"][self.weapon_rank - 1]) + + ( + weapon_effect["23019"]["Param"]["ResistancePenetration"][ + self.weapon_rank - 1 + ] + ) ) return attribute_bonus + class Weapon: @classmethod def create(cls, weapon: DamageInstanceWeapon):