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 */
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 };
}
}

View file

@ -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()
}
}
]
}
]);
}
}
}
};