Fix migration
This commit is contained in:
parent
b694f20e1c
commit
e4143446aa
3 changed files with 15 additions and 12 deletions
|
@ -22,7 +22,9 @@ export async function migrate(): Promise<void> {
|
||||||
function getItemUpdateData(itemData: Partial<foundry.data.ItemData["_source"]>) {
|
function getItemUpdateData(itemData: Partial<foundry.data.ItemData["_source"]>) {
|
||||||
if (!["loot"].includes(itemData.type ?? "")) return undefined;
|
if (!["loot"].includes(itemData.type ?? "")) return undefined;
|
||||||
return {
|
return {
|
||||||
"-=data.equipped": null,
|
data: {
|
||||||
|
"-=equipped": null,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,16 +21,17 @@ export async function migrate(): Promise<void> {
|
||||||
|
|
||||||
function getItemUpdateData(itemData: Partial<foundry.data.ItemData["_source"]>) {
|
function getItemUpdateData(itemData: Partial<foundry.data.ItemData["_source"]>) {
|
||||||
if (itemData.type !== "spell") return;
|
if (itemData.type !== "spell") return;
|
||||||
const updateData: Record<string, unknown> = {
|
|
||||||
"-=data.scrollPrice": null,
|
|
||||||
"data.minimumLevels": { healer: null, wizard: null, sorcerer: null },
|
|
||||||
};
|
|
||||||
|
|
||||||
const cooldownDurationUnit: string | undefined = itemData.data?.cooldownDuration.unit;
|
const cooldownDurationUnit: string | undefined = itemData.data?.cooldownDuration.unit;
|
||||||
|
|
||||||
if (cooldownDurationUnit === "custom") {
|
const updateData: Record<string, unknown> = {
|
||||||
updateData["data.cooldownDuration.unit"] = "rounds";
|
data: {
|
||||||
}
|
"-=scrollPrice": null,
|
||||||
|
minimumLevels: { healer: null, wizard: null, sorcerer: null },
|
||||||
|
cooldownDuration: {
|
||||||
|
unit: cooldownDurationUnit === "custom" ? "rounds" : cooldownDurationUnit,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
return updateData;
|
return updateData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,18 +104,18 @@ export function getSceneUpdateDataGetter(getActorUpdateData: ActorUpdateDataGett
|
||||||
if (update !== undefined) {
|
if (update !== undefined) {
|
||||||
["items" as const, "effects" as const].forEach((embeddedName) => {
|
["items" as const, "effects" as const].forEach((embeddedName) => {
|
||||||
const embeddedUpdates = update[embeddedName];
|
const embeddedUpdates = update[embeddedName];
|
||||||
if (embeddedUpdates === undefined || update[embeddedName]?.length !== 0) return;
|
if (embeddedUpdates === undefined || !embeddedUpdates.length) return;
|
||||||
const updates = new Map(embeddedUpdates.flatMap((u) => (u && u._id ? [[u._id, u]] : [])));
|
const updates = new Map(embeddedUpdates.flatMap((u) => (u && u._id ? [[u._id, u]] : [])));
|
||||||
const originals = t.actorData[embeddedName];
|
const originals = t.actorData[embeddedName];
|
||||||
if (!originals) return;
|
if (!originals) return;
|
||||||
originals.forEach((original) => {
|
originals.forEach((original) => {
|
||||||
if (!original._id) return;
|
if (!original._id) return;
|
||||||
const update = updates.get(original._id);
|
const update = updates.get(original._id);
|
||||||
if (update) mergeObject(original, update);
|
if (update) foundry.utils.mergeObject(original, update);
|
||||||
});
|
});
|
||||||
delete update[embeddedName];
|
delete update[embeddedName];
|
||||||
});
|
});
|
||||||
mergeObject(t.actorData, update);
|
foundry.utils.mergeObject(t.actorData, update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
|
Loading…
Reference in a new issue