mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-23 19:09: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 {
|
export class Migration_2_5_2 extends MigrationHandlerBase {
|
||||||
version = '2.5.2';
|
version = '2.5.2';
|
||||||
documentNames = ['Actor', 'Item'];
|
|
||||||
|
|
||||||
/** @protected */
|
/** @inheritdoc */
|
||||||
_preMigrate() {
|
async updateActiveEffectSource(effectSource, item) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateEffectSource(effectSource, item) {
|
|
||||||
let shouldUpdate = false;
|
let shouldUpdate = false;
|
||||||
const newChanges = [];
|
const newChanges = [];
|
||||||
const srdItem = item?._stats.compendiumSource ?
|
const srdItem = item?._stats.compendiumSource ?
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
/**
|
||||||
|
* @import DHItem from "../../documents/item.mjs";
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base class of an async migration.
|
* The base class of an async migration.
|
||||||
* These are generally run between versions for things that require compendiums or must be done in post.
|
* These are generally run between versions for things that require compendiums or must be done in post.
|
||||||
|
|
@ -7,6 +11,17 @@
|
||||||
export class MigrationHandlerBase {
|
export class MigrationHandlerBase {
|
||||||
version = null;
|
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() {
|
async migrate() {
|
||||||
// todo: handle migrations, but have a way for a migration handler to specify if migrations are handled
|
// 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
|
// 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 updateItem = async item => {
|
||||||
const itemUpdates = [];
|
const itemUpdates = [];
|
||||||
for (const effect of item.effects) {
|
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 (changes) itemUpdates.push(changes);
|
||||||
}
|
}
|
||||||
if (itemUpdates.length) {
|
if (itemUpdates.length) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue