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

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

    schema.description = new fields.HTMLField({ required: true, textSearch: true })

    schema.techAge = new fields.StringField({ required: true, choices: SYSTEM.TECH_AGES, initial: "lateatomic" })
    schema.weaponType = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_TYPES })
    schema.rangeType = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_RANGE })

    schema.damage = new fields.StringField({ required: true, initial: "1d6" })
    schema.magazine = new fields.NumberField({ required: true, initial: 1, min: 0 })

    schema.range = new fields.SchemaField({
      close: new fields.NumberField({ ...requiredInteger, initial: 0 }),
      near: new fields.NumberField({ ...requiredInteger, initial: 0 }),
      far: new fields.NumberField({ ...requiredInteger, initial: 0 }),
      dist: new fields.NumberField({ ...requiredInteger, initial: 0 }),
    })

    schema.enc = new fields.NumberField({ required: true, initial: 1, min: 0 })
    schema.aspect = new fields.StringField({ required: true, initial: "" })

    schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
    schema.ammoCost = new fields.NumberField({ required: true, initial: 0, min: 0 })

    return schema
  }

  /** @override */
  static LOCALIZATION_PREFIXES = ["FTLNOMAD.Weapon"]

}
