Foundryv14 migration
This commit is contained in:
@@ -354,10 +354,6 @@ export class HeritiersActor extends Actor {
|
||||
return combat
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
prepareBaseData() {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async prepareData() {
|
||||
super.prepareData();
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,4 +13,14 @@ export default class AccessoireDataModel extends foundry.abstract.TypeDataModel
|
||||
lieu: new fields.NumberField({ initial: 0, integer: true })
|
||||
};
|
||||
}
|
||||
|
||||
static migrateData(data) {
|
||||
for (const key of ["rarete", "quantite", "prix", "lieu"]) {
|
||||
if (typeof data[key] === "string") {
|
||||
const v = parseInt(data[key]);
|
||||
data[key] = Number.isNaN(v) ? 0 : v;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,14 @@ export default class ArmeDataModel extends foundry.abstract.TypeDataModel {
|
||||
special: new fields.StringField({ initial: "" })
|
||||
};
|
||||
}
|
||||
|
||||
static migrateData(data) {
|
||||
for (const key of ["rarete", "quantite", "prix", "degats", "precision", "magasin", "charge", "zone"]) {
|
||||
if (typeof data[key] === "string") {
|
||||
const v = parseInt(data[key]);
|
||||
data[key] = Number.isNaN(v) ? 0 : v;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,14 @@ export default class EquipementDataModel extends foundry.abstract.TypeDataModel
|
||||
equipped: new fields.BooleanField({ initial: false })
|
||||
};
|
||||
}
|
||||
|
||||
static migrateData(data) {
|
||||
for (const key of ["rarete", "quantite", "prix"]) {
|
||||
if (typeof data[key] === "string") {
|
||||
const v = parseInt(data[key]);
|
||||
data[key] = Number.isNaN(v) ? 0 : v;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,14 @@ export default class ProtectionDataModel extends foundry.abstract.TypeDataModel
|
||||
dissimulation: new fields.StringField({ initial: "" })
|
||||
};
|
||||
}
|
||||
|
||||
static migrateData(data) {
|
||||
for (const key of ["rarete", "quantite", "prix", "points", "malusagilite"]) {
|
||||
if (typeof data[key] === "string") {
|
||||
const v = parseInt(data[key]);
|
||||
data[key] = Number.isNaN(v) ? 0 : v;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user