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

export default class AwEWeapon extends foundry.abstract.TypeDataModel {
  static defineSchema() {
    const fields = foundry.data.fields
    const requiredInteger = { required: true, nullable: false, integer: true }
    const schema = {}

    schema.description = new fields.HTMLField({ required: true, textSearch: true })
    schema.range = new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 })
    schema.damageFormula = new fields.StringField({ initial: "1d6", required: true, nullable: false })
    schema.damageType = new fields.StringField({ initial: "physical", required: true, nullable: false })
    schema.attackAttribute = new fields.StringField({
      required: true,
      nullable: false,
      initial: "agility",
      choices: Object.fromEntries(Object.values(SYSTEM.ATTRIBUTES).map(a => [a.id, a.label]))
    })
    schema.traits = new fields.ArrayField(new fields.StringField())

    return schema
  }
}
