diff --git a/core/services/cookies/services.py b/core/services/cookies/services.py index d727ab7..143e5b9 100644 --- a/core/services/cookies/services.py +++ b/core/services/cookies/services.py @@ -96,13 +96,13 @@ class PublicCookiesService(BaseService): raise RuntimeError("account_id not found") record_cards = await client.get_record_cards() for record_card in record_cards: - if record_card.game == Game.GENSHIN: + if record_card.game == Game.STARRAIL: await client.get_starrail_user(record_card.uid) break else: accounts = await client.get_game_accounts() for account in accounts: - if account.game == Game.GENSHIN: + if account.game == Game.STARRAIL: await client.get_starrail_user(account.uid) break except InvalidCookies as exc: diff --git a/modules/wiki/character.py b/modules/wiki/character.py index 53ccbc8..2377fb7 100644 --- a/modules/wiki/character.py +++ b/modules/wiki/character.py @@ -1,7 +1,7 @@ from typing import List, Dict, Optional from modules.wiki.base import WikiModel -from modules.wiki.models.avatar import Avatar +from modules.wiki.models.avatar import YattaAvatar class Character(WikiModel): @@ -10,9 +10,9 @@ class Character(WikiModel): def __init__(self): super().__init__() - self.all_avatars: List[Avatar] = [] - self.all_avatars_map: Dict[int, Avatar] = {} - self.all_avatars_name: Dict[str, Avatar] = {} + self.all_avatars: List[YattaAvatar] = [] + self.all_avatars_map: Dict[int, YattaAvatar] = {} + self.all_avatars_name: Dict[str, YattaAvatar] = {} def clear_class_data(self) -> None: self.all_avatars.clear() @@ -31,15 +31,15 @@ class Character(WikiModel): datas = await WikiModel.read(self.avatar_path) self.clear_class_data() for data in datas: - m = Avatar(**data) + m = YattaAvatar(**data) self.all_avatars.append(m) self.all_avatars_map[m.id] = m self.all_avatars_name[m.name] = m - def get_by_id(self, cid: int) -> Optional[Avatar]: + def get_by_id(self, cid: int) -> Optional[YattaAvatar]: return self.all_avatars_map.get(cid) - def get_by_name(self, name: str) -> Optional[Avatar]: + def get_by_name(self, name: str) -> Optional[YattaAvatar]: return self.all_avatars_name.get(name) def get_name_list(self) -> List[str]: diff --git a/modules/wiki/models/avatar.py b/modules/wiki/models/avatar.py index c78266e..665ae60 100644 --- a/modules/wiki/models/avatar.py +++ b/modules/wiki/models/avatar.py @@ -1,60 +1,68 @@ -from typing import List +from typing import List, Optional + from pydantic import BaseModel -from .enums import Quality, Destiny, Element -from .material import Material + +from .enums import Destiny, Element -class AvatarInfo(BaseModel): - occupation: str = "" - """所属""" - faction: str = "" - """派系""" +class YattaAvatarPath(BaseModel): + id: str + name: str -class AvatarItem(BaseModel): - item: Material - """物品""" - count: int - """数量""" +class YattaAvatarTypes(BaseModel): + pathType: YattaAvatarPath + combatType: YattaAvatarPath -class AvatarPromote(BaseModel): - required_level: int - """突破所需等级""" - promote_level: int = 0 - """突破等级""" - max_level: int - """解锁的等级上限""" - - coin: int = 0 - """信用点""" - items: List[AvatarItem] - """突破所需材料""" +class YattaAvatarCV(BaseModel): + CV_CN: str + CV_JP: str + CV_KR: str + CV_EN: str -class AvatarSoul(BaseModel): +class YattaAvatarFetter(BaseModel): + faction: Optional[str] + description: Optional[str] + cv: Optional[YattaAvatarCV] + + +class YattaAvatarEidolon(BaseModel): + id: int + rank: int + name: Optional[str] + description: Optional[str] + icon: str + + @property + def icon_url(self) -> str: + return f"https://api.yatta.top/hsr/assets/UI/skill/{self.icon}.png" + + +class YattaAvatar(BaseModel): + id: int + """ 角色ID """ name: str """ 名称 """ - desc: str - """ 介绍 """ - - -class Avatar(BaseModel): - id: int - """角色ID""" - name: str - """名称""" + rank: int + """ 星级 """ + types: YattaAvatarTypes + """ 角色类型 """ icon: str - """图标""" - quality: Quality - """品质""" - destiny: Destiny - """命途""" - element: Element - """属性""" - information: AvatarInfo - """角色信息""" - promote: List[AvatarPromote] - """角色突破数据""" - soul: List[AvatarSoul] - """角色星魂数据""" + """ 图标 """ + release: int + """ 上线时间 """ + route: str + fetter: YattaAvatarFetter + eidolons: List[YattaAvatarEidolon] + + @property + def destiny(self) -> Destiny: + """命途""" + return Destiny(self.types.pathType.name) + + @property + def element(self) -> Element: + """属性""" + return Element(self.types.combatType.name) diff --git a/modules/wiki/models/avatar_config.py b/modules/wiki/models/avatar_config.py index 87c231b..e66f18b 100644 --- a/modules/wiki/models/avatar_config.py +++ b/modules/wiki/models/avatar_config.py @@ -12,7 +12,6 @@ class AvatarConfig(BaseModel): AvatarID: int AvatarName: AvatarName AvatarVOTag: str - Release: bool class AvatarIcon(BaseModel): diff --git a/plugins/starrail/player_cards.py b/plugins/starrail/player_cards.py index 392a576..01d7ced 100644 --- a/plugins/starrail/player_cards.py +++ b/plugins/starrail/player_cards.py @@ -550,4 +550,5 @@ class RenderTemplate: substat_scores=[substat_score(s) for s in self.client.get_affix(e, False)], ) for e in relic_list + if self.client.get_affix_by_id(e.tid) is not None ] diff --git a/plugins/tools/challenge.py b/plugins/tools/challenge.py index 088d088..1caca9c 100644 --- a/plugins/tools/challenge.py +++ b/plugins/tools/challenge.py @@ -1,6 +1,7 @@ from typing import Tuple, Optional from simnet import Region +from simnet.client.cookies import Cookies from simnet.errors import BadRequest as SIMNetBadRequest from core.basemodel import RegionEnum @@ -104,7 +105,7 @@ class ChallengeSystem(Plugin): _, challenge = await self.get_challenge(player.player_id) if challenge is None: raise ChallengeSystemException("验证失效 请求已经过期") - verify = Verify(cookies=cookie_model.data) + verify = Verify(cookies=Cookies(cookie_model.data)) try: await verify.verify(challenge=challenge, validate=validate) except ResponseException as exc: