import { baseItemSchema } from "./_shared.mjs"

/**
 * DataModel pour les items de type "weapon" (armes).
 * @augments {foundry.abstract.TypeDataModel}
 */
export default class VermineWeaponData extends foundry.abstract.TypeDataModel {
  /** @override */
  static LOCALIZATION_PREFIXES = ["VERMINE.item.weapon"]

  /** @override */
  static defineSchema() {
    const fields = foundry.data.fields
    const reqInt = { required: true, nullable: false, integer: true }
    return {
      ...baseItemSchema(),
      skill: new fields.StringField({ required: true, nullable: false, initial: "" }),
      equipped: new fields.BooleanField({ required: true, initial: false }),
      min_range: new fields.NumberField({ ...reqInt, initial: 0, min: 0 }),
      max_range: new fields.NumberField({ ...reqInt, initial: 0, min: 0 }),
      damage: new fields.SchemaField({
        value: new fields.NumberField({ ...reqInt, initial: 0, min: -10 }),
        type: new fields.StringField({ required: true, initial: "" }),
        addVigor: new fields.BooleanField({ required: true, initial: false })
      }),
      ammo: new fields.NumberField({ ...reqInt, initial: 0, min: 0 })
    }
  }
}
