HonkaiStarRailWikiDataParser/models/avatar.py

69 lines
1.3 KiB
Python
Raw Normal View History

2023-07-20 05:07:56 +00:00
from typing import List, Optional
2023-04-23 14:06:11 +00:00
from pydantic import BaseModel
2023-07-20 05:07:56 +00:00
from .enums import Destiny, Element
2023-04-23 14:06:11 +00:00
2023-07-20 05:07:56 +00:00
class YattaAvatarPath(BaseModel):
id: str
name: str
2023-04-23 14:06:11 +00:00
2023-07-20 05:07:56 +00:00
class YattaAvatarTypes(BaseModel):
pathType: YattaAvatarPath
combatType: YattaAvatarPath
2023-04-23 14:06:11 +00:00
2023-07-20 05:07:56 +00:00
class YattaAvatarCV(BaseModel):
CV_CN: str
CV_JP: str
CV_KR: str
CV_EN: str
2023-04-23 14:06:11 +00:00
2023-07-20 05:07:56 +00:00
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"
2023-04-23 14:06:11 +00:00
2023-07-20 05:07:56 +00:00
class YattaAvatar(BaseModel):
2023-04-23 14:06:11 +00:00
id: int
2023-07-20 05:07:56 +00:00
""" 角色ID """
2023-04-23 14:06:11 +00:00
name: str
2023-07-20 05:07:56 +00:00
""" 名称 """
rank: int
""" 星级 """
types: YattaAvatarTypes
""" 角色类型 """
2023-04-28 11:32:53 +00:00
icon: str
2023-07-20 05:07:56 +00:00
""" 图标 """
release: int
""" 上线时间 """
route: str
fetter: YattaAvatarFetter
eidolons: List[YattaAvatarEidolon]
@property
def destiny(self) -> Destiny:
2023-08-29 05:15:55 +00:00
"""命途"""
2023-07-20 05:07:56 +00:00
return Destiny(self.types.pathType.name)
@property
def element(self) -> Element:
2023-08-29 05:15:55 +00:00
"""属性"""
2023-07-20 05:07:56 +00:00
return Element(self.types.combatType.name)