mirror of
https://github.com/PaiGramTeam/StarRailDamageCal.git
synced 2024-11-16 04:45:43 +00:00
update
This commit is contained in:
parent
5735c0fbcc
commit
211cb186ec
@ -41,7 +41,8 @@ ignore = [
|
||||
"ARG",
|
||||
"COM812",
|
||||
"N801",
|
||||
"ISC"
|
||||
"ISC",
|
||||
"TID252"
|
||||
]
|
||||
line-length = 88
|
||||
target-version = "py38"
|
||||
|
@ -2,19 +2,20 @@ from typing import Dict
|
||||
|
||||
from msgspec import convert
|
||||
|
||||
from starrail_damage_cal.damage.Avatar import AvatarInstance
|
||||
from starrail_damage_cal.exception import (
|
||||
from .damage.Avatar import AvatarInstance
|
||||
from .exception import (
|
||||
CharNameError,
|
||||
MihomoRequestError,
|
||||
NotInCharacterShowcaseError,
|
||||
)
|
||||
from starrail_damage_cal.map.name_covert import alias_to_char_name, name_to_avatar_id
|
||||
from starrail_damage_cal.mihomo.models import MihomoData
|
||||
from starrail_damage_cal.mono.Character import Character
|
||||
from starrail_damage_cal.to_data import api_to_dict
|
||||
from .map.name_covert import alias_to_char_name, name_to_avatar_id
|
||||
from .mihomo.models import MihomoData
|
||||
from .model import MohomoCharacter
|
||||
from .mono.Character import Character
|
||||
from .to_data import api_to_dict
|
||||
|
||||
|
||||
async def cal_char_info(char_data: Dict):
|
||||
async def cal_char_info(char_data: MohomoCharacter):
|
||||
char: Character = Character(char_data)
|
||||
await char.get_equipment_info()
|
||||
await char.get_char_attribute_bonus()
|
||||
@ -22,7 +23,7 @@ async def cal_char_info(char_data: Dict):
|
||||
return char
|
||||
|
||||
|
||||
async def cal_info(char_data: Dict):
|
||||
async def cal_info(char_data: MohomoCharacter):
|
||||
char = await cal_char_info(char_data)
|
||||
avatar = AvatarInstance(char)
|
||||
return await avatar.get_damage_info()
|
||||
@ -41,10 +42,6 @@ async def get_char_data(uid: str, avatar_name: str):
|
||||
msg = "char_id_list is str"
|
||||
raise MihomoRequestError(msg)
|
||||
|
||||
if char_data_dict is None:
|
||||
msg = "char_data_dict is None"
|
||||
raise MihomoRequestError(msg)
|
||||
|
||||
if char_id not in char_id_list:
|
||||
raise NotInCharacterShowcaseError
|
||||
|
||||
@ -52,19 +49,10 @@ async def get_char_data(uid: str, avatar_name: str):
|
||||
|
||||
|
||||
class DamageCal:
|
||||
@classmethod
|
||||
async def cal_info(cls, char_data: Dict):
|
||||
char = Character(char_data)
|
||||
await char.get_equipment_info()
|
||||
await char.get_char_attribute_bonus()
|
||||
await char.get_relic_info()
|
||||
avatar = AvatarInstance(char)
|
||||
return await avatar.get_damage_info()
|
||||
|
||||
@classmethod
|
||||
async def get_damage_data_by_uid(cls, uid: str, avatar_name: str):
|
||||
char_data = await get_char_data(uid, avatar_name)
|
||||
return await cls.cal_info(char_data)
|
||||
return await cal_info(char_data)
|
||||
|
||||
@classmethod
|
||||
async def get_damage_data_by_mihomo_raw(cls, mihomo_raw: Dict, avatar_name: str):
|
||||
@ -89,7 +77,7 @@ class DamageCal:
|
||||
raise NotInCharacterShowcaseError
|
||||
|
||||
char_data = char_data_dict[char_id]
|
||||
return await cls.cal_info(char_data)
|
||||
return await cal_info(char_data)
|
||||
|
||||
@classmethod
|
||||
async def get_all_damage_data_by_mihomo_raw(cls, mihomo_raw: Dict):
|
||||
@ -108,7 +96,7 @@ class DamageCal:
|
||||
|
||||
for char_id in char_id_list:
|
||||
char_data = char_data_dict[char_id]
|
||||
damage_dict[char_id] = await cls.cal_info(char_data)
|
||||
damage_dict[char_id] = await cal_info(char_data)
|
||||
|
||||
return damage_dict
|
||||
|
||||
@ -128,6 +116,6 @@ class DamageCal:
|
||||
|
||||
for char_id in char_id_list:
|
||||
char_data = char_data_dict[char_id]
|
||||
damage_dict[char_id] = await cls.cal_info(char_data)
|
||||
damage_dict[char_id] = await cal_info(char_data)
|
||||
|
||||
return damage_dict
|
||||
|
@ -2,12 +2,13 @@ import json
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
from starrail_damage_cal.damage.AvatarDamage.AvatarDamage import AvatarDamage
|
||||
from starrail_damage_cal.damage.Base.AvatarBase import BaseAvatarinfo
|
||||
from starrail_damage_cal.damage.Base.model import DamageInstance
|
||||
from starrail_damage_cal.damage.Relic.Relic import RelicSet, SingleRelic
|
||||
from starrail_damage_cal.damage.Weapon.Weapon import Weapon
|
||||
from starrail_damage_cal.mono.Character import Character
|
||||
from ..damage.AvatarDamage.AvatarDamage import AvatarDamage
|
||||
from ..damage.Base.AvatarBase import BaseAvatarinfo
|
||||
from ..damage.Base.model import DamageInstance
|
||||
from ..damage.Base.RelicBase import SingleRelic
|
||||
from ..damage.Relic.Relic import RelicSet
|
||||
from ..damage.Weapon.Weapon import Weapon
|
||||
from ..mono.Character import Character
|
||||
|
||||
Excel_path = Path(__file__).parent
|
||||
with Path.open(Excel_path / "Excel" / "SkillData.json", encoding="utf-8") as f:
|
||||
@ -109,8 +110,5 @@ class AvatarInstance:
|
||||
self.base_attr,
|
||||
self.attribute_bonus,
|
||||
)
|
||||
if self.attribute_bonus is None:
|
||||
msg = "attribute_bonus is None"
|
||||
raise Exception(msg) # noqa: TRY002
|
||||
|
||||
return await self.avatardamage.getdamage(self.base_attr, self.attribute_bonus)
|
||||
|
@ -1,24 +1,24 @@
|
||||
import copy
|
||||
from typing import Dict, List
|
||||
|
||||
from starrail_damage_cal.damage.Base.AvatarBase import BaseAvatar, BaseAvatarBuff
|
||||
from starrail_damage_cal.damage.Base.model import (
|
||||
from ...damage.Base.AvatarBase import BaseAvatar, BaseAvatarBuff
|
||||
from ...damage.Base.model import (
|
||||
DamageInstanceAvatar,
|
||||
DamageInstanceSkill,
|
||||
)
|
||||
from starrail_damage_cal.damage.Role import (
|
||||
from ...damage.Role import (
|
||||
break_damage,
|
||||
calculate_damage,
|
||||
calculate_heal,
|
||||
calculate_shield,
|
||||
)
|
||||
from starrail_damage_cal.logger import logger
|
||||
from ...logger import logger
|
||||
from ...model import MohomoAvatarSkill
|
||||
|
||||
|
||||
class Seele(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -118,7 +118,7 @@ class Seele(BaseAvatar):
|
||||
class JingYuan(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -210,7 +210,7 @@ class JingYuan(BaseAvatar):
|
||||
class Welt(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -319,7 +319,7 @@ class Welt(BaseAvatar):
|
||||
class Danhengil(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -534,7 +534,7 @@ class Danhengil(BaseAvatar):
|
||||
class Argenti(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -646,7 +646,7 @@ class Argenti(BaseAvatar):
|
||||
class Clara(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -775,7 +775,7 @@ class Clara(BaseAvatar):
|
||||
class Silverwolf(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -857,7 +857,7 @@ class Silverwolf(BaseAvatar):
|
||||
class Kafka(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -955,7 +955,7 @@ class Kafka(BaseAvatar):
|
||||
class Blade(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1100,7 +1100,7 @@ class Blade(BaseAvatar):
|
||||
class Fuxuan(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1177,7 +1177,7 @@ class Fuxuan(BaseAvatar):
|
||||
class Yanqing(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1272,7 +1272,7 @@ class Yanqing(BaseAvatar):
|
||||
class Himeko(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1359,7 +1359,7 @@ class Himeko(BaseAvatar):
|
||||
class Qingque(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1437,7 +1437,7 @@ class Qingque(BaseAvatar):
|
||||
class Jingliu(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1542,7 +1542,7 @@ class Jingliu(BaseAvatar):
|
||||
class Topaz(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1627,7 +1627,7 @@ class Topaz(BaseAvatar):
|
||||
class Guinaifen(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1717,7 +1717,7 @@ class Guinaifen(BaseAvatar):
|
||||
class Gepard(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1782,7 +1782,7 @@ class Gepard(BaseAvatar):
|
||||
class Luocha(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -1909,7 +1909,7 @@ class Luocha(BaseAvatar):
|
||||
class Bailu(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2005,7 +2005,7 @@ class Bailu(BaseAvatar):
|
||||
class Lynx(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2120,7 +2120,7 @@ class Lynx(BaseAvatar):
|
||||
class Natasha(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2214,7 +2214,7 @@ class Natasha(BaseAvatar):
|
||||
class Mar7th(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2310,7 +2310,7 @@ class Mar7th(BaseAvatar):
|
||||
class Bronya(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2374,7 +2374,7 @@ class Bronya(BaseAvatar):
|
||||
class Yukong(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2455,7 +2455,7 @@ class Yukong(BaseAvatar):
|
||||
class Sushang(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2559,7 +2559,7 @@ class Sushang(BaseAvatar):
|
||||
class Luka(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2674,7 +2674,7 @@ class Luka(BaseAvatar):
|
||||
class DanHeng(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2751,7 +2751,7 @@ class DanHeng(BaseAvatar):
|
||||
class Arlan(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2826,7 +2826,7 @@ class Arlan(BaseAvatar):
|
||||
class Asta(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2895,7 +2895,7 @@ class Asta(BaseAvatar):
|
||||
class Herta(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -2984,7 +2984,7 @@ class Herta(BaseAvatar):
|
||||
class Serval(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3078,7 +3078,7 @@ class Serval(BaseAvatar):
|
||||
class Pela(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3167,7 +3167,7 @@ class Pela(BaseAvatar):
|
||||
class Sampo(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3257,7 +3257,7 @@ class Sampo(BaseAvatar):
|
||||
class Hook(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3366,7 +3366,7 @@ class Hook(BaseAvatar):
|
||||
class Tingyun(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3420,7 +3420,7 @@ class Tingyun(BaseAvatar):
|
||||
class Trailblazer(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3508,7 +3508,7 @@ class Trailblazer(BaseAvatar):
|
||||
class Trailblazer_K(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3633,7 +3633,7 @@ class Trailblazer_K(BaseAvatar):
|
||||
class Huohuo(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3737,7 +3737,7 @@ class Huohuo(BaseAvatar):
|
||||
class Hanya(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3814,7 +3814,7 @@ class Hanya(BaseAvatar):
|
||||
class DrRatio(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -3913,7 +3913,7 @@ class DrRatio(BaseAvatar):
|
||||
class RuanMei(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -4011,7 +4011,7 @@ class RuanMei(BaseAvatar):
|
||||
class XueYi(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -4105,7 +4105,7 @@ class XueYi(BaseAvatar):
|
||||
class BlackSwan(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -4217,7 +4217,7 @@ class BlackSwan(BaseAvatar):
|
||||
class Sparkle(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -4287,7 +4287,7 @@ class Sparkle(BaseAvatar):
|
||||
class Acheron(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -4444,7 +4444,7 @@ class Acheron(BaseAvatar):
|
||||
class Aventurine(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -4557,7 +4557,7 @@ class Aventurine(BaseAvatar):
|
||||
class Gallagher(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -4657,7 +4657,7 @@ class Gallagher(BaseAvatar):
|
||||
class Robin(BaseAvatar):
|
||||
Buff: BaseAvatarBuff
|
||||
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
super().__init__(char=char, skills=skills)
|
||||
self.eidolon_attribute: Dict[str, float] = {}
|
||||
self.extra_ability_attribute: Dict[str, float] = {}
|
||||
@ -4745,7 +4745,7 @@ class Robin(BaseAvatar):
|
||||
|
||||
class AvatarDamage:
|
||||
@classmethod
|
||||
def create(cls, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def create(cls, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
if char.id_ == 1214:
|
||||
return XueYi(char, skills)
|
||||
if char.id_ == 1306:
|
||||
|
@ -6,12 +6,12 @@ from typing import List, Tuple, Union
|
||||
import msgspec
|
||||
from msgspec import Struct
|
||||
|
||||
from starrail_damage_cal.damage.Base.model import (
|
||||
from ...damage.Base.model import (
|
||||
DamageInstanceAvatar,
|
||||
DamageInstanceSkill,
|
||||
)
|
||||
from starrail_damage_cal.damage.Base.SkillBase import BaseSkills
|
||||
from starrail_damage_cal.excel.model import AvatarPromotionConfig
|
||||
from ...damage.Base.SkillBase import BaseSkills
|
||||
from ...excel.model import AvatarPromotionConfig
|
||||
from ...model import MohomoAvatarSkill
|
||||
|
||||
path = Path(__file__).parent.parent
|
||||
with Path.open(path / "Excel" / "SkillData.json", encoding="utf-8") as f:
|
||||
@ -41,11 +41,11 @@ class BaseAvatarAttribute(Struct):
|
||||
|
||||
class BaseAvatarBuff:
|
||||
@classmethod
|
||||
def create(cls, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
cls.extra_ability_id = []
|
||||
def create(cls, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
cls.extra_ability_id: List[int] = []
|
||||
if char.extra_ability:
|
||||
for extra_ability in char.extra_ability:
|
||||
cls.extra_ability_id.append(extra_ability["extraAbilityId"])
|
||||
cls.extra_ability_id.append(extra_ability.extraAbilityId)
|
||||
return cls
|
||||
|
||||
@abstractmethod
|
||||
@ -111,7 +111,7 @@ class BaseAvatarinfo:
|
||||
|
||||
|
||||
class BaseAvatar:
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def __init__(self, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
self.Skill = BaseSkills.create(char=char, skills=skills)
|
||||
self.Buff = BaseAvatarBuff.create(char=char, skills=skills)
|
||||
self.avatar_id = char.id_
|
||||
|
@ -1,14 +1,14 @@
|
||||
from abc import abstractmethod
|
||||
from typing import Dict
|
||||
|
||||
from starrail_damage_cal.damage.Base.model import DamageInstanceRelic
|
||||
from starrail_damage_cal.logger import logger
|
||||
from starrail_damage_cal.map.model.RelicSetSkill import RelicSetStatusAdd
|
||||
from starrail_damage_cal.map.SR_MAP_PATH import RelicSetSkill
|
||||
from ...logger import logger
|
||||
from ...map.model.RelicSetSkill import RelicSetStatusAdd
|
||||
from ...map.SR_MAP_PATH import RelicSetSkill
|
||||
from ...model import Relic
|
||||
|
||||
|
||||
class SingleRelic:
|
||||
def __init__(self, relic: DamageInstanceRelic):
|
||||
def __init__(self, relic: Relic):
|
||||
self.raw_relic = relic
|
||||
self.relic_id = relic.relicId
|
||||
self.set_id = relic.SetId
|
||||
|
@ -2,10 +2,10 @@ import json
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
from starrail_damage_cal.damage.Base.model import (
|
||||
from ...damage.Base.model import (
|
||||
DamageInstanceAvatar,
|
||||
DamageInstanceSkill,
|
||||
)
|
||||
from ...model import MohomoAvatarSkill
|
||||
|
||||
path = Path(__file__).parent.parent
|
||||
with Path.open(path / "Excel" / "SkillData.json", encoding="utf-8") as f:
|
||||
@ -22,7 +22,7 @@ skill_types = {
|
||||
|
||||
|
||||
class SingleSkill:
|
||||
def __init__(self, skill: DamageInstanceSkill):
|
||||
def __init__(self, skill: MohomoAvatarSkill):
|
||||
self.id = skill.skillId
|
||||
self.level = skill.skillLevel
|
||||
|
||||
@ -35,7 +35,7 @@ class BaseSkills:
|
||||
Talent_: SingleSkill
|
||||
|
||||
@classmethod
|
||||
def create(cls, char: DamageInstanceAvatar, skills: List[DamageInstanceSkill]):
|
||||
def create(cls, char: DamageInstanceAvatar, skills: List[MohomoAvatarSkill]):
|
||||
for skill in skills:
|
||||
skill_attack_type = skill.skillAttackType
|
||||
if skill_attack_type not in skill_types:
|
||||
|
@ -3,9 +3,9 @@ from typing import Dict, List, Tuple
|
||||
|
||||
from msgspec import Struct
|
||||
|
||||
from starrail_damage_cal.damage.Base.model import DamageInstanceWeapon
|
||||
from starrail_damage_cal.excel.model import EquipmentPromotionConfig
|
||||
from starrail_damage_cal.map.SR_MAP_PATH import EquipmentID2AbilityProperty
|
||||
from ...damage.Base.model import DamageInstanceWeapon
|
||||
from ...excel.model import EquipmentPromotionConfig
|
||||
from ...map.SR_MAP_PATH import EquipmentID2AbilityProperty
|
||||
|
||||
|
||||
class BaseWeaponAttribute(Struct):
|
||||
@ -29,7 +29,6 @@ class BaseWeapon:
|
||||
self.weapon_promotion = weapon.promotion
|
||||
self.weapon_base_attribute = self.get_attribute()
|
||||
self.weapon_attribute: Dict[str, float] = {}
|
||||
self.get_attribute()
|
||||
self.weapon_property_ability()
|
||||
|
||||
@abstractmethod
|
||||
@ -57,7 +56,7 @@ class BaseWeapon:
|
||||
def get_attribute(self):
|
||||
promotion = None
|
||||
for equipment in EquipmentPromotionConfig:
|
||||
if equipment.EquipmentID == self.weapon_id:
|
||||
if equipment.EquipmentID == int(self.weapon_id):
|
||||
promotion = equipment
|
||||
break
|
||||
if not promotion:
|
||||
|
@ -1,107 +1,54 @@
|
||||
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: float
|
||||
|
||||
|
||||
class DamageInstanceRelicMainAffix(Struct):
|
||||
AffixID: int
|
||||
Property: str
|
||||
Name: str
|
||||
Value: float
|
||||
|
||||
|
||||
class DamageInstanceRelic(Struct):
|
||||
relicId: int
|
||||
relicName: str
|
||||
SetId: int
|
||||
SetName: str
|
||||
Type: int
|
||||
MainAffix: DamageInstanceRelicMainAffix
|
||||
SubAffixList: Union[List[DamageInstanceRelicSubAffix], None]
|
||||
Level: int = 0
|
||||
from ...model import (
|
||||
MohomoAvatarAttributeBonus,
|
||||
MohomoAvatarExtraAbility,
|
||||
MohomoAvatarSkill,
|
||||
Relic,
|
||||
)
|
||||
from ...mono.Character import Character
|
||||
|
||||
|
||||
class DamageInstanceWeapon(Struct):
|
||||
id_: str = field(name="id")
|
||||
id_: int = field(name="id")
|
||||
level: int
|
||||
rank: int
|
||||
promotion: int
|
||||
|
||||
|
||||
class AttributeBounsStatusAdd(Struct):
|
||||
property_: str = field(name="property")
|
||||
name: str
|
||||
value: float
|
||||
|
||||
|
||||
class DamageInstanceAvatarAttributeBouns(Struct):
|
||||
attributeBonusId: int
|
||||
attributeBonusLevel: int
|
||||
statusAdd: AttributeBounsStatusAdd
|
||||
|
||||
|
||||
class DamageInstanceAvatar(Struct):
|
||||
id_: str = field(name="id")
|
||||
id_: int = field(name="id")
|
||||
level: int
|
||||
rank: int
|
||||
element: str
|
||||
promotion: int
|
||||
attribute_bonus: Union[List[DamageInstanceAvatarAttributeBouns], None]
|
||||
extra_ability: Union[List, None]
|
||||
attribute_bonus: List[MohomoAvatarAttributeBonus]
|
||||
extra_ability: List[MohomoAvatarExtraAbility]
|
||||
|
||||
|
||||
class DamageInstance:
|
||||
avatar: DamageInstanceAvatar
|
||||
weapon: Union[DamageInstanceWeapon, None]
|
||||
relic: List[DamageInstanceRelic]
|
||||
skill: List[DamageInstanceSkill]
|
||||
relic: List[Relic]
|
||||
skill: List[MohomoAvatarSkill]
|
||||
|
||||
def __init__(self, char):
|
||||
def __init__(self, char: Character):
|
||||
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.convert(
|
||||
char.attribute_bonus,
|
||||
Union[List[DamageInstanceAvatarAttributeBouns], None],
|
||||
),
|
||||
extra_ability=msgspec.convert(
|
||||
char.extra_ability,
|
||||
Union[List, None],
|
||||
),
|
||||
attribute_bonus=char.attribute_bonus,
|
||||
extra_ability=char.extra_ability,
|
||||
)
|
||||
if char.equipment.get("equipmentID") is not None:
|
||||
self.weapon = DamageInstanceWeapon(
|
||||
id_=char.equipment["equipmentID"],
|
||||
level=char.equipment["equipmentLevel"],
|
||||
rank=char.equipment["equipmentRank"],
|
||||
promotion=char.equipment["equipmentPromotion"],
|
||||
)
|
||||
else:
|
||||
self.weapon = None
|
||||
self.relic = []
|
||||
for relic in char.char_relic:
|
||||
self.relic.append(msgspec.convert(relic, DamageInstanceRelic))
|
||||
self.skill = []
|
||||
for skill in char.char_skill:
|
||||
self.skill.append(msgspec.convert(skill, DamageInstanceSkill))
|
||||
self.weapon = DamageInstanceWeapon(
|
||||
id_=char.equipment.equipmentID,
|
||||
level=char.equipment.equipmentLevel,
|
||||
rank=char.equipment.equipmentRank,
|
||||
promotion=char.equipment.equipmentPromotion,
|
||||
)
|
||||
self.relic = char.char_relic
|
||||
self.skill = char.char_skill
|
||||
|
@ -1,10 +1,10 @@
|
||||
from collections import Counter
|
||||
from typing import Dict, List, Union
|
||||
|
||||
from starrail_damage_cal.damage.Base.model import DamageInstanceRelic
|
||||
from starrail_damage_cal.damage.Base.RelicBase import BaseRelicSetSkill, SingleRelic
|
||||
from starrail_damage_cal.damage.utils import merge_attribute
|
||||
from starrail_damage_cal.logger import logger
|
||||
from ...damage.Base.RelicBase import BaseRelicSetSkill, SingleRelic
|
||||
from ...damage.utils import merge_attribute
|
||||
from ...logger import logger
|
||||
from ...model import Relic
|
||||
|
||||
|
||||
class Relic101(BaseRelicSetSkill):
|
||||
@ -941,7 +941,7 @@ class RelicSet:
|
||||
]
|
||||
]
|
||||
|
||||
def create(self, relic_list: List[DamageInstanceRelic]):
|
||||
def create(self, relic_list: List[Relic]):
|
||||
set_id_list: List[int] = []
|
||||
for relic in relic_list:
|
||||
set_id_list.append(relic.SetId)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import copy
|
||||
from typing import Dict
|
||||
|
||||
from starrail_damage_cal.damage.utils import merge_attribute
|
||||
from ..damage.utils import merge_attribute
|
||||
|
||||
|
||||
async def calculate_heal(
|
||||
@ -10,7 +10,7 @@ async def calculate_heal(
|
||||
skill_type: str,
|
||||
skill_multiplier: float,
|
||||
skill_num: float,
|
||||
is_atk=0,
|
||||
is_atk: int = 0,
|
||||
):
|
||||
add_attr_bonus = copy.deepcopy(attribute_bonus)
|
||||
merged_attr = await merge_attribute(base_attr, add_attr_bonus)
|
||||
@ -34,7 +34,7 @@ async def calculate_shield(
|
||||
attribute_bonus: Dict[str, float],
|
||||
skill_multiplier: float,
|
||||
skill_num: float,
|
||||
is_atk=0,
|
||||
is_atk: int = 0,
|
||||
):
|
||||
add_attr_bonus = copy.deepcopy(attribute_bonus)
|
||||
merged_attr = await merge_attribute(base_attr, add_attr_bonus)
|
||||
@ -155,7 +155,7 @@ async def calculate_damage(
|
||||
element: str,
|
||||
skill_multiplier: float,
|
||||
level: int,
|
||||
is_hp=0,
|
||||
is_hp: int=0,
|
||||
):
|
||||
add_attr_bonus = copy.deepcopy(attribute_bonus)
|
||||
|
||||
@ -439,7 +439,7 @@ async def calculate_damage_tz(
|
||||
skill_type: str,
|
||||
add_skill_type: str,
|
||||
element: str,
|
||||
is_hp=0,
|
||||
is_hp:int=0,
|
||||
):
|
||||
add_attr_bonus_tz = copy.deepcopy(add_attr_bonus)
|
||||
add_attr_bonus_tz["AttackAddedRatio"] = (
|
||||
|
@ -2,8 +2,8 @@ import json
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
from starrail_damage_cal.damage.Base.model import DamageInstanceWeapon
|
||||
from starrail_damage_cal.damage.Base.WeaponBase import BaseWeapon
|
||||
from ...damage.Base.model import DamageInstanceWeapon
|
||||
from ...damage.Base.WeaponBase import BaseWeapon
|
||||
|
||||
path = Path(__file__).parent.parent
|
||||
with Path.open(path / "Excel" / "weapon_effect.json", encoding="utf-8") as f:
|
||||
|
@ -1,7 +1,7 @@
|
||||
from typing import Dict
|
||||
|
||||
from starrail_damage_cal.excel.model import RelicMainAffixConfig, RelicSubAffixConfig
|
||||
from starrail_damage_cal.map.SR_MAP_PATH import RelicId2MainAffixGroup
|
||||
from ..excel.model import RelicMainAffixConfig, RelicSubAffixConfig
|
||||
from ..map.SR_MAP_PATH import RelicId2MainAffixGroup
|
||||
|
||||
|
||||
async def cal_relic_main_affix(
|
||||
@ -11,7 +11,7 @@ async def cal_relic_main_affix(
|
||||
relic_type: int,
|
||||
relic_level: int,
|
||||
):
|
||||
if set_id[0] == 3:
|
||||
if set_id[0] == "3":
|
||||
rarity = int(str(relic_id)[0]) - 1
|
||||
group_id = str(rarity) + str(relic_type)
|
||||
else:
|
||||
|
@ -2,7 +2,7 @@ from typing import List, Union
|
||||
|
||||
from msgspec import Struct, convert
|
||||
|
||||
from starrail_damage_cal.excel.read_excel import (
|
||||
from ..excel.read_excel import (
|
||||
AvatarPromotion,
|
||||
EquipmentPromotion,
|
||||
RelicMainAffix,
|
||||
|
@ -4,8 +4,8 @@ from typing import Dict, List, TypedDict, Union
|
||||
|
||||
from msgspec import json as msgjson
|
||||
|
||||
from starrail_damage_cal.map.model.RelicSetSkill import RelicSetSkillModel
|
||||
from starrail_damage_cal.version import StarRail_version
|
||||
from ..map.model.RelicSetSkill import RelicSetSkillModel
|
||||
from ..version import StarRail_version
|
||||
|
||||
MAP = Path(__file__).parent / "data"
|
||||
|
||||
|
@ -7,12 +7,12 @@ import msgspec
|
||||
from httpx import AsyncClient
|
||||
from msgspec import convert
|
||||
|
||||
from starrail_damage_cal.exception import (
|
||||
from ..exception import (
|
||||
InvalidUidError,
|
||||
MihomoModelError,
|
||||
MihomoQueueTimeoutError,
|
||||
)
|
||||
from starrail_damage_cal.mihomo.models import MihomoData
|
||||
from ..mihomo.models import MihomoData
|
||||
|
||||
_HEADER = {"User-Agent": "StarRailDamageCal/"}
|
||||
|
||||
@ -31,7 +31,7 @@ async def get_char_card_info(
|
||||
path = save_path / str(uid)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
with Path.open(path / f"{uid!s}.json", "w") as file:
|
||||
_= file.write(req.text)
|
||||
_ = file.write(req.text)
|
||||
try:
|
||||
return convert(req.json(), type=MihomoData)
|
||||
except msgspec.ValidationError as e:
|
||||
|
106
starrail_damage_cal/model.py
Normal file
106
starrail_damage_cal/model.py
Normal file
@ -0,0 +1,106 @@
|
||||
from typing import List, Union
|
||||
|
||||
from msgspec import Struct, field
|
||||
|
||||
|
||||
class MohomoAvatarSkill(Struct):
|
||||
skillId: int
|
||||
skillName: str
|
||||
skillEffect: str
|
||||
skillAttackType: str
|
||||
skillLevel: int
|
||||
|
||||
|
||||
class MohomoAvatarExtraAbility(Struct):
|
||||
extraAbilityId: int
|
||||
extraAbilityLevel: int
|
||||
|
||||
|
||||
class AttributeBounsStatusAdd(Struct):
|
||||
property_: str = field(name="property")
|
||||
name: str
|
||||
value: float
|
||||
|
||||
|
||||
class MohomoAvatarAttributeBonus(Struct):
|
||||
attributeBonusId: int
|
||||
attributeBonusLevel: int
|
||||
statusAdd: AttributeBounsStatusAdd
|
||||
|
||||
|
||||
class RelicMainAffix(Struct):
|
||||
AffixID: int
|
||||
Property: str
|
||||
Name: str
|
||||
Value: float
|
||||
|
||||
|
||||
class RelicSubAffix(Struct):
|
||||
SubAffixID: int
|
||||
Property: str
|
||||
Name: str
|
||||
Cnt: int
|
||||
Step: int
|
||||
Value: float
|
||||
|
||||
|
||||
class Relic(Struct):
|
||||
relicId: int
|
||||
relicName: str
|
||||
SetId: int
|
||||
SetName: str
|
||||
Type: int
|
||||
MainAffix: RelicMainAffix
|
||||
SubAffixList: List[RelicSubAffix]
|
||||
Level: int = 0
|
||||
|
||||
|
||||
class AvatarBaseAttributes(Struct):
|
||||
hp: float
|
||||
attack: float
|
||||
defence: float
|
||||
CriticalChanceBase: float
|
||||
CriticalDamageBase: float
|
||||
speed: float
|
||||
BaseAggro: float
|
||||
|
||||
|
||||
class EquipmentBaseAttributes(Struct):
|
||||
hp: float
|
||||
attack: float
|
||||
defence: float
|
||||
|
||||
|
||||
class AvatarEquipmentInfo(Struct):
|
||||
equipmentID: int
|
||||
equipmentName: str
|
||||
equipmentLevel: int
|
||||
equipmentPromotion: int
|
||||
equipmentRank: int
|
||||
equipmentRarity: int
|
||||
baseAttributes: EquipmentBaseAttributes
|
||||
|
||||
|
||||
class RankData(Struct):
|
||||
rankId: int
|
||||
rankName: str
|
||||
|
||||
|
||||
class MohomoCharacter(Struct):
|
||||
uid: str
|
||||
nickName: str
|
||||
avatarId: int
|
||||
avatarName: str
|
||||
avatarElement: str
|
||||
avatarRarity: str
|
||||
avatarLevel: int
|
||||
avatarPromotion: int
|
||||
avatarSkill: List[MohomoAvatarSkill]
|
||||
avatarExtraAbility: List[MohomoAvatarExtraAbility]
|
||||
avatarAttributeBonus: List[MohomoAvatarAttributeBonus]
|
||||
RelicInfo: List[Relic]
|
||||
avatarEnName: str
|
||||
baseAttributes: AvatarBaseAttributes
|
||||
equipmentInfo: AvatarEquipmentInfo
|
||||
rank: int
|
||||
rankList: List[RankData]
|
@ -1,45 +1,44 @@
|
||||
from collections import Counter
|
||||
from typing import Dict, List
|
||||
from typing import List
|
||||
|
||||
from starrail_damage_cal.map.SR_MAP_PATH import (
|
||||
from ..map.SR_MAP_PATH import (
|
||||
EquipmentID2AbilityProperty,
|
||||
RelicSetSkill,
|
||||
)
|
||||
from ..model import MohomoCharacter
|
||||
|
||||
|
||||
class Character:
|
||||
def __init__(self, card_prop: Dict):
|
||||
self.char_level: int = int(card_prop["avatarLevel"])
|
||||
self.char_id: int = card_prop["avatarId"]
|
||||
self.char_name: str = card_prop["avatarName"]
|
||||
self.char_rank = card_prop["rank"] if card_prop.get("rank") else 0
|
||||
self.char_rarity = card_prop["avatarRarity"]
|
||||
self.char_element = card_prop["avatarElement"]
|
||||
self.char_promotion = card_prop["avatarPromotion"]
|
||||
self.char_skill = card_prop["avatarSkill"]
|
||||
self.extra_ability = card_prop["avatarExtraAbility"]
|
||||
self.attribute_bonus = card_prop["avatarAttributeBonus"]
|
||||
self.char_relic = card_prop["RelicInfo"]
|
||||
self.base_attributes = card_prop["baseAttributes"]
|
||||
def __init__(self, card_prop: MohomoCharacter):
|
||||
self.char_level = card_prop.avatarLevel
|
||||
self.char_id = card_prop.avatarId
|
||||
self.char_name = card_prop.avatarName
|
||||
self.char_rank = card_prop.rank
|
||||
self.char_rarity = card_prop.avatarRarity
|
||||
self.char_element = card_prop.avatarElement
|
||||
self.char_promotion = card_prop.avatarPromotion
|
||||
self.char_skill = card_prop.avatarSkill
|
||||
self.extra_ability = card_prop.avatarExtraAbility
|
||||
self.attribute_bonus = card_prop.avatarAttributeBonus
|
||||
self.char_relic = card_prop.RelicInfo
|
||||
self.base_attributes = card_prop.baseAttributes
|
||||
self.add_attr = {}
|
||||
self.equipment = card_prop["equipmentInfo"]
|
||||
self.rarity = card_prop["avatarRarity"]
|
||||
self.eidolons = card_prop["rankList"] if card_prop.get("rankList") else []
|
||||
self.equipment = card_prop.equipmentInfo
|
||||
self.rarity = card_prop.avatarRarity
|
||||
self.eidolons = card_prop.rankList
|
||||
|
||||
async def get_equipment_info(self):
|
||||
if self.equipment == {}:
|
||||
return None
|
||||
base_attr = self.base_attributes
|
||||
equip = self.equipment
|
||||
ability_property = EquipmentID2AbilityProperty[str(equip["equipmentID"])]
|
||||
equip_rank = equip["equipmentRank"]
|
||||
ability_property = EquipmentID2AbilityProperty[str(equip.equipmentID)]
|
||||
equip_rank = equip.equipmentRank
|
||||
|
||||
equip_ability_property = ability_property[str(equip_rank)]
|
||||
|
||||
equip_add_base_attr = equip["baseAttributes"]
|
||||
base_attr["hp"] = base_attr["hp"] + equip_add_base_attr["hp"]
|
||||
base_attr["attack"] = base_attr["attack"] + equip_add_base_attr["attack"]
|
||||
base_attr["defence"] = base_attr["defence"] + equip_add_base_attr["defence"]
|
||||
equip_add_base_attr = equip.baseAttributes
|
||||
base_attr.hp = base_attr.hp + equip_add_base_attr.hp
|
||||
base_attr.attack = base_attr.attack + equip_add_base_attr.attack
|
||||
base_attr.defence = base_attr.defence + equip_add_base_attr.defence
|
||||
self.base_attributes = base_attr
|
||||
|
||||
for equip_ability in equip_ability_property:
|
||||
@ -51,27 +50,27 @@ class Character:
|
||||
async def get_char_attribute_bonus(self):
|
||||
attribute_bonus = self.attribute_bonus
|
||||
for bonus in attribute_bonus:
|
||||
status_add = bonus["statusAdd"]
|
||||
bonus_property = status_add["property"]
|
||||
value = status_add["value"]
|
||||
status_add = bonus.statusAdd
|
||||
bonus_property = status_add.property_
|
||||
value = status_add.value
|
||||
self.add_attr[bonus_property] = value + self.add_attr.get(bonus_property, 0)
|
||||
|
||||
async def get_relic_info(self):
|
||||
# 计算圣遗物效果
|
||||
set_id_list: List[int] = []
|
||||
for relic in self.char_relic:
|
||||
set_id_list.append(relic["SetId"])
|
||||
set_id_list.append(relic.SetId)
|
||||
# 处理主属性
|
||||
relic_property = relic["MainAffix"]["Property"]
|
||||
property_value = relic["MainAffix"]["Value"]
|
||||
relic_property = relic.MainAffix.Property
|
||||
property_value = relic.MainAffix.Value
|
||||
self.add_attr[relic_property] = property_value + self.add_attr.get(
|
||||
relic_property,
|
||||
0,
|
||||
)
|
||||
# 处理副词条
|
||||
for sub in relic["SubAffixList"]:
|
||||
sub_property = sub["Property"]
|
||||
sub_value = sub["Value"]
|
||||
for sub in relic.SubAffixList:
|
||||
sub_property = sub.Property
|
||||
sub_value = sub.Value
|
||||
self.add_attr[sub_property] = sub_value + self.add_attr.get(
|
||||
sub_property,
|
||||
0,
|
||||
|
@ -1,18 +1,18 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Tuple, Union
|
||||
from typing import Dict, List, Tuple, Union
|
||||
|
||||
from msgspec import json as msgjson
|
||||
|
||||
from starrail_damage_cal.damage.utils import cal_relic_main_affix, cal_relic_sub_affix
|
||||
from starrail_damage_cal.excel.model import (
|
||||
from .damage.utils import cal_relic_main_affix, cal_relic_sub_affix
|
||||
from .excel.model import (
|
||||
AvatarPromotionConfig,
|
||||
EquipmentPromotionConfig,
|
||||
)
|
||||
from starrail_damage_cal.exception import (
|
||||
from .exception import (
|
||||
CharacterShowcaseNotOpenError,
|
||||
)
|
||||
from starrail_damage_cal.map.SR_MAP_PATH import (
|
||||
from .map.SR_MAP_PATH import (
|
||||
AvatarRankSkillUp,
|
||||
EquipmentID2Name,
|
||||
EquipmentID2Rarity,
|
||||
@ -30,23 +30,29 @@ from starrail_damage_cal.map.SR_MAP_PATH import (
|
||||
skillId2Effect,
|
||||
skillId2Name,
|
||||
)
|
||||
from starrail_damage_cal.mihomo.models import Avatar, MihomoData
|
||||
from starrail_damage_cal.mihomo.requests import get_char_card_info
|
||||
|
||||
|
||||
async def api_to_model(
|
||||
uid: Union[str, None] = None,
|
||||
mihomo_raw: Union[MihomoData, None] = None,
|
||||
save_path: Union[Path, None] = None,
|
||||
) -> Tuple[List[str], List[Dict[str, Any]]]:
|
||||
pass
|
||||
from .mihomo.models import Avatar, MihomoData
|
||||
from .mihomo.requests import get_char_card_info
|
||||
from .model import (
|
||||
AttributeBounsStatusAdd,
|
||||
AvatarBaseAttributes,
|
||||
AvatarEquipmentInfo,
|
||||
EquipmentBaseAttributes,
|
||||
MohomoAvatarAttributeBonus,
|
||||
MohomoAvatarExtraAbility,
|
||||
MohomoAvatarSkill,
|
||||
MohomoCharacter,
|
||||
RankData,
|
||||
Relic,
|
||||
RelicMainAffix,
|
||||
RelicSubAffix,
|
||||
)
|
||||
|
||||
|
||||
async def api_to_dict(
|
||||
uid: Union[str, None] = None,
|
||||
mihomo_raw: Union[MihomoData, None] = None,
|
||||
save_path: Union[Path, None] = None,
|
||||
) -> Tuple[List[str], Dict[str, Dict[str, Any]]]:
|
||||
) -> Tuple[List[str], Dict[str, MohomoCharacter]]:
|
||||
if not mihomo_raw:
|
||||
if not uid:
|
||||
raise KeyError
|
||||
@ -68,7 +74,7 @@ async def api_to_dict(
|
||||
|
||||
char_name_list: List[str] = []
|
||||
char_id_list: List[str] = []
|
||||
char_data_list: Dict[str, Dict] = {}
|
||||
char_data_list: Dict[str, MohomoCharacter] = {}
|
||||
nickName = PlayerDetailInfo.nickname
|
||||
avatarList = (
|
||||
PlayerDetailInfo.avatarDetailList if PlayerDetailInfo.avatarDetailList else []
|
||||
@ -94,137 +100,189 @@ async def api_to_dict(
|
||||
|
||||
async def get_data(
|
||||
char: Avatar, nick_name: str, uid: str, save_path: Union[Path, None] = None
|
||||
):
|
||||
) -> Tuple[MohomoCharacter, str]:
|
||||
# 处理基本信息
|
||||
char_data = {
|
||||
"uid": uid,
|
||||
"nickName": nick_name,
|
||||
"avatarId": char.avatarId,
|
||||
"avatarName": avatarId2Name[str(char.avatarId)],
|
||||
"avatarElement": avatarId2DamageType[str(char.avatarId)],
|
||||
"avatarRarity": avatarId2Rarity[str(char.avatarId)],
|
||||
"avatarPromotion": char.promotion,
|
||||
"avatarLevel": char.level,
|
||||
"avatarSkill": [],
|
||||
"avatarExtraAbility": [],
|
||||
"avatarAttributeBonus": [],
|
||||
"RelicInfo": [],
|
||||
}
|
||||
avatarName = avatarId2Name[str(char.avatarId)]
|
||||
char_data["avatarEnName"] = avatarId2EnName[str(char.avatarId)]
|
||||
char_data = MohomoCharacter(
|
||||
uid=uid,
|
||||
nickName=nick_name,
|
||||
avatarId=char.avatarId,
|
||||
avatarName=avatarId2Name[str(char.avatarId)],
|
||||
avatarElement=avatarId2DamageType[str(char.avatarId)],
|
||||
avatarRarity=avatarId2Rarity[str(char.avatarId)],
|
||||
avatarPromotion=char.promotion if char.promotion else 0,
|
||||
avatarLevel=char.level,
|
||||
avatarSkill=[],
|
||||
avatarExtraAbility=[],
|
||||
avatarAttributeBonus=[],
|
||||
RelicInfo=[],
|
||||
avatarEnName=avatarId2EnName[str(char.avatarId)],
|
||||
baseAttributes=AvatarBaseAttributes(
|
||||
hp=0,
|
||||
attack=0,
|
||||
defence=0,
|
||||
speed=0,
|
||||
CriticalChanceBase=0,
|
||||
CriticalDamageBase=0,
|
||||
BaseAggro=0,
|
||||
),
|
||||
equipmentInfo=AvatarEquipmentInfo(
|
||||
equipmentID=0,
|
||||
equipmentName="",
|
||||
equipmentLevel=0,
|
||||
equipmentPromotion=0,
|
||||
equipmentRank=0,
|
||||
equipmentRarity=0,
|
||||
baseAttributes=EquipmentBaseAttributes(hp=0, attack=0, defence=0),
|
||||
),
|
||||
rank=0,
|
||||
rankList=[],
|
||||
)
|
||||
# 处理技能
|
||||
for behavior in char.skillTreeList:
|
||||
# 处理技能
|
||||
if f"{char.avatarId}0" == str(behavior.pointId)[0:5]:
|
||||
skill_temp = {}
|
||||
skill_temp["skillId"] = char.avatarId * 100 + behavior.pointId % 10
|
||||
skill_temp["skillName"] = skillId2Name[str(skill_temp["skillId"])]
|
||||
skill_temp["skillEffect"] = skillId2Effect[str(skill_temp["skillId"])]
|
||||
skill_temp["skillAttackType"] = skillId2AttackType[
|
||||
str(skill_temp["skillId"])
|
||||
]
|
||||
skill_temp["skillLevel"] = behavior.level
|
||||
char_data["avatarSkill"].append(skill_temp)
|
||||
skill_temp = MohomoAvatarSkill(
|
||||
skillId=char.avatarId * 100 + behavior.pointId % 10,
|
||||
skillName=skillId2Name[
|
||||
str(char.avatarId * 100 + behavior.pointId % 10)
|
||||
],
|
||||
skillEffect=skillId2Effect[
|
||||
str(char.avatarId * 100 + behavior.pointId % 10)
|
||||
],
|
||||
skillAttackType=skillId2AttackType[
|
||||
str(char.avatarId * 100 + behavior.pointId % 10)
|
||||
],
|
||||
skillLevel=behavior.level,
|
||||
)
|
||||
char_data.avatarSkill.append(skill_temp)
|
||||
|
||||
# 处理技能树中的额外能力
|
||||
if f"{char.avatarId}1" == str(behavior.pointId)[0:5]:
|
||||
extra_ability_temp = {}
|
||||
extra_ability_temp["extraAbilityId"] = behavior.pointId
|
||||
extra_ability_temp["extraAbilityLevel"] = behavior.level
|
||||
char_data["avatarExtraAbility"].append(extra_ability_temp)
|
||||
extra_ability_temp = MohomoAvatarExtraAbility(
|
||||
extraAbilityId=behavior.pointId,
|
||||
extraAbilityLevel=behavior.level,
|
||||
)
|
||||
char_data.avatarExtraAbility.append(extra_ability_temp)
|
||||
|
||||
# 处理技能树中的属性加成
|
||||
if f"{char.avatarId}2" == str(behavior.pointId)[0:5]:
|
||||
attribute_bonus_temp = {}
|
||||
attribute_bonus_temp["attributeBonusId"] = behavior.pointId
|
||||
attribute_bonus_temp["attributeBonusLevel"] = behavior.level
|
||||
attribute_bonus_temp = MohomoAvatarAttributeBonus(
|
||||
attributeBonusId=behavior.pointId,
|
||||
attributeBonusLevel=behavior.level,
|
||||
statusAdd=AttributeBounsStatusAdd(
|
||||
property_="",
|
||||
name="",
|
||||
value=0,
|
||||
),
|
||||
)
|
||||
status_add = characterSkillTree[str(char.avatarId)][str(behavior.pointId)][
|
||||
"levels"
|
||||
][behavior.level - 1]["properties"]
|
||||
attribute_bonus_temp["statusAdd"] = {}
|
||||
if status_add:
|
||||
for property_ in status_add:
|
||||
attribute_bonus_temp["statusAdd"]["property"] = property_["type"]
|
||||
attribute_bonus_temp["statusAdd"]["name"] = Property2Name[
|
||||
attribute_bonus_temp.statusAdd.property_ = property_["type"]
|
||||
attribute_bonus_temp.statusAdd.name = Property2Name[
|
||||
property_["type"]
|
||||
]
|
||||
attribute_bonus_temp["statusAdd"]["value"] = property_["value"]
|
||||
char_data["avatarAttributeBonus"].append(attribute_bonus_temp)
|
||||
attribute_bonus_temp.statusAdd.value = property_["value"]
|
||||
char_data.avatarAttributeBonus.append(attribute_bonus_temp)
|
||||
|
||||
# 处理遗器
|
||||
if char.relicList:
|
||||
for relic in char.relicList:
|
||||
relic_temp = {}
|
||||
relic_temp["relicId"] = relic.tid
|
||||
relic_temp["relicName"] = ItemId2Name[str(relic.tid)]
|
||||
relic_temp["SetId"] = int(RelicId2SetId[str(relic.tid)])
|
||||
relic_temp["SetName"] = SetId2Name[str(relic_temp["SetId"])]
|
||||
relic_temp["Level"] = relic.level if relic.level else 0
|
||||
relic_temp["Type"] = relic.type_
|
||||
relic_temp = Relic(
|
||||
relicId=relic.tid,
|
||||
relicName=ItemId2Name[str(relic.tid)],
|
||||
SetId=RelicId2SetId[str(relic.tid)],
|
||||
SetName=SetId2Name[str(RelicId2SetId[str(relic.tid)])],
|
||||
Type=relic.type_,
|
||||
MainAffix=RelicMainAffix(
|
||||
AffixID=0,
|
||||
Property="",
|
||||
Name="",
|
||||
Value=0,
|
||||
),
|
||||
SubAffixList=[],
|
||||
Level=relic.level if relic.level else 0,
|
||||
)
|
||||
|
||||
relic_temp["MainAffix"] = {}
|
||||
relic_temp["MainAffix"]["AffixID"] = relic.mainAffixId
|
||||
relic_temp.MainAffix.AffixID = relic.mainAffixId
|
||||
affix_property, value = await cal_relic_main_affix(
|
||||
relic_id=relic.tid,
|
||||
set_id=str(relic_temp["SetId"]),
|
||||
set_id=str(relic_temp.SetId),
|
||||
affix_id=relic.mainAffixId,
|
||||
relic_type=relic.type_,
|
||||
relic_level=relic_temp["Level"],
|
||||
relic_level=relic_temp.Level,
|
||||
)
|
||||
relic_temp["MainAffix"]["Property"] = affix_property
|
||||
relic_temp["MainAffix"]["Name"] = Property2Name[affix_property]
|
||||
relic_temp["MainAffix"]["Value"] = value
|
||||
relic_temp.MainAffix.Property = affix_property
|
||||
relic_temp.MainAffix.Name = Property2Name[affix_property]
|
||||
relic_temp.MainAffix.Value = value
|
||||
|
||||
relic_temp["SubAffixList"] = []
|
||||
if relic.subAffixList:
|
||||
for sub_affix in relic.subAffixList:
|
||||
sub_affix_temp = {}
|
||||
sub_affix_temp["SubAffixID"] = sub_affix.affixId
|
||||
sub_affix_temp = RelicSubAffix(
|
||||
SubAffixID=0,
|
||||
Property="",
|
||||
Name="",
|
||||
Cnt=0,
|
||||
Step=0,
|
||||
Value=0,
|
||||
)
|
||||
sub_affix_temp.SubAffixID = sub_affix.affixId
|
||||
sub_affix_property, value = await cal_relic_sub_affix(
|
||||
relic_id=relic.tid,
|
||||
affix_id=sub_affix.affixId,
|
||||
cnt=sub_affix.cnt,
|
||||
step=sub_affix.step if sub_affix.step else 0,
|
||||
)
|
||||
sub_affix_temp["Property"] = sub_affix_property
|
||||
sub_affix_temp["Name"] = Property2Name[sub_affix_property]
|
||||
sub_affix_temp["Cnt"] = sub_affix.cnt
|
||||
sub_affix_temp["Step"] = sub_affix.step if sub_affix.step else 0
|
||||
sub_affix_temp["Value"] = value
|
||||
relic_temp["SubAffixList"].append(sub_affix_temp)
|
||||
char_data["RelicInfo"].append(relic_temp)
|
||||
sub_affix_temp.Property = sub_affix_property
|
||||
sub_affix_temp.Name = Property2Name[sub_affix_property]
|
||||
sub_affix_temp.Cnt = sub_affix.cnt
|
||||
sub_affix_temp.Step = sub_affix.step if sub_affix.step else 0
|
||||
sub_affix_temp.Value = value
|
||||
relic_temp.SubAffixList.append(sub_affix_temp)
|
||||
char_data.RelicInfo.append(relic_temp)
|
||||
|
||||
# 处理命座
|
||||
rank_temp = []
|
||||
if char.rank and char.rank is not None:
|
||||
char_data["rank"] = char.rank
|
||||
rank_temp: List[RankData] = []
|
||||
if char.rank:
|
||||
char_data.rank = char.rank
|
||||
for index in range(char.rank):
|
||||
rankTemp = {}
|
||||
rankTemp = RankData(
|
||||
rankId=0,
|
||||
rankName="",
|
||||
)
|
||||
rank_id = int(str(char.avatarId) + "0" + str(index + 1))
|
||||
rankTemp["rankId"] = rank_id
|
||||
rankTemp["rankName"] = rankId2Name[str(rank_id)]
|
||||
rankTemp.rankId = rank_id
|
||||
rankTemp.rankName = rankId2Name[str(rank_id)]
|
||||
rank_temp.append(rankTemp)
|
||||
char_data["rankList"] = rank_temp
|
||||
char_data.rankList = rank_temp
|
||||
|
||||
# 处理命座中的 level_up_skills
|
||||
if char_data.get("rankList"):
|
||||
for rank_item in char_data["rankList"]:
|
||||
rank_id = rank_item["rankId"]
|
||||
if char.relicList:
|
||||
for rank_item in char_data.rankList:
|
||||
rank_id = rank_item.rankId
|
||||
level_up_skill = AvatarRankSkillUp[str(rank_id)]
|
||||
if level_up_skill:
|
||||
for item in level_up_skill:
|
||||
skill_id = item["id"]
|
||||
skill_up_num = item["num"]
|
||||
# 查找skill_id在不在avatarSkill中
|
||||
for index, skill_item in enumerate(char_data["avatarSkill"]):
|
||||
if str(skill_id) == str(skill_item["skillId"]):
|
||||
char_data["avatarSkill"][index]["skillLevel"] += (
|
||||
skill_up_num
|
||||
)
|
||||
for index, skill_item in enumerate(char_data.avatarSkill):
|
||||
if str(skill_id) == str(skill_item.skillId):
|
||||
char_data.avatarSkill[index].skillLevel += skill_up_num
|
||||
break
|
||||
|
||||
# 处理基础属性
|
||||
base_attributes = {}
|
||||
base_attributes = AvatarBaseAttributes(
|
||||
hp=0,
|
||||
attack=0,
|
||||
defence=0,
|
||||
speed=0,
|
||||
CriticalChanceBase=0,
|
||||
CriticalDamageBase=0,
|
||||
BaseAggro=0,
|
||||
)
|
||||
avatar_promotion_base = None
|
||||
for avatar in AvatarPromotionConfig:
|
||||
if avatar.AvatarID == char.avatarId and avatar.Promotion == char.promotion:
|
||||
@ -235,45 +293,60 @@ async def get_data(
|
||||
raise ValueError(msg)
|
||||
|
||||
# 攻击力
|
||||
base_attributes["attack"] = (
|
||||
base_attributes.attack = (
|
||||
avatar_promotion_base.AttackBase.Value
|
||||
+ avatar_promotion_base.AttackAdd.Value * (char.level - 1)
|
||||
)
|
||||
# 防御力
|
||||
base_attributes["defence"] = (
|
||||
base_attributes.defence = (
|
||||
avatar_promotion_base.DefenceBase.Value
|
||||
+ avatar_promotion_base.DefenceAdd.Value * (char.level - 1)
|
||||
)
|
||||
# 血量
|
||||
base_attributes["hp"] = (
|
||||
base_attributes.hp = (
|
||||
avatar_promotion_base.HPBase.Value
|
||||
+ avatar_promotion_base.HPAdd.Value * (char.level - 1)
|
||||
)
|
||||
# 速度
|
||||
base_attributes["speed"] = avatar_promotion_base.SpeedBase.Value
|
||||
base_attributes.speed = avatar_promotion_base.SpeedBase.Value
|
||||
# 暴击率
|
||||
base_attributes["CriticalChanceBase"] = avatar_promotion_base.CriticalChance.Value
|
||||
base_attributes.CriticalChanceBase = avatar_promotion_base.CriticalChance.Value
|
||||
# 暴击伤害
|
||||
base_attributes["CriticalDamageBase"] = avatar_promotion_base.CriticalDamage.Value
|
||||
base_attributes.CriticalDamageBase = avatar_promotion_base.CriticalDamage.Value
|
||||
# 嘲讽
|
||||
base_attributes["BaseAggro"] = avatar_promotion_base.BaseAggro.Value
|
||||
base_attributes.BaseAggro = avatar_promotion_base.BaseAggro.Value
|
||||
|
||||
char_data["baseAttributes"] = base_attributes
|
||||
char_data.baseAttributes = base_attributes
|
||||
|
||||
# 处理武器
|
||||
equipment_info = {}
|
||||
equipment_info = AvatarEquipmentInfo(
|
||||
equipmentID=0,
|
||||
equipmentName="",
|
||||
equipmentLevel=0,
|
||||
equipmentPromotion=0,
|
||||
equipmentRank=0,
|
||||
equipmentRarity=0,
|
||||
baseAttributes=EquipmentBaseAttributes(hp=0, attack=0, defence=0),
|
||||
)
|
||||
if char.equipment and char.equipment.tid is not None:
|
||||
equipment_info["equipmentID"] = char.equipment.tid
|
||||
equipment_info["equipmentName"] = EquipmentID2Name[str(char.equipment.tid)]
|
||||
equipment_info.equipmentID = char.equipment.tid
|
||||
equipment_info.equipmentName = EquipmentID2Name[str(char.equipment.tid)]
|
||||
|
||||
equipment_info.equipmentLevel = (
|
||||
char.equipment.level if char.equipment.level else 1
|
||||
)
|
||||
equipment_info.equipmentPromotion = (
|
||||
char.equipment.promotion if char.equipment.promotion else 0
|
||||
)
|
||||
equipment_info.equipmentRank = char.equipment.rank if char.equipment.rank else 0
|
||||
equipment_info.equipmentRarity = EquipmentID2Rarity[str(char.equipment.tid)]
|
||||
|
||||
equipment_info["equipmentLevel"] = char.equipment.level
|
||||
equipment_info["equipmentPromotion"] = char.equipment.promotion
|
||||
equipment_info["equipmentRank"] = char.equipment.rank
|
||||
equipment_info["equipmentRarity"] = EquipmentID2Rarity[str(char.equipment.tid)]
|
||||
equipment_base_attributes = {}
|
||||
equipment_promotion_base = None
|
||||
for equipment in EquipmentPromotionConfig:
|
||||
if equipment.EquipmentID == char.equipment.tid and equipment.Promotion == char.equipment.promotion:
|
||||
if (
|
||||
equipment.EquipmentID == char.equipment.tid
|
||||
and equipment.Promotion == char.equipment.promotion
|
||||
):
|
||||
equipment_promotion_base = equipment
|
||||
break
|
||||
if not equipment_promotion_base:
|
||||
@ -282,29 +355,30 @@ async def get_data(
|
||||
|
||||
equipment_level = char.equipment.level if char.equipment.level else 1
|
||||
# 生命值
|
||||
equipment_base_attributes["hp"] = (
|
||||
equipment_info.baseAttributes.hp = (
|
||||
equipment_promotion_base.BaseHP.Value
|
||||
+ equipment_promotion_base.BaseHPAdd.Value * (equipment_level - 1)
|
||||
)
|
||||
# 攻击力
|
||||
equipment_base_attributes["attack"] = (
|
||||
equipment_info.baseAttributes.attack = (
|
||||
equipment_promotion_base.BaseAttack.Value
|
||||
+ equipment_promotion_base.BaseAttackAdd.Value * (equipment_level - 1)
|
||||
)
|
||||
# 防御力
|
||||
equipment_base_attributes["defence"] = (
|
||||
equipment_info.baseAttributes.defence = (
|
||||
equipment_promotion_base.BaseDefence.Value
|
||||
+ equipment_promotion_base.BaseDefenceAdd.Value * (equipment_level - 1)
|
||||
)
|
||||
equipment_info["baseAttributes"] = equipment_base_attributes
|
||||
|
||||
char_data["equipmentInfo"] = equipment_info
|
||||
char_data.equipmentInfo = equipment_info
|
||||
|
||||
if save_path:
|
||||
path = save_path / str(uid)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
with Path.open(path / f"{avatarName}.json", "w", encoding="UTF-8") as file:
|
||||
with Path.open(
|
||||
path / f"{char_data.avatarName}.json", "w", encoding="UTF-8"
|
||||
) as file:
|
||||
json.dump(char_data, file, ensure_ascii=False)
|
||||
|
||||
return char_data, avatarName
|
||||
return char_data, char_data.avatarName
|
||||
|
8
test.py
8
test.py
@ -1,15 +1,11 @@
|
||||
import json
|
||||
from typing import List, Union
|
||||
|
||||
from starrail_damage_cal.cal_damage import DamageCal, cal_char_info, get_char_data
|
||||
from starrail_damage_cal.cal_damage import cal_char_info, get_char_data
|
||||
from starrail_damage_cal.damage.Avatar import AvatarInstance
|
||||
from starrail_damage_cal.to_data import api_to_dict
|
||||
|
||||
|
||||
async def test_get_damage_data_by_uid() -> None:
|
||||
# print(await api_to_dict("108069476"))
|
||||
char_data = await get_char_data(uid="100086290", avatar_name="希儿")
|
||||
print(json.dumps(char_data, ensure_ascii=False, indent=4))
|
||||
print(char_data)
|
||||
|
||||
char = await cal_char_info(char_data)
|
||||
avatar = AvatarInstance(char)
|
||||
|
Loading…
Reference in New Issue
Block a user