mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-24 15:19:21 +00:00
✨ Support starrail resident
This commit is contained in:
parent
bc93d34edf
commit
5801b6766d
@ -10,6 +10,7 @@ from simnet.models.starrail.chronicle.challenge import StarRailChallenge
|
|||||||
from simnet.models.starrail.chronicle.characters import StarRailDetailCharacters
|
from simnet.models.starrail.chronicle.characters import StarRailDetailCharacters
|
||||||
from simnet.models.starrail.chronicle.museum import StarRailMuseumBasic, StarRailMuseumDetail
|
from simnet.models.starrail.chronicle.museum import StarRailMuseumBasic, StarRailMuseumDetail
|
||||||
from simnet.models.starrail.chronicle.notes import StarRailNote, StarRailNoteWidget, StarRailNoteOverseaWidget
|
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
|
from simnet.models.starrail.chronicle.rogue import StarRailRogue
|
||||||
from simnet.models.starrail.chronicle.stats import StarRailUserStats, StarRailUserInfo
|
from simnet.models.starrail.chronicle.stats import StarRailUserStats, StarRailUserInfo
|
||||||
from simnet.utils.enum_ import Game, Region
|
from simnet.utils.enum_ import Game, Region
|
||||||
@ -291,6 +292,27 @@ class StarRailBattleChronicleClient(BaseChronicleClient):
|
|||||||
data = await self._request_starrail_record("activity", uid, lang=lang)
|
data = await self._request_starrail_record("activity", uid, lang=lang)
|
||||||
return StarRailActivity(**data)
|
return StarRailActivity(**data)
|
||||||
|
|
||||||
|
async def get_starrail_resident(
|
||||||
|
self,
|
||||||
|
uid: Optional[int] = None,
|
||||||
|
lang: Optional[str] = None,
|
||||||
|
) -> StarRailResident:
|
||||||
|
"""Get starrail resident info.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
uid (Optional[int], optional): The player ID. Defaults to None.
|
||||||
|
lang (Optional[str], optional): The language of the data. Defaults to None.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
StarRailResident: The requested activity info.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
BadRequest: If the request is invalid.
|
||||||
|
DataNotPublic: If the requested data is not public.
|
||||||
|
"""
|
||||||
|
data = await self._request_starrail_record("resident", uid, lang=lang)
|
||||||
|
return StarRailResident(**data)
|
||||||
|
|
||||||
async def get_starrail_notes_by_stoken(
|
async def get_starrail_notes_by_stoken(
|
||||||
self,
|
self,
|
||||||
lang: Optional[str] = None,
|
lang: Optional[str] = None,
|
||||||
|
@ -144,7 +144,7 @@ class StarRailActivity(APIModel):
|
|||||||
for activity in self.activities:
|
for activity in self.activities:
|
||||||
if list(activity.keys())[0] == key:
|
if list(activity.keys())[0] == key:
|
||||||
return activity[key]
|
return activity[key]
|
||||||
raise ValueError("No star fight activity found.")
|
raise ValueError("No starrail activity found.")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fantastic_story(self) -> StarRailFantasticStory:
|
def fantastic_story(self) -> StarRailFantasticStory:
|
||||||
|
68
simnet/models/starrail/chronicle/resident.py
Normal file
68
simnet/models/starrail/chronicle/resident.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
from simnet.models.base import APIModel
|
||||||
|
|
||||||
|
|
||||||
|
class StarRailResidentBase(APIModel):
|
||||||
|
"""StarRailResident Base Model"""
|
||||||
|
|
||||||
|
exists_data: bool = True
|
||||||
|
is_hot: bool
|
||||||
|
strategy_link: str = ""
|
||||||
|
|
||||||
|
|
||||||
|
class StarRailResidentBoxingListItem(APIModel):
|
||||||
|
"""Resident Boxing List Item"""
|
||||||
|
|
||||||
|
id: int
|
||||||
|
name: str
|
||||||
|
best: int
|
||||||
|
|
||||||
|
|
||||||
|
class StarRailResidentBoxing(APIModel):
|
||||||
|
"""Resident Boxing"""
|
||||||
|
|
||||||
|
base: StarRailResidentBase
|
||||||
|
list: List[StarRailResidentBoxingListItem]
|
||||||
|
|
||||||
|
|
||||||
|
class StarRailResidentMuseumInfo(APIModel):
|
||||||
|
"""Resident Museum Info"""
|
||||||
|
|
||||||
|
current_exp: int
|
||||||
|
max_exp: int
|
||||||
|
exhibition_num: int
|
||||||
|
total_exhibition: int
|
||||||
|
director_num: int
|
||||||
|
total_director: int
|
||||||
|
phase: str
|
||||||
|
|
||||||
|
|
||||||
|
class StarRailResidentMuseum(APIModel):
|
||||||
|
"""Resident Museum"""
|
||||||
|
|
||||||
|
base: StarRailResidentBase
|
||||||
|
museum: StarRailResidentMuseumInfo
|
||||||
|
|
||||||
|
|
||||||
|
class StarRailResident(APIModel):
|
||||||
|
"""Starrail chronicle resident activity."""
|
||||||
|
|
||||||
|
residents: List
|
||||||
|
|
||||||
|
def find_resident(self, key: str) -> Optional[dict]:
|
||||||
|
"""Find a resident by key."""
|
||||||
|
for resident in self.residents:
|
||||||
|
if list(resident.keys())[0] == key:
|
||||||
|
return resident[key]
|
||||||
|
raise ValueError("No starrail resident found.")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def museum(self) -> StarRailResidentMuseum:
|
||||||
|
"""Get the museum resident."""
|
||||||
|
return StarRailResidentMuseum(**self.find_resident("museum"))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def boxing(self) -> StarRailResidentBoxing:
|
||||||
|
"""Get the boxing resident."""
|
||||||
|
return StarRailResidentBoxing(**self.find_resident("boxing"))
|
Loading…
Reference in New Issue
Block a user