EnkaNetwork.py/enkanetwork/model/assets.py

154 lines
3.9 KiB
Python
Raw Normal View History

from pydantic import BaseModel, Field
from typing import List, Any
from ..enum import ElementType
2022-08-14 09:44:47 +00:00
from .utils import IconAsset
2022-07-29 04:31:21 +00:00
__all__ = (
'NamecardAsset',
'CharacterIconAsset',
'CharacterSkillAsset',
'CharacterConstellationsAsset',
'CharacterCostume',
'CharacterAsset'
)
2023-02-07 08:22:05 +00:00
class NamecardAsset(BaseModel):
2023-02-07 08:22:05 +00:00
""" Namecards (Assets)
Attributes
------------
id: :class:`int`
Namecard ID
hash_id: :class:`str`
Namecard hash id
icon: :class:`IconAsset`
A icon assets. Please refers in `IconAsset` class
banner: :class:`IconAsset`
A banner assets. Please refers in `IconAsset` class
navbar: :class:`IconAsset`
A navbar assets. Please refers in `IconAsset` class
"""
id: int = 0
hash_id: str = Field("", alias="nameTextMapHash")
2022-08-14 09:44:47 +00:00
icon: IconAsset
banner: IconAsset
navbar: IconAsset
2022-07-29 04:31:21 +00:00
class CharacterIconAsset(BaseModel):
2023-02-07 08:22:05 +00:00
""" Character Icon (Assets)
Attributes
------------
icon: :class:`IconAsset`
A icon assets. Please refers in `IconAsset` class
side: :class:`IconAsset`
A navbar assets. Please refers in `IconAsset` class
banner: :class:`IconAsset`
A banner assets. Please refers in `IconAsset` class
card: :class:`IconAsset`
A navbar assets. Please refers in `IconAsset` class
"""
2022-08-14 09:44:47 +00:00
icon: IconAsset
2023-02-07 08:22:05 +00:00
side: IconAsset
2022-08-14 09:44:47 +00:00
banner: IconAsset
card: IconAsset
2022-07-29 04:31:21 +00:00
class CharacterSkillAsset(BaseModel):
2023-02-07 08:22:05 +00:00
""" Character Skill(s) (Assets)
Attributes
------------
id: :class:`int`
Character skill(s) ID
pround_map: :class:`int`
pround map for a booest skill by constellation
hash_id: :class:`str`
Skill(s) hash id
icon: :class:`IconAsset`
A icon assets. Please refers in `IconAsset` class
"""
2022-12-09 05:51:21 +00:00
id: int = 0,
pround_map: int = 0,
hash_id: str = Field("", alias="nameTextMapHash")
2022-08-15 20:17:34 +00:00
icon: IconAsset = None
2022-07-29 04:31:21 +00:00
class CharacterConstellationsAsset(BaseModel):
2023-02-07 08:22:05 +00:00
""" Character Constellations (Assets)
Attributes
------------
id: :class:`int`
Character constellations ID
hash_id: :class:`str`
Constellations hash id
icon: :class:`IconAsset`
A icon assets. Please refers in `IconAsset` class
"""
id: int = 0
hash_id: str = Field("", alias="nameTextMapHash")
2022-08-15 20:17:34 +00:00
icon: IconAsset = None
2023-02-07 08:22:05 +00:00
class CharacterCostume(BaseModel):
2023-02-07 08:22:05 +00:00
""" Character Costume (Assets)
Attributes
------------
id: :class:`int`
Costume ID
hash_id: :class:`str`
Costume hash id
icon: :class:`IconAsset`
A icon assets. Please refers in `IconAsset` class
"""
id: int = 0
images: CharacterIconAsset = None
class CharacterAsset(BaseModel):
2023-02-07 08:22:05 +00:00
""" Character (Assets)
Attributes
------------
id: :class:`int`
Avatar ID
rarity: :class:`int`
Character rarity (5 stars or 4stars)
hash_id: :class:`str`
Character hash id
element: :class:`ElementType`
Character element type
images: :class:`CharacterIconAsset`
Character image data. Please refers in `CharacterIconAsset`
skill_id: :class:`int`
Character skill ID
skills: List[:class:`int`]
Character skill data list
constellations: List[:class:`int`]
Character constellations data list
"""
id: int = 0
rarity: int = 0
hash_id: str = Field("", alias="nameTextMapHash")
element: ElementType = ElementType.Unknown
images: CharacterIconAsset = None
skill_id: int = 0
skills: List[int] = []
constellations: List[int] = Field([], alias="talents")
class Config:
use_enum_values = True
def __init__(self, **data: Any) -> None:
super().__init__(**data)
2023-02-07 08:22:05 +00:00
self.element = ElementType(
data["costElemType"]) if data["costElemType"] != "" else ElementType.Unknown
self.rarity = 5 if data["qualityType"].endswith("_ORANGE") else 4