/**
 * Normalized shapes over the Open5e SRD data. Fields mirror the source JSON;
 * optional because the dataset is not perfectly uniform.
 */
export interface MonsterAction {
  name: string;
  desc: string;
  attack_bonus?: number;
  damage_dice?: string;
  damage_bonus?: number;
}

export interface Monster {
  slug: string;
  name: string;
  size?: string;
  type?: string;
  subtype?: string;
  alignment?: string;
  armor_class?: number;
  armor_desc?: string | null;
  hit_points?: number;
  hit_dice?: string;
  speed?: Record<string, number> | { walk?: number; [k: string]: number | undefined };
  strength?: number;
  dexterity?: number;
  constitution?: number;
  intelligence?: number;
  wisdom?: number;
  charisma?: number;
  perception?: number;
  senses?: string;
  languages?: string;
  /** numeric challenge rating (0.25 for "1/4") */
  cr?: number;
  challenge_rating?: string;
  actions?: MonsterAction[] | string;
  special_abilities?: MonsterAction[] | string;
  legendary_actions?: MonsterAction[] | string;
  reactions?: MonsterAction[] | string;
  damage_vulnerabilities?: string;
  damage_resistances?: string;
  damage_immunities?: string;
  condition_immunities?: string;
  desc?: string;
}

export interface Spell {
  slug: string;
  name: string;
  desc?: string;
  higher_level?: string;
  level?: string;
  level_int?: number;
  school?: string;
  casting_time?: string;
  range?: string;
  duration?: string;
  concentration?: boolean | string;
  requires_concentration?: boolean;
  ritual?: boolean | string;
  can_be_cast_as_ritual?: boolean;
  components?: string;
  material?: string;
  dnd_class?: string;
}

export interface MagicItem {
  slug: string;
  name: string;
  type?: string;
  desc?: string;
  rarity?: string;
  requires_attunement?: string;
}

export type CompendiumKind = 'monsters' | 'spells' | 'items';

/** A loosely-typed entry for the generic, registry-driven categories. */
export type CompendiumEntry = Record<string, unknown> & { name: string; slug?: string };

export interface Weapon5e {
  name: string;
  slug: string;
  category?: string;
  cost?: string;
  damage_dice?: string;
  damage_type?: string;
  weight?: string | number;
  properties?: string[];
}

export interface Armor5e {
  name: string;
  type?: string;
  ac?: string;
  dexCap?: number | null;
  stealthPenalty?: boolean;
  weight?: number;
  cost?: string;
}

export interface Feat5e {
  name: string;
  description?: string;
  source?: { source: string; page: number }[];
}

export interface Condition5e {
  name: string;
  description?: string;
  effects?: string[];
}
