diff --git a/module/bestiary.js b/module/bestiary.js index 1845530..722b79a 100644 --- a/module/bestiary.js +++ b/module/bestiary.js @@ -80,7 +80,7 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application context.selected = foundry.utils.deepClone(this.selected); context.openType = this.selected.type ? Object.keys(this.bestiary[this.selected.category][this.selected.type]).reduce((acc, key)=> { const monster = this.bestiary[this.selected.category][this.selected.type][key]; - if(!this.search.name || monster.name.toLowerCase().match(this.search.name.toLowerCase())) { + if(!this.search.name || (monster.name.revealed && monster.name.value.toLowerCase().match(this.search.name.toLowerCase()))) { acc[key] = monster; } @@ -155,8 +155,10 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application static async toggleRevealed(_, button){ if(!game.user.isGM) return; - foundry.utils.setProperty(this.selected.monster, `${button.dataset.path}.revealed`, !foundry.utils.getProperty(this.selected.monster, `${button.dataset.path}.revealed`)); - + for(var type of this.selected.monster.inTypes){ + foundry.utils.setProperty(this.bestiary.monster[type][this.selected.monster.slug], `${button.dataset.path}.revealed`, !foundry.utils.getProperty(this.bestiary.monster[type][this.selected.monster.slug])); + } + if(button.dataset.parent){ const values = Object.values(this.selected.monster[button.dataset.parent].values); this.selected.monster[button.dataset.parent].currentRevealed = values.filter(x => x.revealed).length; @@ -296,7 +298,7 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(Application inTypes: types.map(x => x.key), traits: traits, size: getCreatureSize(item.system.traits.size.value), - name: item.name, + name: { reveal: false, value: item.name }, img: item.img, abilities: { revealed: false, diff --git a/scripts/handlebarHelpers.js b/scripts/handlebarHelpers.js index c209187..d685730 100644 --- a/scripts/handlebarHelpers.js +++ b/scripts/handlebarHelpers.js @@ -1,18 +1,11 @@ export default class RegisterHandlebarsHelpers { static registerHelpers(){ Handlebars.registerHelper({ - add: this.add, - nrKeys: this.nrKeys, - monsterValue: this.monsterValue, - categoryClassTitle: this.categoryClassTitle, + PF2EBTNrKeys: this.nrKeys, + PF2EBTMonsterValue: this.monsterValue, + PF2EBTCategoryClassTitle: this.categoryClassTitle, }); }; - - static add(a, b){ - const aNum = Number.parseInt(a); - const bNum = Number.parseInt(b); - return (Number.isNaN(aNum) ? 0 : aNum) + (Number.isNaN(bNum) ? 0 : bNum); - } static nrKeys(obj) { return obj ? Object.keys(obj).length : 0; diff --git a/scripts/migrationHandler.js b/scripts/migrationHandler.js index ea79562..22f99e0 100644 --- a/scripts/migrationHandler.js +++ b/scripts/migrationHandler.js @@ -1,4 +1,6 @@ export const handleDataMigration = async () => { + if(!game.user.isGM) return; + var version = await game.settings.get('pf2e-bestiary-tracking', 'version'); if(!version){ version = '0.8.1'; @@ -13,6 +15,12 @@ export const handleDataMigration = async () => { if(!monster.name.value){ bestiary.monster[type][monsterKey].name = { revealed: false, value: monster.name }; } + + for(var inType of monster.inTypes){ + if(type !== inType){ + bestiary.monster[inType][monsterKey] = foundry.utils.deepClone(bestiary.monster[type][monsterKey]); + } + } }); }); diff --git a/styles/pf2e-bestiary-tracking.css b/styles/pf2e-bestiary-tracking.css index 8ae2226..f9e5d81 100644 --- a/styles/pf2e-bestiary-tracking.css +++ b/styles/pf2e-bestiary-tracking.css @@ -19,6 +19,7 @@ align-items: center; justify-content: space-between; margin-bottom: 8px; + min-height: 32px; } .bestiary-tracking.bestiary header .return-container { cursor: pointer; diff --git a/styles/stylesheets/bestiary.less b/styles/stylesheets/bestiary.less index 938e2e8..4e47291 100644 --- a/styles/stylesheets/bestiary.less +++ b/styles/stylesheets/bestiary.less @@ -31,6 +31,7 @@ align-items: center; justify-content: space-between; margin-bottom: 8px; + min-height: 32px; .return-container { cursor: pointer; diff --git a/templates/bestiary.hbs b/templates/bestiary.hbs index 57a2a15..2ee39d3 100644 --- a/templates/bestiary.hbs +++ b/templates/bestiary.hbs @@ -49,7 +49,7 @@ {{/with}} {{else}}