clash/mihomo/models/character.py

93 lines
3.4 KiB
Python
Raw Normal View History

2023-05-28 13:13:13 +00:00
from typing import Any
from pydantic import BaseModel, Field, root_validator
2023-06-10 14:47:57 +00:00
from .combat import Element, Path, Trace, TraceTreeNode
2023-05-28 13:13:13 +00:00
from .equipment import LightCone, Relic, RelicSet
2023-06-10 14:47:57 +00:00
from .stat import Attribute, Property
2023-05-28 13:13:13 +00:00
class Character(BaseModel):
"""
Represents a character.
Attributes:
- Basic info:
- id (`str`): The character's ID.
- name (`str`): The character's name.
- rarity (`int`): The character's rarity.
- level (`int`): The character's current level.
- max_level (`int`): The maximum character level according to the current ascension phase.
- ascension (`int`): Ascension phase.
2023-05-28 13:13:13 +00:00
- eidolon (`int`): The character's eidolon rank.
- eidolon_icons (list[`str`]): The list of character's eiodolon icons.
2023-05-28 13:13:13 +00:00
- Image
- icon (`str`): The character avatar image
- preview (`str`): The character's preview image.
- portrait (`str`): The character's portrait image.
- Combat
- path (`Path`): The character's path.
- element (`Element`): The character's element.
2023-05-28 13:13:13 +00:00
- traces (list[`Trace`]): The list of character's skill traces.
- trace_tree (list[`TraceTreeNode]): The list of the character's skill traces.
- Equipment
2023-05-28 13:13:13 +00:00
- light_cone (`LightCone` | `None`): The character's light cone (weapon), or None if not applicable.
- relics (list[`Relic`] | `None`): The list of character's relics, or None if not applicable.
- relic_set (list[`RelicSet`] | `None`): The list of character's relic sets, or None if not applicable.
- stats (list[`Stat`]): The list of character's stats.
- Stats
- attributes (list[`Attribute`]): The list of character's attributes.
- additions (list[`Attribute`]): The list of character's additional attributes.
- properties (list[`Property`]): The list of character's properties.
2023-05-28 13:13:13 +00:00
"""
id: str
"""Character's ID"""
name: str
"""Character's name"""
rarity: int
"""Character's rarity"""
level: int
"""Character's level"""
ascension: int = Field(..., alias="promotion")
"""Ascension phase"""
2023-05-28 13:13:13 +00:00
eidolon: int = Field(..., alias="rank")
"""Character's eidolon rank"""
eidolon_icons: list[str] = Field([], alias="rank_icons")
"""The list of character's eiodolon icons"""
2023-05-28 13:13:13 +00:00
icon: str
"""Character avatar image"""
2023-05-28 13:13:13 +00:00
preview: str
"""Character preview image"""
portrait: str
"""Character portrait image"""
path: Path
2023-05-28 13:13:13 +00:00
"""Character's path"""
element: Element
2023-05-28 13:13:13 +00:00
"""Character's element"""
traces: list[Trace] = Field(..., alias="skills")
2023-05-28 13:13:13 +00:00
"""The list of character's skill traces"""
trace_tree: list[TraceTreeNode] = Field([], alias="skill_trees")
"""The list of the character's skill traces"""
2023-05-28 13:13:13 +00:00
light_cone: LightCone | None = None
"""Character's light cone (weapon)"""
relics: list[Relic] = []
2023-05-28 13:13:13 +00:00
"""The list of character's relics"""
relic_sets: list[RelicSet] = []
2023-05-28 13:13:13 +00:00
"""The list of character's relic sets"""
attributes: list[Attribute]
"""The list of character's attributes"""
additions: list[Attribute]
"""The list of character's additional attributes"""
properties: list[Property]
"""The list of character's properties"""
@property
def max_level(self) -> int:
"""The maximum character level according to the current ascension phase"""
return 20 + 10 * self.ascension