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

const fields = foundry.data.fields;

export default class RdDModelRace extends foundry.abstract.TypeDataModel {
  static defineSchema() {
    const caracField = (extra = {}) => new fields.SchemaField({
      value: new fields.NumberField({ initial: 0, ...INTEGER_SIGNED }),
      ...extra,
    })
    return Object.assign({},
      TEMPLATE_DESCRIPTION.fields(),
      {
        carac: new fields.SchemaField({
          taille: new fields.SchemaField({
            value: new fields.NumberField({ initial: 0, ...INTEGER_SIGNED }),
            min: new fields.NumberField({ initial: -1, ...INTEGER_SIGNED }),
            max: new fields.NumberField({ initial: -1, ...INTEGER_SIGNED }),
          }),
          apparence: caracField(),
          constitution: caracField(),
          force: new fields.SchemaField({
            value: new fields.NumberField({ initial: 0, ...INTEGER_SIGNED }),
            limit: new fields.StringField({ initial: "taille + 4", ...STRING }),
            limitmessage: new fields.StringField({ initial: "", ...STRING }),
          }),
          agilite: caracField(),
          dexterite: caracField(),
          vue: caracField(),
          ouie: caracField(),
          odoratgout: caracField(),
          volonte: caracField(),
          intellect: caracField(),
          empathie: caracField(),
          reve: caracField(),
          chance: caracField(),
        }),
        attributs: new fields.SchemaField({
          protection: caracField(),
        }),
        background: new fields.SchemaField({
          beaute: caracField(),
        }),
      }
    )
  }
}
