/**
 * Race data model for Prism RPG
 *
 * Races provide:
 * - Racial Passive: Always-on ability
 * - Sub-race selection: Specific racial ability based on sub-race
 * - Basic information: Senses, size, age, language
 */
import { SYSTEM } from "../config/system.mjs"

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

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

    // Basic Information
    schema.senses = new fields.StringField({
      required: true,
      initial: "standard",
      label: "Senses"
    })

    schema.size = new fields.StringField({
      required: true,
      initial: "medium",
      choices: SYSTEM.RACE_SIZE,
      label: "Size"
    })

    schema.ageCategory = new fields.StringField({
      required: true,
      initial: "short",
      choices: SYSTEM.RACE_AGE_CATEGORY,
      label: "Age Category"
    })

    schema.language = new fields.StringField({
      required: true,
      initial: "",
      label: "Language"
    })

    schema.baseBurden = new fields.NumberField({
      required: true,
      nullable: false,
      integer: true,
      initial: 0,
      min: 0,
      label: "Base Burden"
    })

    // Racial Passive
    schema.racialPassive = new fields.StringField({
      required: true,
      initial: "",
      label: "Racial Passive Name"
    })

    schema.racialPassiveDescription = new fields.HTMLField({
      required: true,
      initial: "",
      label: "Racial Passive Description"
    })

    // Sub-race
    schema.subrace = new fields.StringField({
      required: true,
      initial: "",
      label: "Sub-race"
    })

    schema.subraceAbility = new fields.StringField({
      required: true,
      initial: "",
      label: "Sub-race Ability Name"
    })

    schema.subraceAbilityDescription = new fields.HTMLField({
      required: true,
      initial: "",
      label: "Sub-race Ability Description"
    })

    // Additional notes
    schema.notes = new fields.HTMLField({
      required: true,
      initial: "",
      label: "Notes"
    })

    return schema
  }

  /** @override */
  static LOCALIZATION_PREFIXES = ["PRISMRPG.Race"]

  /**
   * Get the localized size label
   */
  get sizeLabel() {
    return game.i18n.localize(`PRISMRPG.Race.Size.${this.size}`)
  }

  /**
   * Get the localized age category label
   */
  get ageCategoryLabel() {
    return game.i18n.localize(`PRISMRPG.Race.AgeCategory.${this.ageCategory}`)
  }
}
