"""Mirrors upstream src/2014/schemas/5e-SRD-Levels.ts."""

from pydantic import Field

from dnd5e_db.models.base import SRDModel
from dnd5e_db.models.common import APIReference


class CreatingSpellSlot(SRDModel):
    sorcery_point_cost: int
    spell_slot_level: int


class MartialArts(SRDModel):
    dice_count: int
    dice_value: int


class SneakAttack(SRDModel):
    dice_count: int
    dice_value: int


class ClassSpecific(SRDModel):
    action_surges: int | None = None
    arcane_recovery_levels: int | None = None
    aura_range: int | None = None
    bardic_inspiration_die: int | None = None
    brutal_critical_dice: int | None = None
    channel_divinity_charges: int | None = None
    creating_spell_slots: list[CreatingSpellSlot] | None = None
    destroy_undead_cr: float | None = None
    extra_attacks: int | None = None
    favored_enemies: int | None = None
    favored_terrain: int | None = None
    indomitable_uses: int | None = None
    invocations_known: int | None = None
    ki_points: int | None = None
    magical_secrets_max_5: int | None = None
    magical_secrets_max_7: int | None = None
    magical_secrets_max_9: int | None = None
    martial_arts: MartialArts | None = None
    metamagic_known: int | None = None
    mystic_arcanum_level_6: int | None = None
    mystic_arcanum_level_7: int | None = None
    mystic_arcanum_level_8: int | None = None
    mystic_arcanum_level_9: int | None = None
    rage_count: int | None = None
    rage_damage_bonus: int | None = None
    sneak_attack: SneakAttack | None = None
    song_of_rest_die: int | None = None
    sorcery_points: int | None = None
    unarmored_movement: int | None = None
    wild_shape_fly: bool | None = None
    wild_shape_max_cr: float | None = None
    wild_shape_swim: bool | None = None


class LevelSpellcasting(SRDModel):
    cantrips_known: int | None = None
    spell_slots_level_1: int
    spell_slots_level_2: int
    spell_slots_level_3: int
    spell_slots_level_4: int
    spell_slots_level_5: int
    spell_slots_level_6: int | None = None
    spell_slots_level_7: int | None = None
    spell_slots_level_8: int | None = None
    spell_slots_level_9: int | None = None
    spells_known: int | None = None


class SubclassSpecific(SRDModel):
    additional_magical_secrets_max_lvl: int | None = None
    aura_range: int | None = None


class Level(SRDModel):
    index: str
    level: int
    ability_score_bonuses: int | None = None
    prof_bonus: int | None = None
    features: list[APIReference] | None = None
    class_: APIReference = Field(alias="class")
    class_specific: ClassSpecific | None = None
    spellcasting: LevelSpellcasting | None = None
    subclass: APIReference | None = None
    subclass_specific: SubclassSpecific | None = None
    url: str
