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

export default class OathHammerSkillNPC extends foundry.abstract.TypeDataModel {
  static defineSchema() {
    const fields = foundry.data.fields
    const schema = {}

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

    // Total dice pool for this skill (attribute + skill ranks combined)
    schema.dicePool = new fields.NumberField({
      required: true, nullable: false, integer: true, initial: 1, min: 0, max: 20
    })

    // Dice color: white (4+), red (3+), black (2+)
    schema.colorDiceType = new fields.StringField({
      required: true, initial: "white", choices: SYSTEM.DICE_COLOR_TYPES
    })

    // Optional reference to a system skill key (e.g. "fighting", "perception")
    // Used for display/tooltip only — does not restrict the roll.
    schema.skillRef = new fields.StringField({ required: false, nullable: true, initial: null })

    return schema
  }

  static LOCALIZATION_PREFIXES = ["OATHHAMMER.SkillNPC"]

  get threshold() {
    return this.colorDiceType === "black" ? 2 : this.colorDiceType === "red" ? 3 : 4
  }

  get colorEmoji() {
    return this.colorDiceType === "black" ? "⬛" : this.colorDiceType === "red" ? "🔴" : "⬜"
  }
}
