# hero

from models.heroes.character import Character
from models.loots.armor import Armor
from models.loots.weapon import Weapon

from sty import fg


class Hero(Character):
    ARCHERY = 1
    WARRIOR = 2
    WIZARD = 3
    BEAST = 7
    HUMANOID = 8
    UNDEAD = 9
    DRAGON = 10
    ELEMENTAL = 11

    def __init__(
        self,
        name: str,
        description: str,
        HP: int,
        attack_power: int,
        defense: int,
        type: str,
        armor: Armor = None,
        weapon: Weapon = None,
    ) -> None:
        super().__init__(name, description, HP)
        self.attack_power = attack_power
        self.defense = defense
        self.type = type
        self.armor = armor
        self.weapon = weapon

        self.attacks_choice: list = ["Attacks", "Cure"]

    def get_type_str(self) -> str:
        return "Heroes"

    def attacks(self, opponent: "Hero") -> float:
        power = None
        if self.weapon:
            print(f"{self.name} {fg.red}attacks{fg.rs} with {self.weapon.name}")
            power = self.weapon.power
        else:
            print(
                f"{self.name} {fg.red}attacks{fg.rs} with {fg.yellow}bare hands{fg.rs}"
            )
            power = self.attack_power

        if opponent.armor:
            power -= opponent.defends()

        return power

    def defends(self) -> float:
        if self.armor:
            print(
                f"{self.armor.name} {fg.blue}delete{fg.rs} {self.armor.defense} damage points"
            )
            return self.armor.defense
        else:
            return 0

    def cure(self, hero: "Hero" = None):
        target = hero if hero else self

        UP_HP = 10
        print(
            f"{target.name}: {target.HP} {fg.green}HP{fg.rs} +{UP_HP}{fg.green}HP{fg.rs}"
        )
        target.HP += UP_HP

        print(f"{target.name}: {target.HP} {fg.green}HP{fg.rs}")

        return UP_HP
