mirror of
https://github.com/PaiGramTeam/EnkaNetwork.py.git
synced 2024-11-16 03:45:28 +00:00
Fix model to support new json data
This commit is contained in:
parent
d162cea376
commit
9dba0fa42b
@ -7,6 +7,7 @@ from .equipments import Equipments
|
|||||||
from .combats import CharacterCombat
|
from .combats import CharacterCombat
|
||||||
from ..json import Config
|
from ..json import Config
|
||||||
from ..utils import create_ui_path
|
from ..utils import create_ui_path
|
||||||
|
from ..enum import ElementType
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ class CharacterInfo(BaseModel):
|
|||||||
Custom data
|
Custom data
|
||||||
"""
|
"""
|
||||||
name: str = "" # Get from name hash map
|
name: str = "" # Get from name hash map
|
||||||
|
element: ElementType = ElementType.Unknown
|
||||||
image: CharacterImages = CharacterImages()
|
image: CharacterImages = CharacterImages()
|
||||||
skills: List[CharacterSkill] = []
|
skills: List[CharacterSkill] = []
|
||||||
constellations: List[CharacterConstellations] = []
|
constellations: List[CharacterConstellations] = []
|
||||||
@ -74,14 +76,17 @@ class CharacterInfo(BaseModel):
|
|||||||
|
|
||||||
# Load icon
|
# Load icon
|
||||||
__pydantic_self__.image = CharacterImages(
|
__pydantic_self__.image = CharacterImages(
|
||||||
icon=create_ui_path(character["SideIconName"].replace("_Side", "")),
|
icon=create_ui_path(character["sideIconName"].replace("_Side", "")),
|
||||||
side=create_ui_path(character["SideIconName"]),
|
side=create_ui_path(character["sideIconName"]),
|
||||||
gacha=create_ui_path(character["SideIconName"].replace("AvatarIcon_Side", "Gacha_AvatarImg"))
|
gacha=create_ui_path(character["sideIconName"].replace("AvatarIcon_Side", "Gacha_AvatarImg"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Get element
|
||||||
|
__pydantic_self__.element = ElementType[character["costElemType"]]
|
||||||
|
|
||||||
# Load constellation
|
# Load constellation
|
||||||
LOGGER.debug(f"=== Constellation ===")
|
LOGGER.debug(f"=== Constellation ===")
|
||||||
for constellation in character["Consts"]:
|
for constellation in character["talents"]:
|
||||||
LOGGER.debug(f"Getting constellation icon ID: {constellation}")
|
LOGGER.debug(f"Getting constellation icon ID: {constellation}")
|
||||||
_constellation = Config.DATA["constellations"].get(str(constellation))
|
_constellation = Config.DATA["constellations"].get(str(constellation))
|
||||||
|
|
||||||
@ -98,15 +103,15 @@ class CharacterInfo(BaseModel):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
__pydantic_self__.constellations.append(CharacterConstellations(
|
__pydantic_self__.constellations.append(CharacterConstellations(
|
||||||
id=_constellation["talentId"],
|
id=int(constellation),
|
||||||
name=_name[Config.LANGS],
|
name=_name[Config.LANGS],
|
||||||
icon=create_ui_path(constellation),
|
icon=create_ui_path(_constellation["icon"]),
|
||||||
unlocked=_constellation["talentId"] in data["talentIdList"] if "talentIdList" in data else False
|
unlocked=int(constellation) in data["talentIdList"] if "talentIdList" in data else False
|
||||||
))
|
))
|
||||||
|
|
||||||
# Load skills
|
# Load skills
|
||||||
LOGGER.debug(f"=== Skills ===")
|
LOGGER.debug(f"=== Skills ===")
|
||||||
for skill in character["SkillOrder"]:
|
for skill in character["skills"]:
|
||||||
LOGGER.debug(f"Getting skill ID: {skill}")
|
LOGGER.debug(f"Getting skill ID: {skill}")
|
||||||
_skill = Config.DATA["skills"].get(str(skill))
|
_skill = Config.DATA["skills"].get(str(skill))
|
||||||
|
|
||||||
@ -139,5 +144,6 @@ class CharacterInfo(BaseModel):
|
|||||||
|
|
||||||
# Get name from hash map
|
# Get name from hash map
|
||||||
__pydantic_self__.name = _name[Config.LANGS]
|
__pydantic_self__.name = _name[Config.LANGS]
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
use_enum_values = True
|
@ -63,6 +63,7 @@ class EquipmentsDetail(BaseModel):
|
|||||||
|
|
||||||
if data["itemType"] == "ITEM_RELIQUARY": # AKA. Artifact
|
if data["itemType"] == "ITEM_RELIQUARY": # AKA. Artifact
|
||||||
LOGGER.debug(f"=== Artifact ===")
|
LOGGER.debug(f"=== Artifact ===")
|
||||||
|
__pydantic_self__.icon = create_ui_path(data["icon"])
|
||||||
__pydantic_self__.artifactType = EquipType[data["equipType"]]
|
__pydantic_self__.artifactType = EquipType[data["equipType"]]
|
||||||
# Sub Stats
|
# Sub Stats
|
||||||
for stats in data["reliquarySubstats"]:
|
for stats in data["reliquarySubstats"]:
|
||||||
|
@ -16,7 +16,7 @@ class ProfilePicture(BaseModel):
|
|||||||
"""
|
"""
|
||||||
Custom add data
|
Custom add data
|
||||||
"""
|
"""
|
||||||
icon: str = ""
|
url: str = ""
|
||||||
|
|
||||||
def __init__(__pydantic_self__, **data: Any) -> None:
|
def __init__(__pydantic_self__, **data: Any) -> None:
|
||||||
super().__init__(**data)
|
super().__init__(**data)
|
||||||
@ -29,7 +29,7 @@ class ProfilePicture(BaseModel):
|
|||||||
LOGGER.error(f"Character not found with id: {data['avatarId']}")
|
LOGGER.error(f"Character not found with id: {data['avatarId']}")
|
||||||
return
|
return
|
||||||
|
|
||||||
__pydantic_self__.icon = create_ui_path(character["SideIconName"].replace("_Side", ""))
|
__pydantic_self__.url = create_ui_path(character["sideIconName"].replace("_Side", ""))
|
||||||
|
|
||||||
class showAvatar(BaseModel):
|
class showAvatar(BaseModel):
|
||||||
"""
|
"""
|
||||||
@ -56,7 +56,7 @@ class showAvatar(BaseModel):
|
|||||||
LOGGER.error(f"Character preview not found with id: {__pydantic_self__.id}")
|
LOGGER.error(f"Character preview not found with id: {__pydantic_self__.id}")
|
||||||
return
|
return
|
||||||
|
|
||||||
__pydantic_self__.icon = create_ui_path(character_preview["SideIconName"].replace("_Side", ""))
|
__pydantic_self__.icon = create_ui_path(character_preview["sideIconName"].replace("_Side", ""))
|
||||||
|
|
||||||
# Get name hash map
|
# Get name hash map
|
||||||
LOGGER.debug(f"Getting name hash map id: {character_preview['nameTextMapHash']}")
|
LOGGER.debug(f"Getting name hash map id: {character_preview['nameTextMapHash']}")
|
||||||
@ -90,8 +90,8 @@ class Namecard(BaseModel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
__pydantic_self__.icon = create_ui_path(namecard["icon"])
|
__pydantic_self__.icon = create_ui_path(namecard["icon"])
|
||||||
__pydantic_self__.banner = create_ui_path(namecard["banner"])
|
__pydantic_self__.banner = create_ui_path(namecard["picPath"][1])
|
||||||
__pydantic_self__.navbar = create_ui_path(namecard["navbar"])
|
__pydantic_self__.navbar = create_ui_path(namecard["picPath"][0])
|
||||||
|
|
||||||
LOGGER.debug(f"Getting name hash map id: {namecard['nameTextMapHash']}")
|
LOGGER.debug(f"Getting name hash map id: {namecard['nameTextMapHash']}")
|
||||||
_name = Config.HASH_MAP["namecards"].get(str(namecard["nameTextMapHash"]))
|
_name = Config.HASH_MAP["namecards"].get(str(namecard["nameTextMapHash"]))
|
||||||
@ -111,7 +111,7 @@ class PlayerInfo(BaseModel):
|
|||||||
nickname: str = ""
|
nickname: str = ""
|
||||||
signature: str = ""
|
signature: str = ""
|
||||||
world_level: int = Field(1, alias="worldLevel")
|
world_level: int = Field(1, alias="worldLevel")
|
||||||
profile_picture: ProfilePicture = Field(None, alias="profilePicture")
|
icon: ProfilePicture = Field(None, alias="profilePicture")
|
||||||
# Avatars
|
# Avatars
|
||||||
characters_preview: List[showAvatar] = Field([], alias="showAvatarInfoList")
|
characters_preview: List[showAvatar] = Field([], alias="showAvatarInfoList")
|
||||||
# Abyss floor
|
# Abyss floor
|
||||||
|
Loading…
Reference in New Issue
Block a user