From 5e6626830465e7a0b6a8938124701a1f12ea67ae Mon Sep 17 00:00:00 2001 From: seriaati Date: Tue, 10 Sep 2024 12:08:23 +0800 Subject: [PATCH] Add ImgTheater battle stats --- .../models/genshin/chronicle/img_theater.py | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/genshin/models/genshin/chronicle/img_theater.py b/genshin/models/genshin/chronicle/img_theater.py index 75dae271..6420ff7e 100644 --- a/genshin/models/genshin/chronicle/img_theater.py +++ b/genshin/models/genshin/chronicle/img_theater.py @@ -24,6 +24,8 @@ "TheaterDifficulty", "TheaterSchedule", "TheaterStats", + "TheaterBattleStats", + "BattleStatCharacter", ) @@ -129,21 +131,48 @@ def __parse_datetime(cls, value: typing.Mapping[str, typing.Any]) -> datetime.da ) +class BattleStatCharacter(APIModel): + """Imaginarium theater battle statistic character.""" + + id: int = Aliased("avatar_id") + icon: str = Aliased("avatar_icon") + value: int + rarity: int + + @pydantic.validator("value", pre=True) + def __intify_value(cls, value: str) -> int: + if not value: + return 0 + return int(value) + + +class TheaterBattleStats(APIModel): + """Imaginarium theater battle statistics.""" + + max_defeat_character: BattleStatCharacter = Aliased("max_defeat_avatar") + max_damage_character: BattleStatCharacter = Aliased("max_damage_avatar") + max_take_damage_character: BattleStatCharacter = Aliased("max_take_damage_avatar") + fastest_character_list: typing.Sequence[BattleStatCharacter] = Aliased("shortest_avatar_list") + total_cast_seconds: int = Aliased("total_use_time") + + class ImgTheaterData(APIModel): """Imaginarium theater data.""" acts: typing.Sequence[Act] = Aliased(alias="rounds_data") - backup_characters: typing.Sequence[ActCharacter] = Aliased(alias="backup_avatars") # Not sure what this is + backup_characters: typing.Sequence[ActCharacter] = Aliased("backup_avatars") # Not sure what this is stats: TheaterStats = Aliased(alias="stat") schedule: TheaterSchedule has_data: bool has_detail_data: bool + battle_stats: TheaterBattleStats = Aliased("fight_statisic", default=None) @pydantic.root_validator(pre=True) def __unnest_detail(cls, values: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]: detail: typing.Optional[typing.Dict[str, typing.Any]] = values.get("detail") values["rounds_data"] = detail.get("rounds_data", []) if detail is not None else [] values["backup_avatars"] = detail.get("backup_avatars", []) if detail is not None else [] + values["fight_statisic"] = detail.get("fight_statisic", None) if detail is not None else None return values