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