import { TEMPLATE_DESCRIPTION } from "../common/_module.mjs";
import { INTEGER, MODEL_ARRAY, STRING } from "../common/field-types.mjs";

const fields = foundry.data.fields;

export default class RdDModelSort extends foundry.abstract.TypeDataModel {
  static defineSchema() {
    return Object.assign({},
      TEMPLATE_DESCRIPTION.fields(),
      {
        draconic: new fields.StringField({ label: "Draconique", initial: "", ...STRING }),
        duree: new fields.StringField({ label: "Durée", initial: "", ...STRING }),
        JR: new fields.StringField({ label: "JR", initial: "", ...STRING }),
        cible: new fields.StringField({ label: "Cible", initial: "", ...STRING }),
        difficulte: new fields.StringField({ label: "Difficulté", initial: "", ...STRING }),
        portée: new fields.StringField({ label: "Portée", initial: "", ...STRING }),
        caseTMR: new fields.StringField({ label: "Case TMR", initial: "", ...STRING }),
        caseTMRspeciale: new fields.StringField({ label: "Case TMR spéciale", initial: "", ...STRING }),
        ptreve: new fields.StringField({ label: "Points de rêve", initial: "", ...STRING }),
        xp: new fields.NumberField({ label: "XP", initial: 0, ...INTEGER }),
        bonuscase: new fields.StringField({ label: "Bonus de case", initial: "", ...STRING }),
        isrituel: new fields.BooleanField({ label: "Rituel", initial: false }),
        coutseuil: new fields.NumberField({ label: "Coût seuil", initial: 0, ...INTEGER }),
        lancements: new fields.ArrayField(
          new fields.SchemaField({
            indexDate: new fields.NumberField({ initial: 0, integer: true }),
            indexMinute: new fields.NumberField({ initial: 0, integer: true }),
          }),
          { ...MODEL_ARRAY }
        ),
      }
    )
  }
}
