[Fix] ActiveEffect Mode OneTime Migration (#2078)

* Migrations for ActiveEffect Mode
* Start on migration handlers

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
This commit is contained in:
WBHarry 2026-07-12 00:37:02 +02:00 committed by GitHub
parent c6411ef0fe
commit 76ee777985
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 129 additions and 1 deletions

View file

@ -0,0 +1,38 @@
import { MigrationHandlerBase } from './base.mjs';
export class Migration_2_5_2 extends MigrationHandlerBase {
version = '2.5.2';
/** @inheritdoc */
async updateActiveEffectSource(effectSource, item) {
let shouldUpdate = false;
const newChanges = [];
const srdItem = item?._stats.compendiumSource ?
await foundry.utils.fromUuid(item?._stats.compendiumSource) :
null;
for (let i = 0; i < effectSource.system.changes.length; i++) {
const change = effectSource.system.changes[i];
const srdEffect = srdItem?.effects.find(x => x.name === effectSource.name);
if (change.type === 'custom') {
const srdChange = srdEffect ? srdEffect.system.changes[i] : null;
if (
change.key === srdChange.key &&
change.value === srdChange.value &&
change.type !== srdChange.type
) {
shouldUpdate = true;
newChanges.push(srdChange);
}
} else {
newChanges.push(change);
}
}
if (shouldUpdate) {
return {
_id: effectSource._id,
system: { changes: newChanges }
}
}
}
}