const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;

const TABLE_MORTEL_DISPLAY = [
  { jet: "≤ 0", type: "—", endurance: "0", vie: "0" },
  { jet: "01-04", type: "Contusion / éraflure", endurance: "-1", vie: "—" },
  { jet: "05-06", type: "Contusion / éraflure", endurance: "-2", vie: "—" },
  { jet: "07-08", type: "Contusion / éraflure", endurance: "-3", vie: "—" },
  { jet: "09-10", type: "Contusion / éraflure", endurance: "-4", vie: "—" },
  { jet: "11-12", type: "Contusion", endurance: "-4", vie: "—" },
  { jet: "13-14", type: "Contusion", endurance: "-5", vie: "—" },
  { jet: "15", type: "Contusion", endurance: "-6", vie: "—" },
  { jet: "16", type: "Contusion", endurance: "-6", vie: "-2" },
  { jet: "17", type: "Contusion", endurance: "-8", vie: "-2" },
  { jet: "18", type: "Contusion", endurance: "-10", vie: "-2" },
  { jet: "19", type: "Contusion", endurance: "-12", vie: "-2" },
  { jet: "20+", type: "Contusion", endurance: "End. à 0", vie: "-4 ou +" },
]

const TABLE_NONMORTEL_DISPLAY = [
  { jet: "≤ 0", type: "—", endurance: "0", vie: "0" },
  { jet: "01-04", type: "Contusion / éraflure", endurance: "-1", vie: "—" },
  { jet: "05-06", type: "Contusion / éraflure", endurance: "-2", vie: "—" },
  { jet: "07-08", type: "Contusion / éraflure", endurance: "-3", vie: "—" },
  { jet: "09-12", type: "Contusion / éraflure", endurance: "-4", vie: "—" },
  { jet: "13-14", type: "Blessure légère", endurance: "-5", vie: "—" },
  { jet: "15", type: "Blessure légère", endurance: "-6", vie: "—" },
  { jet: "16", type: "Blessure légère", endurance: "-6", vie: "—" },
  { jet: "17", type: "Blessure légère", endurance: "-8", vie: "—" },
  { jet: "18", type: "Blessure légère", endurance: "-10", vie: "—" },
  { jet: "19", type: "Blessure légère", endurance: "-12", vie: "—" },
  { jet: "20+", type: "Blessure légère", endurance: "End. à 0", vie: "-1" },
]

export class DialogEncaissementTables extends HandlebarsApplicationMixin(ApplicationV2) {
  static DEFAULT_OPTIONS = {
    tag: "form",
    id: "dialog-encaissement-tables",
    classes: ["dialog-encaissement-tables"],
    form: { submitOnChange: false, closeOnSubmit: true },
    position: { width: 500, height: 600 },
    window: { title: "Tables d'encaissement alternatives", icon: "fa-solid fa-table" }
  }

  static PARTS = {
    form: { template: "systems/foundryvtt-reve-de-dragon/templates/settings/dialog-encaissement-tables.hbs" }
  }

  async _prepareContext() {
    return {
      mortel: TABLE_MORTEL_DISPLAY,
      nonmortel: TABLE_NONMORTEL_DISPLAY,
    }
  }
}
