From cd4a8069fc148e295fe113ffa5ff9ac9c6a35ee5 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 22 Mar 2026 01:25:38 +0100 Subject: [PATCH] Updated migrations --- module/data/item/armor.mjs | 6 ++-- module/systemRegistration/migrations.mjs | 37 ++++-------------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/module/data/item/armor.mjs b/module/data/item/armor.mjs index 760f9c22..16c936d2 100644 --- a/module/data/item/armor.mjs +++ b/module/data/item/armor.mjs @@ -153,10 +153,8 @@ export default class DHArmor extends AttachableItem { /** @inheritDoc */ static migrateDocumentData(source) { - if (source.system.baseScore !== undefined && !source.effects.some(x => x.type === 'armor')) { - if (!source.flags) source.flags = {}; - if (!source.flags.daggerheart) source.flags.daggerheart = {}; - source.flags.daggerheart.baseScoreMigrationValue = source.system.baseScore; + if (!source.system.armor) { + source.system.armor = { current: source.system.marks ?? 0, max: source.system.baseScore ?? 0 }; } } diff --git a/module/systemRegistration/migrations.mjs b/module/systemRegistration/migrations.mjs index df837ef4..38bb9afb 100644 --- a/module/systemRegistration/migrations.mjs +++ b/module/systemRegistration/migrations.mjs @@ -318,16 +318,16 @@ export async function runMigrations() { const oldEffectData = effect.toObject(); changeData.createData = { ...oldEffectData, - type: 'armor', system: { - ...oldEffectData.sytem, + ...oldEffectData.system, changes: oldArmorChanges.map(change => ({ - key: 'system.armorScore', type: CONFIG.DH.GENERAL.activeEffectModes.armor.id, phase: 'initial', priority: 20, - value: 0, - max: change.value + value: { + current: 0, + max: change.value + } })) } }; @@ -363,35 +363,10 @@ export async function runMigrations() { ); }; - /* Migrate existing armors to the new Armor Effects */ + /* Migrate existing armors effects */ const migrateItems = async items => { for (const item of items) { await migrateEffects(item); - - if (item instanceof game.system.api.documents.DHItem && item.type === 'armor') { - const hasArmorEffect = item.effects.some(x => x.type === 'armor'); - const migrationArmorScore = item.flags.daggerheart?.baseScoreMigrationValue; - if (migrationArmorScore !== undefined && !hasArmorEffect) { - await item.createEmbeddedDocuments('ActiveEffect', [ - { - ...game.system.api.data.activeEffects.changeTypes.armor.getDefaultArmorEffect(), - changes: [ - { - key: 'Armor', - type: CONFIG.DH.GENERAL.activeEffectModes.armor, - phase: 'initial', - priority: 20, - value: 0, - typeData: { - type: 'armor', - max: migrationArmorScore.toString() - } - } - ] - } - ]); - } - } } };