import { ApiProperty } from '@nestjs/swagger';
import { IsObject, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';

// Pathbuilder JSON structure
export interface PathbuilderBuild {
  name: string;
  class: string;
  dualClass?: string | null;
  level: number;
  xp: number;
  ancestry: string;
  heritage: string;
  background: string;
  alignment: string;
  gender: string;
  age: string;
  deity: string;
  size: number;
  sizeName: string;
  keyability: string;
  languages: string[];
  abilities: {
    str: number;
    dex: number;
    con: number;
    int: number;
    wis: number;
    cha: number;
    breakdown?: unknown;
  };
  attributes: {
    ancestryhp: number;
    classhp: number;
    bonushp: number;
    bonushpPerLevel: number;
    speed: number;
    speedBonus: number;
  };
  proficiencies: {
    classDC: number;
    perception: number;
    fortitude: number;
    reflex: number;
    will: number;
    heavy: number;
    medium: number;
    light: number;
    unarmored: number;
    advanced: number;
    martial: number;
    simple: number;
    unarmed: number;
    castingArcane: number;
    castingDivine: number;
    castingOccult: number;
    castingPrimal: number;
    acrobatics: number;
    arcana: number;
    athletics: number;
    crafting: number;
    deception: number;
    diplomacy: number;
    intimidation: number;
    medicine: number;
    nature: number;
    occultism: number;
    performance: number;
    religion: number;
    society: number;
    stealth: number;
    survival: number;
    thievery: number;
  };
  feats: Array<[string, unknown, string, number, ...unknown[]]>;
  specials: string[];
  lores: Array<[string, number]>;
  equipment: Array<[string, number, string?]>;
  weapons: Array<{
    name: string;
    qty: number;
    prof: string;
    die: string;
    pot: number;
    str: string;
    mat: string | null;
    display: string;
    runes: string[];
    damageType: string;
    attack: number;
    damageBonus: number;
    extraDamage: string[];
    increasedDice: boolean;
    isInventor: boolean;
  }>;
  armor: Array<{
    name: string;
    qty: number;
    prof: string;
    pot: number;
    res: string;
    mat: string | null;
    display: string;
    worn: boolean;
    runes: string[];
  }>;
  money: {
    cp: number;
    sp: number;
    gp: number;
    pp: number;
  };
  spellCasters: Array<{
    name: string;
    magicTradition: string;
    spellcastingType: string;
    ability: string;
    proficiency: number;
    focusPoints: number;
    spells: Array<{
      spellLevel: number;
      list: string[];
    }>;
    perDay: number[];
  }>;
  focusPoints: number;
  focus: unknown;
  formula: Array<{
    type: string;
    known: string[];
  }>;
  acTotal: {
    acProfBonus: number;
    acAbilityBonus: number;
    acItemBonus: number;
    acTotal: number;
    shieldBonus: number | null;
  };
  pets: unknown[];
  familiars: unknown[];
}

export interface PathbuilderJson {
  success: boolean;
  build: PathbuilderBuild;
}

export class PathbuilderImportDto {
  @ApiProperty({ description: 'Raw Pathbuilder export JSON' })
  @IsObject()
  pathbuilderJson: PathbuilderJson;
}
