import MournbladeCYD2ActorSheetV2 from "./base-actor-sheet.mjs";
import { MournbladeCYD2Utility } from "../../mournblade-cyd2-utility.js";

export default class MournbladeCYD2CreatureSheet extends MournbladeCYD2ActorSheetV2 {

  /** @override */
  static DEFAULT_OPTIONS = {
    ...super.DEFAULT_OPTIONS,
    classes: [...super.DEFAULT_OPTIONS.classes],
    window: {
      ...super.DEFAULT_OPTIONS.window,
      title: "SHEETS.Actor.creature",
    },
  };

  /** @override */
  static PARTS = {
    sheet: {
      template: "systems/fvtt-mournblade-cyd-2-0/templates/creature-sheet.hbs",
    },
  };

  /** @override */
  tabGroups = { primary: "stats" };

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

    context.skills = actor.getSkills?.() ?? [];
    context.combativiteList = MournbladeCYD2Utility.getCombativiteList(actor.system.sante?.nbcombativite || 0);
    context.armes = foundry.utils.duplicate(actor.getWeapons?.() ?? []);
    context.protections = foundry.utils.duplicate(actor.getArmors?.() ?? []);
    context.runes = foundry.utils.duplicate(actor.getRunes?.() ?? []);
    context.combat = actor.getCombatValues?.() ?? {};
    context.equipements = foundry.utils.duplicate(actor.getEquipments?.() ?? []);
    context.monnaies = foundry.utils.duplicate(actor.getMonnaies?.() ?? []);
    context.talents = foundry.utils.duplicate(actor.getTalents?.() ?? []);
    context.protectionTotal = actor.getProtectionTotal?.() ?? 0;
    context.adversiteTotal = (actor.system.adversite?.bleue || 0) + (actor.system.adversite?.rouge || 0) + (actor.system.adversite?.noire || 0);
    return context;
  }
}
