Johannes Loher
da1f6999eb
World data (including compendium packs) is migrated automatically. In order to also migrate packs provided by modules, you can use the following macro: ```js const pack = game.packs.get("<name-of-the-module>.<name-of-the-pack>"); game.ds4.migration.migrateCompendiumFromTo(pack, 4, 5); ```
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import {
|
|
getCompendiumMigrator,
|
|
getSceneUpdateDataGetter,
|
|
migrateActors,
|
|
migrateCompendiums,
|
|
migrateScenes,
|
|
} from "./migrationHelpers";
|
|
|
|
async function migrate(): Promise<void> {
|
|
await migrateActors(getActorUpdateData);
|
|
await migrateScenes(getSceneUpdateData);
|
|
await migrateCompendiums(migrateCompendium);
|
|
}
|
|
|
|
function getActorUpdateData(): Record<string, unknown> {
|
|
const updateData = {
|
|
data: {
|
|
combatValues: [
|
|
"hitPoints",
|
|
"defense",
|
|
"initiative",
|
|
"movement",
|
|
"meleeAttack",
|
|
"rangedAttack",
|
|
"spellcasting",
|
|
"targetedSpellcasting",
|
|
].reduce((acc: Partial<Record<string, { "-=base": null }>>, curr) => {
|
|
acc[curr] = { "-=base": null };
|
|
return acc;
|
|
}, {}),
|
|
},
|
|
};
|
|
return updateData;
|
|
}
|
|
|
|
const getSceneUpdateData = getSceneUpdateDataGetter(getActorUpdateData);
|
|
const migrateCompendium = getCompendiumMigrator({ getActorUpdateData, getSceneUpdateData });
|
|
|
|
export const migration = {
|
|
migrate,
|
|
migrateCompendium,
|
|
};
|