From b43884fa5bb5e04f9fd546ab05def8d1273fb1fb Mon Sep 17 00:00:00 2001 From: KT Date: Sat, 10 Jun 2023 13:25:36 +0800 Subject: [PATCH] feat: Add max_level property Add max_level property to character and light cone. --- mihomo/models/character.py | 12 +++++++++--- mihomo/models/equipment.py | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/mihomo/models/character.py b/mihomo/models/character.py index 784a55bd..6777a141 100644 --- a/mihomo/models/character.py +++ b/mihomo/models/character.py @@ -60,8 +60,9 @@ class Character(BaseModel): - id (`str`): The character's ID. - name (`str`): The character's name. - rarity (`int`): The character's rarity. - - level (`int`): The character's level. - - ascension (`int`): Ascension level. + - level (`int`): The character's current level. + - max_level (`int`): The maximum character level according to the current ascension phase. + - ascension (`int`): Ascension phase. - eidolon (`int`): The character's eidolon rank. - Image - icon (`str`): The character avatar image @@ -91,7 +92,7 @@ class Character(BaseModel): level: int """Character's level""" ascension: int = Field(..., alias="promotion") - """Ascension Level""" + """Ascension phase""" eidolon: int = Field(..., alias="rank") """Character's eidolon rank""" @@ -122,3 +123,8 @@ class Character(BaseModel): """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 diff --git a/mihomo/models/equipment.py b/mihomo/models/equipment.py index 6c26bb65..8ce4174e 100644 --- a/mihomo/models/equipment.py +++ b/mihomo/models/equipment.py @@ -12,8 +12,9 @@ class LightCone(BaseModel): - name (`str`): The name of the light cone. - rarity (`int`): The rarity of the light cone. - superimpose (`int`): The superimpose rank of the light cone. - - level (`int`): The level of the light cone. - - ascension (`int`): The ascension level of the light cone. + - level (`int`): The current level of the light cone. + - max_level (`int`): The maximum light cone level according to the current ascension phase. + - ascension (`int`): The ascension phase of the light cone. - icon (`str`): The light cone icon image. - preview (`str`): The light cone preview image. - portrait (`str`): The light cone portrait image. @@ -33,7 +34,7 @@ class LightCone(BaseModel): level: int """The level of the light cone""" ascension: int = Field(..., alias="promotion") - """The ascension level of the light cone""" + """The ascension phase of the light cone""" icon: str """The light cone icon image""" preview: str @@ -47,6 +48,11 @@ class LightCone(BaseModel): properties: list[Property] """The list of properties of the light cone""" + @property + def max_level(self) -> int: + """The maximum light cone level according to the current ascension phase""" + return 20 + 10 * self.ascension + class Relic(BaseModel): """