Skip to content

Commit

Permalink
Migration fix
Browse files Browse the repository at this point in the history
  • Loading branch information
WBHarry committed Aug 26, 2024
1 parent f45ac64 commit 485cf4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions BestiaryTracking.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions scripts/migrationHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ export const handleDataMigration = async () => {
}

export const handleBestiaryMigration = async (bestiary) => {
bestiary.metadata.version = !bestiary.metadata.version ? '0.8.9' : bestiary.metadata.version;
const oldMonsterData = Object.keys(bestiary.monster).length > 0 && Boolean(bestiary.monster[Object.keys(bestiary.monster)[0]].traits);
bestiary.metadata.version = oldMonsterData ? '0.8.8' : !bestiary.metadata.version ? '0.8.9' : bestiary.metadata.version;

if(bestiary.metadata.version === '0.8.8'){
bestiary = await newMigrateBestiary(async (_, monster) => {
Expand Down Expand Up @@ -403,7 +404,7 @@ export const handleBestiaryMigration = async (bestiary) => {

return acc;
}, []);
const newBestiary = { monster: {}, npc: {} };
const newBestiary = { monster: {}, npc: {}, metadata: {} };
for(var uuid of uuids){
const orig = await fromUuid(uuid);
const data = await PF2EBestiary.getMonsterData(orig);
Expand Down Expand Up @@ -653,7 +654,7 @@ export const handleBestiaryMigration = async (bestiary) => {
}
}
}
else {
else if(monster.items[attackKey].system.damageRolls) {
Object.values(monster.items[attackKey].system.damageRolls).forEach(damageRoll => {
if(!damageRoll.damageType.value){
damageRoll.damageType = { revealed: false, value: damageRoll.damageType };
Expand Down

0 comments on commit 485cf4d

Please sign in to comment.