Foundryv14 migration

This commit is contained in:
2026-04-01 22:19:03 +02:00
parent 038aa37838
commit a11d9be830
91 changed files with 241 additions and 207 deletions

View File

@@ -31,7 +31,32 @@ export class HeritiersItem extends Item {
if (!data.img) {
data.img = defaultItemImg[data.type];
}
// Coerce legacy string numeric fields before DataModel validation
if (data.system) {
for (const key of ["quantite", "rarete", "prix", "degats", "precision",
"magasin", "charge", "zone", "points", "malusagilite", "lieu"]) {
if (typeof data.system[key] === "string") {
const v = parseInt(data.system[key])
data.system[key] = Number.isNaN(v) ? 0 : v
}
}
}
super(data, context);
}
// Coerce legacy string values for NumberFields in system data (migration from pre-DataModel era)
static migrateData(data) {
if (data.system) {
const numericFields = ["quantite", "rarete", "prix", "degats", "precision",
"magasin", "charge", "zone", "points", "malusagilite", "lieu"]
for (const key of numericFields) {
if (typeof data.system[key] === "string") {
const v = parseInt(data.system[key])
data.system[key] = Number.isNaN(v) ? 0 : v
}
}
}
return super.migrateData(data)
}
}