Support starrail challenge story

This commit is contained in:
xtaodada 2024-01-09 16:18:23 +08:00
parent 0ebae4973f
commit 9f7d581f07
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 97 additions and 0 deletions

View File

@ -7,6 +7,7 @@ from simnet.errors import BadRequest, DataNotPublic
from simnet.models.lab.record import RecordCard
from simnet.models.starrail.chronicle.activity import StarRailActivity
from simnet.models.starrail.chronicle.challenge import StarRailChallenge
from simnet.models.starrail.chronicle.challenge_story import StarRailChallengeStory
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
@ -205,6 +206,30 @@ class StarRailBattleChronicleClient(BaseChronicleClient):
data = await self._request_starrail_record("challenge", player_id, lang=lang, payload=payload)
return StarRailChallenge(**data)
async def get_starrail_challenge_story(
self,
player_id: Optional[int] = None,
previous: bool = False,
lang: Optional[str] = None,
) -> StarRailChallengeStory:
"""Get starrail challenge runs.
Args:
player_id (Optional[int], optional): The player ID. Defaults to None.
previous (bool, optional): Whether to get previous runs. Defaults to False.
lang (Optional[str], optional): The language of the data. Defaults to None.
Returns:
StarRailChallengeStory: The requested challenge runs.
Raises:
BadRequest: If the request is invalid.
DataNotPublic: If the requested data is not public.
"""
payload = dict(schedule_type=2 if previous else 1, need_all="true", type="story")
data = await self._request_starrail_record("challenge_story", player_id, lang=lang, payload=payload)
return StarRailChallengeStory(**data)
async def get_starrail_rogue(
self,
player_id: Optional[int] = None,

View File

@ -0,0 +1,72 @@
"""Starrail chronicle challenge story."""
from typing import List
from pydantic import Field
from simnet.models.base import APIModel
from simnet.models.starrail.character import RogueCharacter
from .base import PartialTime
__all__ = [
"StarRailChallengeStoryGroup",
"StarRailChallengeStoryFloorNode",
"StarRailChallengeStoryFloor",
"StarRailChallengeStory",
]
class StarRailChallengeStoryGroup(APIModel):
"""Group in a challenge story."""
season: int = Field(alias="schedule_id")
begin_time: PartialTime
end_time: PartialTime
status: str
name_mi18n: str
class StarRailChallengeStoryBuff(APIModel):
"""Challenge Story Buff"""
id: int
name_mi18n: str
desc_mi18n: str
icon: str
class StarRailChallengeStoryFloorNode(APIModel):
"""Node for a floor."""
challenge_time: PartialTime
avatars: List[RogueCharacter]
challenge_time: PartialTime
avatars: List[RogueCharacter]
buff: StarRailChallengeStoryBuff
score: int
class StarRailChallengeStoryFloor(APIModel):
"""Floor in a challenge."""
name: str
round_num: int
star_num: int
node_1: StarRailChallengeStoryFloorNode
node_2: StarRailChallengeStoryFloorNode
is_fast: bool
maze_id: int
class StarRailChallengeStory(APIModel):
"""Challenge story in a season."""
groups: List[StarRailChallengeStoryGroup]
total_stars: int = Field(alias="star_num")
max_floor: str
max_floor_id: int
total_battles: int = Field(alias="battle_num")
has_data: bool
floors: List[StarRailChallengeStoryFloor] = Field(alias="all_floor_detail")