"""Mirrors upstream src/2024/schemas/5e-SRD-Monsters.ts."""

from dnd5e_db.models.base import SRDModel
from dnd5e_db.models.common import APIReference, Choice, Damage, DifficultyClass


class MonsterSpeed(SRDModel):
    walk: str | None = None
    burrow: str | None = None
    climb: str | None = None
    fly: str | None = None
    swim: str | None = None
    hover: bool | None = None


class Sense(SRDModel):
    passive_perception: int
    blindsight: str | None = None
    darkvision: str | None = None
    tremorsense: str | None = None
    truesight: str | None = None


class MonsterProficiency(SRDModel):
    value: int
    proficiency: APIReference


class MonsterArmorClass(SRDModel):
    type: str
    value: int
    armor: list[APIReference] | None = None
    condition: APIReference | None = None
    spell: APIReference | None = None
    desc: str | None = None


class SpecialAbilityUsage(SRDModel):
    type: str
    times: int | None = None
    times_in_lair: int | None = None
    rest_types: list[str] | None = None


class SpellcastingSpellUsage(SRDModel):
    type: str
    times: int | None = None


class SpellcastingSpell(SRDModel):
    index: str
    name: str
    level: int
    url: str
    usage: SpellcastingSpellUsage | None = None
    notes: str | None = None


class MonsterSpellcasting(SRDModel):
    ability: APIReference
    components_required: list[str]
    spells: list[SpellcastingSpell]
    level: int | None = None
    dc: int | None = None
    modifier: int | None = None
    school: str | None = None
    slots: dict[str, int] | None = None


class ActionUsage(SRDModel):
    type: str
    dice: str | None = None
    min_value: int | None = None
    times: int | None = None


class MonsterActionItem(SRDModel):
    action_name: str
    count: int | str
    type: str


class MonsterAttack(SRDModel):
    name: str
    dc: DifficultyClass
    damage: list[Damage] | None = None


class MonsterAction(SRDModel):
    name: str
    desc: str
    attack_bonus: int | None = None
    dc: DifficultyClass | None = None
    usage: ActionUsage | None = None
    multiattack_type: str | None = None
    actions: list[MonsterActionItem] | None = None
    action_options: Choice | None = None
    attacks: list[MonsterAttack] | None = None
    options: Choice | None = None
    damage: list[Damage | Choice] | None = None
    spellcasting: MonsterSpellcasting | None = None


class LegendaryAction(SRDModel):
    name: str
    desc: str
    attack_bonus: int | None = None
    damage: list[Damage] | None = None
    dc: DifficultyClass | None = None


class Reaction(SRDModel):
    name: str
    desc: str
    dc: DifficultyClass | None = None


class SpecialAbility(SRDModel):
    name: str
    desc: str
    attack_bonus: int | None = None
    damage: list[Damage] | None = None
    dc: DifficultyClass | None = None
    usage: SpecialAbilityUsage | None = None
    spellcasting: MonsterSpellcasting | None = None


class Monster(SRDModel):
    index: str
    name: str
    size: str
    type: str
    subtype: str | None = None
    alignment: str
    armor_class: list[MonsterArmorClass]
    hit_points: int
    hit_dice: str
    hit_points_roll: str
    speed: MonsterSpeed
    strength: int
    dexterity: int
    constitution: int
    intelligence: int
    wisdom: int
    charisma: int
    proficiencies: list[MonsterProficiency]
    damage_vulnerabilities: list[str]
    damage_resistances: list[str]
    damage_immunities: list[str]
    condition_immunities: list[APIReference]
    senses: Sense
    languages: str
    challenge_rating: float
    proficiency_bonus: int | None = None
    xp: int
    xp_in_lair: int | None = None
    special_abilities: list[SpecialAbility] | None = None
    actions: list[MonsterAction] | None = None
    legendary_actions: list[LegendaryAction] | None = None
    reactions: list[Reaction] | None = None
    forms: list[APIReference] | None = None
    image: str | None = None
    url: str
