mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Added migration for TagTeamData
This commit is contained in:
parent
7a036821d9
commit
ef749f9b8c
3 changed files with 65 additions and 3 deletions
|
|
@ -1,8 +1,9 @@
|
|||
/**
|
||||
* @import DHItem from "../../documents/item.mjs";
|
||||
* @import DhActor from "../../documents/actor.mjs";
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* The base class of an async migration.
|
||||
* These are generally run between versions for things that require compendiums or must be done in post.
|
||||
* The migrate() functions calls the various updateXSource() functions.
|
||||
|
|
@ -22,6 +23,16 @@ export class MigrationHandlerBase {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a world actor
|
||||
* @param {DhActor} actor
|
||||
* @returns {Promise<object>}
|
||||
* @protected
|
||||
*/
|
||||
async updateActorSource(actor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async migrate() {
|
||||
// todo: handle more than just migrating effects. Right now this can only migrate effects
|
||||
// NOTE: the preload is hardcoded, we should not hardcode it
|
||||
|
|
@ -60,10 +71,39 @@ export class MigrationHandlerBase {
|
|||
}
|
||||
};
|
||||
|
||||
for (const actor of game.actors) {
|
||||
const updateActor = async actor => {
|
||||
const actorUpdate = await this.updateActorSource(actor);
|
||||
if (actorUpdate) {
|
||||
batch.push({
|
||||
action: 'update',
|
||||
documentName: 'Actor',
|
||||
updates: [actorUpdate]
|
||||
});
|
||||
}
|
||||
|
||||
const aeUpdates = [];
|
||||
for (const item of actor.items) {
|
||||
await updateItem(item);
|
||||
}
|
||||
|
||||
for (const effect of actor.effects) {
|
||||
const changes = await this.updateActiveEffectSource(effect.toObject(), { parent: actor });
|
||||
if (changes) aeUpdates.push(changes);
|
||||
}
|
||||
if (aeUpdates.length) {
|
||||
batch.push({
|
||||
action: 'update',
|
||||
documentName: 'ActiveEffect',
|
||||
updates: aeUpdates,
|
||||
parent: actor
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (const actor of game.actors) {
|
||||
await updateActor(actor);
|
||||
|
||||
progress.advance();
|
||||
}
|
||||
for (const item of game.items) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue