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

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

  /** @override */
  static PARTS = {
    sheet: {
      template: "systems/fvtt-mournblade/templates/actor-sheet.hbs",
      scrollable: [".tab.principal", ".tab.competences", ".tab.dons", ".tab.equipement"],
    },
  }

  /** @override */
  tabGroups = {
    primary: "principal",
  }

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

    // Add personnage-specific data
    context.skills = actor.getSkills()
    context.armes = foundry.utils.duplicate(actor.getWeapons())
    context.protections = foundry.utils.duplicate(actor.getArmors())
    context.dons = foundry.utils.duplicate(actor.getDons())
    context.pactes = foundry.utils.duplicate(actor.getPactes())
    context.alignement = actor.getAlignement()
    context.isChaotique = context.alignement === "chaotique"
    context.isLoyal = context.alignement === "loyal"
    context.aspect = actor.getAspect()
    context.marge = actor.getMarge()
    context.tendances = foundry.utils.duplicate(actor.getTendances())
    context.runes = foundry.utils.duplicate(actor.getRunes())
    context.traitsChaotiques = foundry.utils.duplicate(actor.getTraitsChaotiques())
    context.traitsEspeces = foundry.utils.duplicate(actor.getTraitsEspeces())
    context.origine = foundry.utils.duplicate(actor.getOrigine() || {})
    context.heritage = foundry.utils.duplicate(actor.getHeritage() || {})
    context.metier = foundry.utils.duplicate(actor.getMetier() || {})
    context.combat = actor.getCombatValues()
    context.equipements = foundry.utils.duplicate(actor.getEquipments())
    context.potions = foundry.utils.duplicate(actor.getPotions())
    context.modifiers = foundry.utils.duplicate(actor.getModifiers())
    context.monnaies = foundry.utils.duplicate(actor.getMonnaies())
    context.runeEffects = foundry.utils.duplicate(actor.getRuneEffects())
    context.protectionTotal = actor.getProtectionTotal()
    context.santeMalus = actor.getStatusMalus()
    context.ameMalus = actor.getAmeMalus()
    return context
  }
}