Files
2026-03-08 17:27:59 +01:00

37 lines
1.3 KiB
JavaScript

import { ARMOR_TYPE_CHOICES, WEAPON_PROFICIENCY_GROUPS } from "../config/system.mjs"
export default class OathHammerClass extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
// Class features, starting abilities, advancement options (rich text)
schema.features = new fields.HTMLField({ required: true, textSearch: true })
// Armor proficiencies — set of keys from ARMOR_TYPE_CHOICES (light, medium, heavy)
schema.armorProficiency = new fields.SetField(
new fields.StringField({ choices: ARMOR_TYPE_CHOICES }),
{ required: true, initial: [] }
)
// Weapon proficiencies — set of keys from WEAPON_PROFICIENCY_GROUPS
schema.weaponProficiency = new fields.SetField(
new fields.StringField({ choices: WEAPON_PROFICIENCY_GROUPS }),
{ required: true, initial: [] }
)
return schema
}
// Migrate old free-text string values to empty sets
static migrateData(source) {
if (typeof source.armorProficiency === "string") source.armorProficiency = []
if (typeof source.weaponProficiency === "string") source.weaponProficiency = []
return super.migrateData(source)
}
static LOCALIZATION_PREFIXES = ["OATHHAMMER.Class"]
}