import HeritiersActorSheet from "./base-actor-sheet.mjs"

export default class HeritiersPersonnageSheet extends HeritiersActorSheet {
  /** @override */
  static DEFAULT_OPTIONS = {
    ...super.DEFAULT_OPTIONS,
    classes: [...super.DEFAULT_OPTIONS.classes],
    window: {
      ...super.DEFAULT_OPTIONS.window,
      title: "SHEETS.Actor.personnage",
    },
    actions: {
      ...super.DEFAULT_OPTIONS.actions,
    },
  }

  /** @override */
  static PARTS = {
    sheet: {
      template: "systems/fvtt-les-heritiers/templates/actor-sheet.hbs",
    },
  }

  /** @override */
  tabGroups = { primary: "competences" }

  /** @override */
  async _prepareContext() {
    const context = await super._prepareContext()
    const actor = this.document

    // Add personnage-specific data
    context.skills = actor.getSkills()
    context.utileSkillsMental = actor.organizeUtileSkills("mental")
    context.utileSkillsPhysical = actor.organizeUtileSkills("physical")
    context.competencesMagie = game.system.lesheritiers.config.competencesMagie || []
    context.futileSkills = actor.organizeFutileSkills()
    context.contacts = actor.organizeContacts()
    context.armes = foundry.utils.duplicate(actor.getWeapons())
    context.monnaies = foundry.utils.duplicate(actor.getMonnaies())
    context.pouvoirs = foundry.utils.duplicate(actor.getPouvoirs())
    context.fee = foundry.utils.duplicate(actor.getFee() || {})
    context.protections = foundry.utils.duplicate(actor.getArmors())
    context.combat = actor.getCombatValues()
    context.equipements = foundry.utils.duplicate(actor.getEquipments())
    context.avantages = foundry.utils.duplicate(actor.getAvantages())
    context.atouts = foundry.utils.duplicate(actor.getAtouts())
    context.capacites = foundry.utils.duplicate(actor.getCapacites())
    context.desavantages = foundry.utils.duplicate(actor.getDesavantages())
    context.profils = foundry.utils.duplicate(actor.getProfils())
    context.pvMalus = actor.getPvMalus()
    context.heritage = game.settings.get("fvtt-les-heritiers", "heritiers-heritage")
    context.initiative = actor.getFlag("world", "last-initiative") || -1
    context.magieList = actor.prepareMagie()
    context.isPNJ = false

    return context
  }
}
