mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-05 19:23:45 +08:00
* 完成刃卡芙卡伤害计算
* 完成刃卡芙卡伤害计算
* 🚨 `pre-commit-ci`修复格式错误
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
108 lines
2.6 KiB
Python
108 lines
2.6 KiB
Python
from typing import List, Union
|
|
|
|
import msgspec
|
|
from msgspec import Struct, field
|
|
|
|
|
|
class DamageInstanceSkill(Struct):
|
|
skillId: int
|
|
skillName: str
|
|
skillEffect: str
|
|
skillAttackType: str
|
|
skillLevel: int
|
|
|
|
|
|
class DamageInstanceRelicSubAffix(Struct):
|
|
SubAffixID: int
|
|
Property: str
|
|
Name: str
|
|
Cnt: int
|
|
Step: int
|
|
Value: str
|
|
|
|
|
|
class DamageInstanceRelicMainAffix(Struct):
|
|
AffixID: int
|
|
Property: str
|
|
Name: str
|
|
Value: str
|
|
|
|
|
|
class DamageInstanceRelic(Struct):
|
|
relicId: int
|
|
relicName: str
|
|
SetId: int
|
|
SetName: str
|
|
Type: int
|
|
MainAffix: DamageInstanceRelicMainAffix
|
|
SubAffixList: Union[List[DamageInstanceRelicSubAffix], None]
|
|
Level: int = 0
|
|
|
|
|
|
class DamageInstanceWeapon(Struct):
|
|
id_: str = field(name='id')
|
|
level: int
|
|
rank: int
|
|
promotion: int
|
|
|
|
|
|
class AttributeBounsStatusAdd(Struct):
|
|
property: str
|
|
name: str
|
|
value: float
|
|
|
|
|
|
class DamageInstanceAvatarAttributeBouns(Struct):
|
|
attributeBonusId: int
|
|
attributeBonusLevel: int
|
|
statusAdd: AttributeBounsStatusAdd
|
|
|
|
|
|
class DamageInstanceAvatar(Struct):
|
|
id_: str = field(name='id')
|
|
level: int
|
|
rank: int
|
|
element: str
|
|
promotion: int
|
|
attribute_bonus: Union[List[DamageInstanceAvatarAttributeBouns], None]
|
|
extra_ability: Union[List, None]
|
|
|
|
|
|
class DamageInstance:
|
|
avatar: DamageInstanceAvatar
|
|
weapon: DamageInstanceWeapon
|
|
relic: List[DamageInstanceRelic]
|
|
skill: List[DamageInstanceSkill]
|
|
|
|
def __init__(self, char):
|
|
self.avatar = DamageInstanceAvatar(
|
|
id_=char.char_id,
|
|
level=char.char_level,
|
|
rank=char.char_rank,
|
|
element=char.char_element,
|
|
promotion=char.char_promotion,
|
|
attribute_bonus=msgspec.from_builtins(
|
|
char.attribute_bonus,
|
|
Union[List[DamageInstanceAvatarAttributeBouns], None],
|
|
),
|
|
extra_ability=msgspec.from_builtins(
|
|
char.extra_ability, Union[List, None]
|
|
),
|
|
)
|
|
self.weapon = DamageInstanceWeapon(
|
|
id_=char.equipment['equipmentID'],
|
|
level=char.equipment['equipmentLevel'],
|
|
rank=char.equipment['equipmentRank'],
|
|
promotion=char.equipment['equipmentPromotion'],
|
|
)
|
|
self.relic = []
|
|
for relic in char.char_relic:
|
|
self.relic.append(
|
|
msgspec.from_builtins(relic, DamageInstanceRelic)
|
|
)
|
|
self.skill = []
|
|
for skill in char.char_skill:
|
|
self.skill.append(
|
|
msgspec.from_builtins(skill, DamageInstanceSkill)
|
|
)
|