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

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

    schema.description = new fields.HTMLField({ required: true, textSearch: true })
    schema.abilityType = new fields.StringField({
      required: true,
      nullable: false,
      initial: "field",
      choices: Object.fromEntries(Object.values(SYSTEM.ABILITY_TYPE).map(a => [a.id, a.label]))
    })
    schema.cost = new fields.StringField({
      required: true,
      nullable: false,
      initial: "one",
      choices: Object.fromEntries(Object.values(SYSTEM.ABILITY_COST).map(a => [a.id, a.label]))
    })
    schema.frequency = new fields.StringField({ initial: "", required: false, nullable: true })
    schema.requirements = new fields.StringField({ initial: "", required: false, nullable: true })
    schema.trigger = new fields.StringField({ initial: "", required: false, nullable: true })
    schema.traits = new fields.ArrayField(new fields.StringField())

    return schema
  }
}
