# coding: utf-8

"""
    Artifacts API

     Artifacts is an API-based MMO game where you can manage 5 characters to explore, fight, gather resources, craft items and much more.  Website: https://artifactsmmo.com/  Documentation: https://docs.artifactsmmo.com/  OpenAPI Spec: https://api.artifactsmmo.com/openapi.json 

    The version of the OpenAPI document: 1.6
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from pyartifactsmmo.models.inventory_slot import InventorySlot
from typing import Optional, Set
from typing_extensions import Self

class CharacterSchema(BaseModel):
    """
    CharacterSchema
    """ # noqa: E501
    name: StrictStr = Field(description="Name of the character.")
    skin: StrictStr = Field(description="Character skin code.")
    level: StrictInt = Field(description="Combat level.")
    xp: StrictInt = Field(description="The current xp level of the combat level.")
    max_xp: StrictInt = Field(description="XP required to level up the character.")
    total_xp: StrictInt = Field(description="Total XP of your character.")
    gold: StrictInt = Field(description="The numbers of golds on this character.")
    speed: StrictInt = Field(description="*Not available, on the roadmap. Character movement speed.")
    mining_level: StrictInt = Field(description="Mining level.")
    mining_xp: StrictInt = Field(description="The current xp level of the Mining skill.")
    mining_max_xp: StrictInt = Field(description="Mining XP required to level up the skill.")
    woodcutting_level: StrictInt = Field(description="Woodcutting level.")
    woodcutting_xp: StrictInt = Field(description="The current xp level of the Woodcutting skill.")
    woodcutting_max_xp: StrictInt = Field(description="Woodcutting XP required to level up the skill.")
    fishing_level: StrictInt = Field(description="Fishing level.")
    fishing_xp: StrictInt = Field(description="The current xp level of the Fishing skill.")
    fishing_max_xp: StrictInt = Field(description="Fishing XP required to level up the skill.")
    weaponcrafting_level: StrictInt = Field(description="Weaponcrafting level.")
    weaponcrafting_xp: StrictInt = Field(description="The current xp level of the Weaponcrafting skill.")
    weaponcrafting_max_xp: StrictInt = Field(description="Weaponcrafting XP required to level up the skill.")
    gearcrafting_level: StrictInt = Field(description="Gearcrafting level.")
    gearcrafting_xp: StrictInt = Field(description="The current xp level of the Gearcrafting skill.")
    gearcrafting_max_xp: StrictInt = Field(description="Gearcrafting XP required to level up the skill.")
    jewelrycrafting_level: StrictInt = Field(description="Jewelrycrafting level.")
    jewelrycrafting_xp: StrictInt = Field(description="The current xp level of the Jewelrycrafting skill.")
    jewelrycrafting_max_xp: StrictInt = Field(description="Jewelrycrafting XP required to level up the skill.")
    cooking_level: StrictInt = Field(description="The current xp level of the Cooking skill.")
    cooking_xp: StrictInt = Field(description="Cooking XP.")
    cooking_max_xp: StrictInt = Field(description="Cooking XP required to level up the skill.")
    hp: StrictInt = Field(description="Character HP.")
    haste: StrictInt = Field(description="*Character Haste. Increase speed attack (reduce fight cooldown)")
    critical_strike: StrictInt = Field(description="*Not available, on the roadmap. Character Critical   Strike. Critical strikes increase the attack's damage.")
    stamina: StrictInt = Field(description="*Not available, on the roadmap. Regenerates life at the start of each turn.")
    attack_fire: StrictInt = Field(description="Fire attack.")
    attack_earth: StrictInt = Field(description="Earth attack.")
    attack_water: StrictInt = Field(description="Water attack.")
    attack_air: StrictInt = Field(description="Air attack.")
    dmg_fire: StrictInt = Field(description="% Fire damage.")
    dmg_earth: StrictInt = Field(description="% Earth damage.")
    dmg_water: StrictInt = Field(description="% Water damage.")
    dmg_air: StrictInt = Field(description="% Air damage.")
    res_fire: StrictInt = Field(description="% Fire resistance.")
    res_earth: StrictInt = Field(description="% Earth resistance.")
    res_water: StrictInt = Field(description="% Water resistance.")
    res_air: StrictInt = Field(description="% Air resistance.")
    x: StrictInt = Field(description="Character x coordinate.")
    y: StrictInt = Field(description="Character y coordinate.")
    cooldown: StrictInt = Field(description="Cooldown in seconds.")
    cooldown_expiration: Optional[datetime] = Field(default=None, description="Datetime Cooldown expiration.")
    weapon_slot: StrictStr = Field(description="Weapon slot.")
    shield_slot: StrictStr = Field(description="Shield slot.")
    helmet_slot: StrictStr = Field(description="Helmet slot.")
    body_armor_slot: StrictStr = Field(description="Body armor slot.")
    leg_armor_slot: StrictStr = Field(description="Leg armor slot.")
    boots_slot: StrictStr = Field(description="Boots slot.")
    ring1_slot: StrictStr = Field(description="Ring 1 slot.")
    ring2_slot: StrictStr = Field(description="Ring 2 slot.")
    amulet_slot: StrictStr = Field(description="Amulet slot.")
    artifact1_slot: StrictStr = Field(description="Artifact 1 slot.")
    artifact2_slot: StrictStr = Field(description="Artifact 2 slot.")
    artifact3_slot: StrictStr = Field(description="Artifact 3 slot.")
    consumable1_slot: StrictStr = Field(description="Consumable 1 slot.")
    consumable1_slot_quantity: StrictInt = Field(description="Consumable 1 quantity.")
    consumable2_slot: StrictStr = Field(description="Consumable 2 slot.")
    consumable2_slot_quantity: StrictInt = Field(description="Consumable 2 quantity.")
    task: StrictStr = Field(description="Task in progress.")
    task_type: StrictStr = Field(description="Task type.")
    task_progress: StrictInt = Field(description="Task progression.")
    task_total: StrictInt = Field(description="Task total objective.")
    inventory_max_items: StrictInt = Field(description="Inventory max items.")
    inventory: Optional[List[InventorySlot]] = Field(default=None, description="List of inventory slots.")
    __properties: ClassVar[List[str]] = ["name", "skin", "level", "xp", "max_xp", "total_xp", "gold", "speed", "mining_level", "mining_xp", "mining_max_xp", "woodcutting_level", "woodcutting_xp", "woodcutting_max_xp", "fishing_level", "fishing_xp", "fishing_max_xp", "weaponcrafting_level", "weaponcrafting_xp", "weaponcrafting_max_xp", "gearcrafting_level", "gearcrafting_xp", "gearcrafting_max_xp", "jewelrycrafting_level", "jewelrycrafting_xp", "jewelrycrafting_max_xp", "cooking_level", "cooking_xp", "cooking_max_xp", "hp", "haste", "critical_strike", "stamina", "attack_fire", "attack_earth", "attack_water", "attack_air", "dmg_fire", "dmg_earth", "dmg_water", "dmg_air", "res_fire", "res_earth", "res_water", "res_air", "x", "y", "cooldown", "cooldown_expiration", "weapon_slot", "shield_slot", "helmet_slot", "body_armor_slot", "leg_armor_slot", "boots_slot", "ring1_slot", "ring2_slot", "amulet_slot", "artifact1_slot", "artifact2_slot", "artifact3_slot", "consumable1_slot", "consumable1_slot_quantity", "consumable2_slot", "consumable2_slot_quantity", "task", "task_type", "task_progress", "task_total", "inventory_max_items", "inventory"]

    @field_validator('skin')
    def skin_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['men1', 'men2', 'men3', 'women1', 'women2', 'women3']):
            raise ValueError("must be one of enum values ('men1', 'men2', 'men3', 'women1', 'women2', 'women3')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of CharacterSchema from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in inventory (list)
        _items = []
        if self.inventory:
            for _item_inventory in self.inventory:
                if _item_inventory:
                    _items.append(_item_inventory.to_dict())
            _dict['inventory'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CharacterSchema from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "skin": obj.get("skin"),
            "level": obj.get("level"),
            "xp": obj.get("xp"),
            "max_xp": obj.get("max_xp"),
            "total_xp": obj.get("total_xp"),
            "gold": obj.get("gold"),
            "speed": obj.get("speed"),
            "mining_level": obj.get("mining_level"),
            "mining_xp": obj.get("mining_xp"),
            "mining_max_xp": obj.get("mining_max_xp"),
            "woodcutting_level": obj.get("woodcutting_level"),
            "woodcutting_xp": obj.get("woodcutting_xp"),
            "woodcutting_max_xp": obj.get("woodcutting_max_xp"),
            "fishing_level": obj.get("fishing_level"),
            "fishing_xp": obj.get("fishing_xp"),
            "fishing_max_xp": obj.get("fishing_max_xp"),
            "weaponcrafting_level": obj.get("weaponcrafting_level"),
            "weaponcrafting_xp": obj.get("weaponcrafting_xp"),
            "weaponcrafting_max_xp": obj.get("weaponcrafting_max_xp"),
            "gearcrafting_level": obj.get("gearcrafting_level"),
            "gearcrafting_xp": obj.get("gearcrafting_xp"),
            "gearcrafting_max_xp": obj.get("gearcrafting_max_xp"),
            "jewelrycrafting_level": obj.get("jewelrycrafting_level"),
            "jewelrycrafting_xp": obj.get("jewelrycrafting_xp"),
            "jewelrycrafting_max_xp": obj.get("jewelrycrafting_max_xp"),
            "cooking_level": obj.get("cooking_level"),
            "cooking_xp": obj.get("cooking_xp"),
            "cooking_max_xp": obj.get("cooking_max_xp"),
            "hp": obj.get("hp"),
            "haste": obj.get("haste"),
            "critical_strike": obj.get("critical_strike"),
            "stamina": obj.get("stamina"),
            "attack_fire": obj.get("attack_fire"),
            "attack_earth": obj.get("attack_earth"),
            "attack_water": obj.get("attack_water"),
            "attack_air": obj.get("attack_air"),
            "dmg_fire": obj.get("dmg_fire"),
            "dmg_earth": obj.get("dmg_earth"),
            "dmg_water": obj.get("dmg_water"),
            "dmg_air": obj.get("dmg_air"),
            "res_fire": obj.get("res_fire"),
            "res_earth": obj.get("res_earth"),
            "res_water": obj.get("res_water"),
            "res_air": obj.get("res_air"),
            "x": obj.get("x"),
            "y": obj.get("y"),
            "cooldown": obj.get("cooldown"),
            "cooldown_expiration": obj.get("cooldown_expiration"),
            "weapon_slot": obj.get("weapon_slot"),
            "shield_slot": obj.get("shield_slot"),
            "helmet_slot": obj.get("helmet_slot"),
            "body_armor_slot": obj.get("body_armor_slot"),
            "leg_armor_slot": obj.get("leg_armor_slot"),
            "boots_slot": obj.get("boots_slot"),
            "ring1_slot": obj.get("ring1_slot"),
            "ring2_slot": obj.get("ring2_slot"),
            "amulet_slot": obj.get("amulet_slot"),
            "artifact1_slot": obj.get("artifact1_slot"),
            "artifact2_slot": obj.get("artifact2_slot"),
            "artifact3_slot": obj.get("artifact3_slot"),
            "consumable1_slot": obj.get("consumable1_slot"),
            "consumable1_slot_quantity": obj.get("consumable1_slot_quantity"),
            "consumable2_slot": obj.get("consumable2_slot"),
            "consumable2_slot_quantity": obj.get("consumable2_slot_quantity"),
            "task": obj.get("task"),
            "task_type": obj.get("task_type"),
            "task_progress": obj.get("task_progress"),
            "task_total": obj.get("task_total"),
            "inventory_max_items": obj.get("inventory_max_items"),
            "inventory": [InventorySlot.from_dict(_item) for _item in obj["inventory"]] if obj.get("inventory") is not None else None
        })
        return _obj


