ds4/src/migrations/001.ts

41 lines
1.2 KiB
TypeScript

// SPDX-FileCopyrightText: 2021 Johannes Loher
//
// SPDX-License-Identifier: MIT
import {
getCompendiumMigrator,
getSceneUpdateDataGetter,
migrateActors,
migrateCompendiums,
migrateScenes,
} from "./migrationHelpers";
export 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 });