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

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

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

    // Divine tradition (Druidic / Profane / Sanctified)
    schema.divineTradition = new fields.StringField({
      required: true, initial: "sanctified", choices: SYSTEM.DIVINE_TRADITIONS
    })

    // Difficulty Value: 0 = scales dynamically (1st = DV1, 2nd = DV2…).
    // Non-zero only for Ritual miracles which have a fixed DV (p.129).
    schema.difficultyValue = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 10 })

    // Ritual miracles require 1 hour; need a holy book; fixed DV; don't
    // increment the daily miracle counter (p.129).
    schema.isRitual = new fields.BooleanField({ initial: false })

    // Range: "Touch", "Self", "20", "100", "1 mile", etc.
    schema.range = new fields.StringField({ required: true, nullable: false, initial: "" })

    // Duration: "1 hour", "Encounter", "1 day", etc. Empty = instantaneous.
    schema.duration = new fields.StringField({ required: true, nullable: false, initial: "" })

    // Spell Save: e.g. "DV4 Athletics", "DV5 Fortune". Empty = no save.
    schema.spellSave = new fields.StringField({ required: true, nullable: false, initial: "" })

    return schema
  }

  static LOCALIZATION_PREFIXES = ["OATHHAMMER.Miracle"]
}
