ds4/src/migration/001.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-06-26 22:02:00 +02:00
// SPDX-FileCopyrightText: 2021 Johannes Loher
//
// SPDX-License-Identifier: MIT
2021-07-08 02:32:25 +02:00
import {
getCompendiumMigrator,
getSceneUpdateDataGetter,
migrateActors,
migrateCompendiums,
migrateScenes,
} from "./migrationHelpers";
/** @type {import("./migration").Migration["migrate"]} */
async function migrate() {
2021-07-08 02:32:25 +02:00
await migrateActors(getActorUpdateData);
await migrateScenes(getSceneUpdateData);
await migrateCompendiums(migrateCompendium);
}
/** @type {import("./migrationHelpers").ActorUpdateDataGetter} */
function getActorUpdateData() {
const updateData = {
2022-11-21 03:00:46 +01:00
system: {
combatValues: [
"hitPoints",
"defense",
"initiative",
"movement",
"meleeAttack",
"rangedAttack",
"spellcasting",
"targetedSpellcasting",
].reduce((acc, curr) => {
acc[curr] = { "-=base": null };
return acc;
}, {}),
},
};
return updateData;
}
2021-07-08 02:32:25 +02:00
const getSceneUpdateData = getSceneUpdateDataGetter(getActorUpdateData);
const migrateCompendium = getCompendiumMigrator({ getActorUpdateData, getSceneUpdateData });
/** @type {import("./migration").Migration} */
export const migration = {
migrate,
migrateCompendium,
};