diff --git a/enkanetwork/model/character.py b/enkanetwork/model/character.py index 3dd85a7..babe674 100644 --- a/enkanetwork/model/character.py +++ b/enkanetwork/model/character.py @@ -7,6 +7,7 @@ from .equipments import Equipments from .combats import CharacterCombat from ..json import Config from ..utils import create_ui_path +from ..enum import ElementType LOGGER = logging.getLogger(__name__) @@ -45,6 +46,7 @@ class CharacterInfo(BaseModel): Custom data """ name: str = "" # Get from name hash map + element: ElementType = ElementType.Unknown image: CharacterImages = CharacterImages() skills: List[CharacterSkill] = [] constellations: List[CharacterConstellations] = [] @@ -74,14 +76,17 @@ class CharacterInfo(BaseModel): # Load icon __pydantic_self__.image = CharacterImages( - icon=create_ui_path(character["SideIconName"].replace("_Side", "")), - side=create_ui_path(character["SideIconName"]), - gacha=create_ui_path(character["SideIconName"].replace("AvatarIcon_Side", "Gacha_AvatarImg")) + icon=create_ui_path(character["sideIconName"].replace("_Side", "")), + side=create_ui_path(character["sideIconName"]), + gacha=create_ui_path(character["sideIconName"].replace("AvatarIcon_Side", "Gacha_AvatarImg")) ) + # Get element + __pydantic_self__.element = ElementType[character["costElemType"]] + # Load constellation LOGGER.debug(f"=== Constellation ===") - for constellation in character["Consts"]: + for constellation in character["talents"]: LOGGER.debug(f"Getting constellation icon ID: {constellation}") _constellation = Config.DATA["constellations"].get(str(constellation)) @@ -98,15 +103,15 @@ class CharacterInfo(BaseModel): continue __pydantic_self__.constellations.append(CharacterConstellations( - id=_constellation["talentId"], + id=int(constellation), name=_name[Config.LANGS], - icon=create_ui_path(constellation), - unlocked=_constellation["talentId"] in data["talentIdList"] if "talentIdList" in data else False + icon=create_ui_path(_constellation["icon"]), + unlocked=int(constellation) in data["talentIdList"] if "talentIdList" in data else False )) # Load skills LOGGER.debug(f"=== Skills ===") - for skill in character["SkillOrder"]: + for skill in character["skills"]: LOGGER.debug(f"Getting skill ID: {skill}") _skill = Config.DATA["skills"].get(str(skill)) @@ -139,5 +144,6 @@ class CharacterInfo(BaseModel): # Get name from hash map __pydantic_self__.name = _name[Config.LANGS] - - \ No newline at end of file + + class Config: + use_enum_values = True \ No newline at end of file diff --git a/enkanetwork/model/equipments.py b/enkanetwork/model/equipments.py index ad5d52f..4ff956d 100644 --- a/enkanetwork/model/equipments.py +++ b/enkanetwork/model/equipments.py @@ -63,6 +63,7 @@ class EquipmentsDetail(BaseModel): if data["itemType"] == "ITEM_RELIQUARY": # AKA. Artifact LOGGER.debug(f"=== Artifact ===") + __pydantic_self__.icon = create_ui_path(data["icon"]) __pydantic_self__.artifactType = EquipType[data["equipType"]] # Sub Stats for stats in data["reliquarySubstats"]: diff --git a/enkanetwork/model/players.py b/enkanetwork/model/players.py index b504d42..5a095bc 100644 --- a/enkanetwork/model/players.py +++ b/enkanetwork/model/players.py @@ -16,7 +16,7 @@ class ProfilePicture(BaseModel): """ Custom add data """ - icon: str = "" + url: str = "" def __init__(__pydantic_self__, **data: Any) -> None: super().__init__(**data) @@ -29,7 +29,7 @@ class ProfilePicture(BaseModel): LOGGER.error(f"Character not found with id: {data['avatarId']}") return - __pydantic_self__.icon = create_ui_path(character["SideIconName"].replace("_Side", "")) + __pydantic_self__.url = create_ui_path(character["sideIconName"].replace("_Side", "")) class showAvatar(BaseModel): """ @@ -56,7 +56,7 @@ class showAvatar(BaseModel): LOGGER.error(f"Character preview not found with id: {__pydantic_self__.id}") 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 LOGGER.debug(f"Getting name hash map id: {character_preview['nameTextMapHash']}") @@ -90,8 +90,8 @@ class Namecard(BaseModel): return __pydantic_self__.icon = create_ui_path(namecard["icon"]) - __pydantic_self__.banner = create_ui_path(namecard["banner"]) - __pydantic_self__.navbar = create_ui_path(namecard["navbar"]) + __pydantic_self__.banner = create_ui_path(namecard["picPath"][1]) + __pydantic_self__.navbar = create_ui_path(namecard["picPath"][0]) LOGGER.debug(f"Getting name hash map id: {namecard['nameTextMapHash']}") _name = Config.HASH_MAP["namecards"].get(str(namecard["nameTextMapHash"])) @@ -111,7 +111,7 @@ class PlayerInfo(BaseModel): nickname: str = "" signature: str = "" world_level: int = Field(1, alias="worldLevel") - profile_picture: ProfilePicture = Field(None, alias="profilePicture") + icon: ProfilePicture = Field(None, alias="profilePicture") # Avatars characters_preview: List[showAvatar] = Field([], alias="showAvatarInfoList") # Abyss floor