forked from GitHub-Mirrors/foundry-sw5e
Update migration.js
Found a case where power migration could be skipped if the actor had no items
This commit is contained in:
parent
d17515a59b
commit
6e37fd8306
1 changed files with 19 additions and 18 deletions
|
@ -131,27 +131,28 @@ export const migrateActorData = function(actor) {
|
||||||
_migrateActorSenses(actor, updateData);
|
_migrateActorSenses(actor, updateData);
|
||||||
|
|
||||||
// Migrate Owned Items
|
// Migrate Owned Items
|
||||||
if ( !actor.items ) return updateData;
|
if ( !!actor.items ) {
|
||||||
let hasItemUpdates = false;
|
let hasItemUpdates = false;
|
||||||
const items = actor.items.map(i => {
|
const items = actor.items.map(i => {
|
||||||
|
|
||||||
// Migrate the Owned Item
|
// Migrate the Owned Item
|
||||||
let itemUpdate = migrateItemData(i);
|
let itemUpdate = migrateItemData(i);
|
||||||
|
|
||||||
// Prepared, Equipped, and Proficient for NPC actors
|
// Prepared, Equipped, and Proficient for NPC actors
|
||||||
if ( actor.type === "npc" ) {
|
if ( actor.type === "npc" ) {
|
||||||
if (getProperty(i.data, "preparation.prepared") === false) itemUpdate["data.preparation.prepared"] = true;
|
if (getProperty(i.data, "preparation.prepared") === false) itemUpdate["data.preparation.prepared"] = true;
|
||||||
if (getProperty(i.data, "equipped") === false) itemUpdate["data.equipped"] = true;
|
if (getProperty(i.data, "equipped") === false) itemUpdate["data.equipped"] = true;
|
||||||
if (getProperty(i.data, "proficient") === false) itemUpdate["data.proficient"] = true;
|
if (getProperty(i.data, "proficient") === false) itemUpdate["data.proficient"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the Owned Item
|
// Update the Owned Item
|
||||||
if ( !isObjectEmpty(itemUpdate) ) {
|
if ( !isObjectEmpty(itemUpdate) ) {
|
||||||
hasItemUpdates = true;
|
hasItemUpdates = true;
|
||||||
return mergeObject(i, itemUpdate, {enforceTypes: false, inplace: false});
|
return mergeObject(i, itemUpdate, {enforceTypes: false, inplace: false});
|
||||||
} else return i;
|
} else return i;
|
||||||
});
|
});
|
||||||
if ( hasItemUpdates ) updateData.items = items;
|
if ( hasItemUpdates ) updateData.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
// migrate powers last since it relies on item classes being migrated first.
|
// migrate powers last since it relies on item classes being migrated first.
|
||||||
_migrateActorPowers(actor, updateData);
|
_migrateActorPowers(actor, updateData);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue