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

const fields = foundry.data.fields;

export default class RdDModelRencontre extends foundry.abstract.TypeDataModel {
  static defineSchema() {
    return Object.assign({},
      TEMPLATE_DESCRIPTION.fields(),
      TEMPLATE_TEMPOREL.fields(),
      {
        genre: new fields.StringField({ label: "Genre", initial: "f", ...STRING }),
        formule: new fields.StringField({ label: "Formule", initial: "2d4", ...STRING }),
        refoulement: new fields.NumberField({ label: "Refoulement", initial: 1, ...INTEGER }),
        presentCite: new fields.BooleanField({ label: "Présent en cité", initial: false }),
        mauvaiseRencontre: new fields.BooleanField({ label: "Mauvaise rencontre", initial: false }),
        ordreTri: new fields.NumberField({ label: "Ordre de tri", initial: 0, ...INTEGER }),
        force: new fields.NumberField({ label: "Force", initial: 0, ...INTEGER }),
        coord: new fields.StringField({ label: "Coordonnées", initial: "", ...STRING }),
        date: new fields.StringField({ label: "Date", initial: "", ...STRING }),
        heure: new fields.StringField({ label: "Heure", initial: "", ...STRING }),
        succes: new fields.SchemaField({
          effets: new fields.ArrayField(new fields.StringField({}), { ...MODEL_ARRAY }),
          message: new fields.StringField({ initial: "", ...STRING }),
          poesie: new fields.StringField({ initial: "", ...STRING }),
          reference: new fields.StringField({ initial: "", ...STRING }),
        }),
        echec: new fields.SchemaField({
          effets: new fields.ArrayField(new fields.StringField({}), { ...MODEL_ARRAY }),
          message: new fields.StringField({ initial: "", ...STRING }),
          poesie: new fields.StringField({ initial: "", ...STRING }),
          reference: new fields.StringField({ initial: "", ...STRING }),
        }),
        frequence: new fields.SchemaField({
          cite: new fields.NumberField({ initial: 0, ...INTEGER }),
          sanctuaire: new fields.NumberField({ initial: 0, ...INTEGER }),
          plaines: new fields.NumberField({ initial: 0, ...INTEGER }),
          pont: new fields.NumberField({ initial: 0, ...INTEGER }),
          collines: new fields.NumberField({ initial: 0, ...INTEGER }),
          foret: new fields.NumberField({ initial: 0, ...INTEGER }),
          monts: new fields.NumberField({ initial: 0, ...INTEGER }),
          desert: new fields.NumberField({ initial: 0, ...INTEGER }),
          fleuve: new fields.NumberField({ initial: 0, ...INTEGER }),
          lac: new fields.NumberField({ initial: 0, ...INTEGER }),
          marais: new fields.NumberField({ initial: 0, ...INTEGER }),
          gouffre: new fields.NumberField({ initial: 0, ...INTEGER }),
          necropole: new fields.NumberField({ initial: 0, ...INTEGER }),
          desolation: new fields.NumberField({ initial: 0, ...INTEGER }),
          mauvaise: new fields.NumberField({ initial: 0, ...INTEGER }),
        }),
      }
    )
  }
}
