From 8a1ac17edaff13d421877bf703c5a8b3fb879dca Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 30 Dec 2023 10:20:49 +0800 Subject: [PATCH] :sparkles: Support starrail rogue nous --- .../client/components/chronicle/starrail.py | 24 +++++- simnet/models/starrail/chronicle/rogue.py | 75 +++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/simnet/client/components/chronicle/starrail.py b/simnet/client/components/chronicle/starrail.py index 43626cd..5e6296b 100644 --- a/simnet/client/components/chronicle/starrail.py +++ b/simnet/client/components/chronicle/starrail.py @@ -11,7 +11,7 @@ from simnet.models.starrail.chronicle.characters import StarRailDetailCharacters from simnet.models.starrail.chronicle.museum import StarRailMuseumBasic, StarRailMuseumDetail from simnet.models.starrail.chronicle.notes import StarRailNote, StarRailNoteWidget, StarRailNoteOverseaWidget from simnet.models.starrail.chronicle.resident import StarRailResident -from simnet.models.starrail.chronicle.rogue import StarRailRogue, StarRailRogueLocust +from simnet.models.starrail.chronicle.rogue import StarRailRogue, StarRailRogueLocust, StarRailRogueNous from simnet.models.starrail.chronicle.stats import StarRailUserStats, StarRailUserInfo from simnet.utils.enums import Game, Region from simnet.utils.player import recognize_starrail_server, recognize_region @@ -251,6 +251,28 @@ class StarRailBattleChronicleClient(BaseChronicleClient): data = await self._request_starrail_record("rogue_locust", player_id, lang=lang, payload=payload) return StarRailRogueLocust(**data) + async def get_starrail_rogue_nous( + self, + player_id: Optional[int] = None, + lang: Optional[str] = None, + ) -> StarRailRogueNous: + """Get starrail rogue nous runs. + + Args: + player_id (Optional[int], optional): The player ID. Defaults to None. + lang (Optional[str], optional): The language of the data. Defaults to None. + + Returns: + StarRailRogueNous: The requested rogue nous runs. + + Raises: + BadRequest: If the request is invalid. + DataNotPublic: If the requested data is not public. + """ + payload = dict(need_detail="true") + data = await self._request_starrail_record("rogue_nous", player_id, lang=lang, payload=payload) + return StarRailRogueNous(**data) + async def get_starrail_museum_info( self, uid: Optional[int] = None, diff --git a/simnet/models/starrail/chronicle/rogue.py b/simnet/models/starrail/chronicle/rogue.py index 9343fb5..1e4eb8e 100644 --- a/simnet/models/starrail/chronicle/rogue.py +++ b/simnet/models/starrail/chronicle/rogue.py @@ -170,3 +170,78 @@ class StarRailRogueLocust(APIModel): basic: RogueLocustBasic detail: RogueLocustRecords role: RogueUserRole + + +class StarRailRogueNousBasic(APIModel): + """StarRail Rogue Nous Basic""" + + cur_progress: int + max_progress: int + cur_rolling: int + max_rolling: int + unlock_miracle: int + active_nerve: int + unlock_event: int + exist_data: bool + + +class StarRailRogueNousSide(APIModel): + """StarRail Rogue Nous Side""" + + icon: str + rarity: int + + +class StarRailRogueNousRolling(APIModel): + """StarRail Rogue Nous Rolling""" + + id: int + name_mi18n: str + icon: str + sides: List[StarRailRogueNousSide] + main_buff_mi18n: str + aeon_id: int + + +class StarRailRogueNousRecordDetail(APIModel): + """Detailed Rogue nous record info.""" + + name_mi18n: str + finish_time: PartialTime + final_lineup: List[RogueCharacter] + base_type_list: List[RogueBuffType] + cached_avatars: List[RogueCharacter] + buffs: List[RogueBuff] + miracles: List[RogueMiracle] + blocks: List[RogueLocustRecordDetailBlock] + boss_effect: List[str] + rolling: StarRailRogueNousRolling + + difficulty: int + difficulty_type1_value: int + difficulty_type2_value: int + has_difficulty_type: bool + + fury: RogueLocustRecordDetailFury + + @property + def time_str(self) -> str: + """Get the time as a string.""" + if self.finish_time is None: + return "N/A" + + return self.finish_time.datetime.strftime("%Y.%m.%d %H:%M") + + +class StarRailRogueNousRecords(APIModel): + """Rogue Nous records""" + + records: List[StarRailRogueNousRecordDetail] + + +class StarRailRogueNous(APIModel): + """StarRail Rogue Nous""" + + basic: StarRailRogueNousBasic + detail: StarRailRogueNousRecords + role: RogueUserRole