Updated migrations

This commit is contained in:
WBHarry 2026-03-22 01:25:38 +01:00
parent 33fb7bcc69
commit cd4a8069fc
2 changed files with 8 additions and 35 deletions

View file

@ -153,10 +153,8 @@ export default class DHArmor extends AttachableItem {
/** @inheritDoc */ /** @inheritDoc */
static migrateDocumentData(source) { static migrateDocumentData(source) {
if (source.system.baseScore !== undefined && !source.effects.some(x => x.type === 'armor')) { if (!source.system.armor) {
if (!source.flags) source.flags = {}; source.system.armor = { current: source.system.marks ?? 0, max: source.system.baseScore ?? 0 };
if (!source.flags.daggerheart) source.flags.daggerheart = {};
source.flags.daggerheart.baseScoreMigrationValue = source.system.baseScore;
} }
} }

View file

@ -318,16 +318,16 @@ export async function runMigrations() {
const oldEffectData = effect.toObject(); const oldEffectData = effect.toObject();
changeData.createData = { changeData.createData = {
...oldEffectData, ...oldEffectData,
type: 'armor',
system: { system: {
...oldEffectData.sytem, ...oldEffectData.system,
changes: oldArmorChanges.map(change => ({ changes: oldArmorChanges.map(change => ({
key: 'system.armorScore',
type: CONFIG.DH.GENERAL.activeEffectModes.armor.id, type: CONFIG.DH.GENERAL.activeEffectModes.armor.id,
phase: 'initial', phase: 'initial',
priority: 20, priority: 20,
value: 0, value: {
current: 0,
max: change.value 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 => { const migrateItems = async items => {
for (const item of items) { for (const item of items) {
await migrateEffects(item); 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()
}
}
]
}
]);
}
}
} }
}; };