mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 18:39:55 +02:00
Some refactors
This commit is contained in:
parent
e3e1ae2706
commit
c033a578fa
2 changed files with 18 additions and 8 deletions
|
|
@ -2,14 +2,9 @@ import { MigrationHandlerBase } from './base.mjs';
|
|||
|
||||
export class Migration_2_5_2 extends MigrationHandlerBase {
|
||||
version = '2.5.2';
|
||||
documentNames = ['Actor', 'Item'];
|
||||
|
||||
/** @protected */
|
||||
_preMigrate() {
|
||||
|
||||
}
|
||||
|
||||
async updateEffectSource(effectSource, item) {
|
||||
/** @inheritdoc */
|
||||
async updateActiveEffectSource(effectSource, item) {
|
||||
let shouldUpdate = false;
|
||||
const newChanges = [];
|
||||
const srdItem = item?._stats.compendiumSource ?
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
/**
|
||||
* @import DHItem from "../../documents/item.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.
|
||||
|
|
@ -7,6 +11,17 @@
|
|||
export class MigrationHandlerBase {
|
||||
version = null;
|
||||
|
||||
/**
|
||||
* Gets change data for an active effect's source, or null if no changes
|
||||
* @param {object} effectSource
|
||||
* @param {DHItem} item
|
||||
* @returns {Promise<object>}
|
||||
* @protected
|
||||
*/
|
||||
async updateActiveEffectSource(effectSource, item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async migrate() {
|
||||
// todo: handle migrations, but have a way for a migration handler to specify if migrations are handled
|
||||
// todo: handle more than just migrating effects. Right now this can only migrate effects
|
||||
|
|
@ -33,7 +48,7 @@ export class MigrationHandlerBase {
|
|||
const updateItem = async item => {
|
||||
const itemUpdates = [];
|
||||
for (const effect of item.effects) {
|
||||
const changes = await this.updateEffectSource(effect.toObject(), effect.parent);
|
||||
const changes = await this.updateActiveEffectSource(effect.toObject(), item);
|
||||
if (changes) itemUpdates.push(changes);
|
||||
}
|
||||
if (itemUpdates.length) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue