Skip to content

Commit

Permalink
Added a fix for Mystify Token Names. Added a fix for refreshing creat…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
WBHarry committed Aug 28, 2024
1 parent 5456b13 commit 9f0a8e8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
27 changes: 26 additions & 1 deletion BestiaryTracking.js

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

5 changes: 4 additions & 1 deletion module/bestiary.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application
!monster.name.revealed ? game.i18n.localize("PF2EBestiary.Bestiary.Miscellaneous.Unknown") : null;

if(name) {
for(var token of canvas.tokens.placeables.filter(x => x.document.baseActor.uuid === monster.uuid)){
for(var token of canvas.tokens.placeables.filter(x => x.document?.baseActor?.uuid === monster.uuid)){
await token.document.update({ name });
}
}
Expand Down Expand Up @@ -780,6 +780,8 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application
monster.system.details.publicNotes.revealed = revealed;
monster.system.details.privateNotes.revealed = revealed;

await PF2EBestiary.handleTokenNames(this.selected.monster);

await game.settings.set('pf2e-bestiary-tracking', 'bestiary-tracking', this.bestiary);
await game.socket.emit(`module.pf2e-bestiary-tracking`, {
action: socketEvent.UpdateBestiary,
Expand All @@ -790,6 +792,7 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application
}

static getUpdatedCreature(creature, data){
data.system.details.playerNotes = creature.system.details.playerNotes;
data.name = { ...data.name, revealed: creature.name.revealed, custom: creature.name.custom };
data.system.details.level = { ...data.system.details.level, revealed: creature.system.details.level.revealed, custom: creature.system.details.level.custom };
data.system.attributes.ac = { ...data.system.attributes.ac, revealed: creature.system.attributes.ac.revealed, custom: creature.system.attributes.ac.custom};
Expand Down
22 changes: 22 additions & 0 deletions scripts/migrationHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ export const handleDataMigration = async () => {
await game.settings.set('pf2e-bestiary-tracking', 'version', version);
}

if(bestiary.metadata.version === '0.8.9.9.6'){
version = '0.8.12';

await game.settings.set('pf2e-bestiary-tracking', 'version', version);
}

const updatedBestiary = await handleBestiaryMigration(game.settings.get('pf2e-bestiary-tracking', 'bestiary-tracking'));
await game.settings.set('pf2e-bestiary-tracking', 'bestiary-tracking', updatedBestiary);
}
Expand Down Expand Up @@ -821,6 +827,22 @@ export const handleBestiaryMigration = async (bestiary) => {
bestiary.metadata.version = '0.8.11';
}

if(bestiary.metadata.version === '0.8.11'){
const journalEntry = game.journal.getName(bestiaryJournalEntry);
if(journalEntry){
bestiary = await newMigrateBestiary(async (_, monster) => {
if(!monster.system.details.playerNotes?.document){
const page = journalEntry.pages.find(x => x.name === monster.name.value);
if(page){
monster.system.details.playerNotes = { document: page.id };
}
}
}, bestiary);
}

bestiary.metadata.version = '0.8.12';
}

return bestiary;
};

Expand Down

0 comments on commit 9f0a8e8

Please sign in to comment.