import { SYSTEM } from "../config/system.mjs"
export default class LethalFantasySpell 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: false,
      blank: true,
      initial: "",
      textSearch: true,
    })
    schema.level = new fields.NumberField({
      ...requiredInteger,
      initial: 1,
      min: 1,
      max: 25,
    })

    schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
    schema.costOverpowered = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
    schema.costOverpowered2 = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
    schema.memorized = new fields.BooleanField({ required: true, initial: false })
    
    schema.components = new fields.SchemaField({
      verbal: new fields.BooleanField(),
      somatic: new fields.BooleanField(),      
      catalyst: new fields.BooleanField(),
      material: new fields.BooleanField(),
    })
    schema.castingTime = new fields.StringField({ required: true, initial: "" })
    schema.spellRange = new fields.StringField({ required: true, initial: "" })
    schema.areaAffected = new fields.StringField({ required: true, initial: "" })
    schema.duration = new fields.StringField({ required: true, initial: "" })
    schema.savingThrow = new fields.StringField({ required: true, initial: "" })
    schema.extraAetherPoints = new fields.StringField({ required: true, initial: "" })
    schema.materialComponent = new fields.StringField({ required: true, initial: "" })
    schema.catalyst = new fields.StringField({ required: true, initial: "" })
    schema.criticalType = new fields.StringField({ required: true, initial: "electric", choices : SYSTEM.SPELL_CRITICAL })

    schema.attackRoll = new fields.StringField({ required: true, initial: "" })
    schema.powerRoll = new fields.StringField({ required: true, initial: "" })
    schema.damageDice = new fields.StringField({ required: false, initial: "" })
    schema.damageDiceOverpowered = new fields.StringField({ required: false, initial: "" })
    schema.damageDiceOverpowered2 = new fields.StringField({ required: false, initial: "" })
  
    return schema
  }

  /** @override */
  static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Spell"]
}
