import { SYSTEM } from "../config/system.mjs"

export default class AwEField extends foundry.abstract.TypeDataModel {
  static defineSchema() {
    const fields = foundry.data.fields
    const schema = {}

    schema.description = new fields.HTMLField({ required: true, textSearch: true })
    schema.keyAttribute = new fields.StringField({
      required: true,
      nullable: false,
      initial: "agility",
      choices: Object.fromEntries(Object.values(SYSTEM.ATTRIBUTES).map(a => [a.id, a.label]))
    })
    schema.keyAttribute2 = new fields.StringField({
      required: false,
      nullable: true,
      initial: "",
      blank: true,
      choices: { "": "—", ...Object.values(SYSTEM.ATTRIBUTES).reduce((o, a) => { o[a.id] = a.label; return o }, {}) }
    })
    schema.knowledgeBonus = new fields.StringField({ initial: "", required: false, nullable: true })

    return schema
  }
}
