ds4/src/migration/001.js

44 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
import { getSceneMigrator, migrateCollection, migrateCompendiums, getCompendiumMigrator } from "./migrationHelpers.js";
/** @type {import("./migration.js").Migration["migrate"]} */
async function migrate() {
await migrateCollection(game.actors, migrateActor);
await migrateCollection(game.scenes, migrateScene);
2021-07-08 02:32:25 +02:00
await migrateCompendiums(migrateCompendium);
}
/** @type {import('./migrationHelpers.js').Migrator<Actor>} */
async function migrateActor(actor) {
await actor.update({
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;
}, {}),
},
});
}
2021-07-08 02:32:25 +02:00
const migrateScene = getSceneMigrator(migrateActor);
const migrateCompendium = getCompendiumMigrator({ migrateActor, migrateScene });
/** @type {import("./migration.js").Migration} */
export const migration = {
migrate,
migrateCompendium,
};