Foundryv14 migration
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user