Fix weapon sheet
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
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
|
||||
@@ -8,14 +10,27 @@ export default class OathHammerClass extends foundry.abstract.TypeDataModel {
|
||||
// Class features, starting abilities, advancement options (rich text)
|
||||
schema.features = new fields.HTMLField({ required: true, textSearch: true })
|
||||
|
||||
// Armor proficiencies (e.g. "Light, Medium, Heavy")
|
||||
schema.armorProficiency = new fields.StringField({ required: true, nullable: false, initial: "" })
|
||||
// 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 (e.g. "Common, Dueling, Heavy, Throwing")
|
||||
schema.weaponProficiency = new fields.StringField({ required: true, nullable: false, 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"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user