Fix as per CSV sheet tracking + creature explanation

This commit is contained in:
2026-05-17 17:43:33 +02:00
parent a572c66678
commit 374854cc8b
99 changed files with 2716 additions and 464 deletions
+28 -1
View File
@@ -13,7 +13,14 @@ export default class MGNEWeapon extends foundry.abstract.TypeDataModel {
}),
damage: stringField("1d4"),
range: stringField("Touch"),
properties: stringField(""),
properties: new foundry.data.fields.SetField(
new foundry.data.fields.StringField({ required: true, nullable: false, blank: false }),
{ required: true, nullable: false, initial: [] }
),
weight: new foundry.data.fields.StringField({
required: true, nullable: false, initial: "normal",
choices: SYSTEM.weightCategories,
}),
usageDie: new foundry.data.fields.StringField({
required: true,
nullable: false,
@@ -23,9 +30,29 @@ export default class MGNEWeapon extends foundry.abstract.TypeDataModel {
quantity: numberField(1, 0),
equipped: booleanField(false),
broken: booleanField(false),
durabilityDie: new foundry.data.fields.StringField({
required: true, nullable: false, initial: "d6",
choices: SYSTEM.usageDieChoices,
}),
}
}
/** @override */
static LOCALIZATION_PREFIXES = ["MGNE.Weapon"]
/**
* Migrate old string-based properties field to the new SetField format.
* @override
*/
static migrateData(source) {
// Old data stored properties as a plain string; convert to empty array
if (typeof source.properties === "string") {
source.properties = []
}
// Remove any null/undefined/blank entries that may have crept in
if (Array.isArray(source.properties)) {
source.properties = source.properties.filter(p => p != null && p !== "")
}
return super.migrateData(source)
}
}