mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-23 19:09:55 +02:00
Start on migration handlers
This commit is contained in:
parent
d860040824
commit
babd18c9a4
2 changed files with 42 additions and 28 deletions
35
module/systemRegistration/migration-handlers/2_5_2.mjs
Normal file
35
module/systemRegistration/migration-handlers/2_5_2.mjs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
export class Migration_2_5_2 {
|
||||
version = '2.5.2';
|
||||
|
||||
async updateEffect(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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue