mirror of
https://github.com/baiqwerdvd/StarRailDamageCal.git
synced 2025-05-04 10:57:31 +08:00
update
This commit is contained in:
parent
aa9c661e66
commit
09b9c63c0b
@ -21,7 +21,6 @@ class PromotionAttr(Struct):
|
||||
|
||||
class SingleAvatarPromotion(Struct):
|
||||
AvatarID: int
|
||||
# Promotion: int
|
||||
PromotionCostList: List[PromotionCost]
|
||||
MaxLevel: int
|
||||
# WorldLevelRequire: Union[int, None]
|
||||
@ -35,12 +34,12 @@ class SingleAvatarPromotion(Struct):
|
||||
CriticalChance: PromotionAttr
|
||||
CriticalDamage: PromotionAttr
|
||||
BaseAggro: PromotionAttr
|
||||
Promotion: Union[int, None] = None
|
||||
PlayerLevelRequire: Union[int, None] = None
|
||||
|
||||
|
||||
class SingleEquipmentPromotion(Struct):
|
||||
EquipmentID: int
|
||||
# Promotion: int
|
||||
PromotionCostList: List[PromotionCost]
|
||||
MaxLevel: int
|
||||
# WorldLevelRequire: Union[int, None]
|
||||
@ -50,6 +49,7 @@ class SingleEquipmentPromotion(Struct):
|
||||
BaseAttackAdd: PromotionAttr
|
||||
BaseDefence: PromotionAttr
|
||||
BaseDefenceAdd: PromotionAttr
|
||||
Promotion: Union[int, None] = None
|
||||
PlayerLevelRequire: Union[int, None] = None
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
@ -34,6 +34,14 @@ 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
|
||||
|
||||
|
||||
async def api_to_dict(
|
||||
uid: Union[str, None] = None,
|
||||
mihomo_raw: Union[MihomoData, None] = None,
|
||||
@ -52,15 +60,12 @@ async def api_to_dict(
|
||||
path = save_path / uid
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
with Path.open(path / f"{uid!s}.json", "wb") as file:
|
||||
file.write(msgjson.format(msgjson.encode(PlayerDetailInfo), indent=4))
|
||||
_ = file.write(msgjson.format(msgjson.encode(PlayerDetailInfo), indent=4))
|
||||
with Path.open(path / "rawData.json", "wb") as file:
|
||||
file.write(msgjson.format(msgjson.encode(sr_data), indent=4))
|
||||
_ = file.write(msgjson.format(msgjson.encode(sr_data), indent=4))
|
||||
|
||||
player_uid = str(PlayerDetailInfo.uid)
|
||||
|
||||
if sr_data.detailInfo is None:
|
||||
raise CharacterShowcaseNotOpenError(player_uid)
|
||||
|
||||
char_name_list: List[str] = []
|
||||
char_id_list: List[str] = []
|
||||
char_data_list: Dict[str, Dict] = {}
|
||||
@ -222,7 +227,7 @@ async def get_data(
|
||||
base_attributes = {}
|
||||
avatar_promotion_base = None
|
||||
for avatar in AvatarPromotionConfig:
|
||||
if avatar.AvatarID == char.avatarId:
|
||||
if avatar.AvatarID == char.avatarId and avatar.Promotion == char.promotion:
|
||||
avatar_promotion_base = avatar
|
||||
break
|
||||
if not avatar_promotion_base:
|
||||
@ -256,7 +261,6 @@ async def get_data(
|
||||
char_data["baseAttributes"] = base_attributes
|
||||
|
||||
# 处理武器
|
||||
|
||||
equipment_info = {}
|
||||
if char.equipment and char.equipment.tid is not None:
|
||||
equipment_info["equipmentID"] = char.equipment.tid
|
||||
@ -269,7 +273,7 @@ async def get_data(
|
||||
equipment_base_attributes = {}
|
||||
equipment_promotion_base = None
|
||||
for equipment in EquipmentPromotionConfig:
|
||||
if equipment.EquipmentID == char.equipment.tid:
|
||||
if equipment.EquipmentID == char.equipment.tid and equipment.Promotion == char.equipment.promotion:
|
||||
equipment_promotion_base = equipment
|
||||
break
|
||||
if not equipment_promotion_base:
|
||||
|
5
test.py
5
test.py
@ -8,9 +8,8 @@ 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="108069476", avatar_name="流萤")
|
||||
if isinstance(char_data, Union[List, dict]):
|
||||
print(json.dumps(char_data, ensure_ascii=False, indent=4))
|
||||
char_data = await get_char_data(uid="100086290", avatar_name="希儿")
|
||||
print(json.dumps(char_data, ensure_ascii=False, indent=4))
|
||||
|
||||
char = await cal_char_info(char_data)
|
||||
avatar = AvatarInstance(char)
|
||||
|
Loading…
x
Reference in New Issue
Block a user