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}}
- {{#if (eq (nrKeys this.openType) 0)}} + {{#if (eq (PF2EBTNrKeys this.openType) 0)}} {{localize "PF2EBestiary.Bestiary.CategoryView.EmptyText" category=this.selected.type}} {{else}} {{#each this.openType as |type key|}} @@ -67,7 +67,7 @@
{{#each bestiary.monster as |type key|}} -
+
{{key}}
{{/each}} diff --git a/templates/partials/monsterView.hbs b/templates/partials/monsterView.hbs index 8c2ce40..9596b07 100644 --- a/templates/partials/monsterView.hbs +++ b/templates/partials/monsterView.hbs @@ -7,7 +7,7 @@
{{localize "PF2EBestiary.Miscellaneous.AC"}}
-
{{#if (or this.ac.revealed this.user.isGM)}}{{monsterValue this.ac this.vagueDescriptions.ac}}{{else}}?{{/if}}
+
{{#if (or this.ac.revealed this.user.isGM)}}{{PF2EBTMonsterValue this.ac this.vagueDescriptions.ac}}{{else}}?{{/if}}
@@ -15,7 +15,7 @@
{{localize "PF2EBestiary.Miscellaneous.HP"}}
-
{{#if (or this.hp.revealed this.user.isGM)}}{{monsterValue this.hp this.vagueDescriptions.hp}}{{else}}?{{/if}}
+
{{#if (or this.hp.revealed this.user.isGM)}}{{PF2EBTMonsterValue this.hp this.vagueDescriptions.hp}}{{else}}?{{/if}}
@@ -65,9 +65,9 @@ data-action="toggleRevealed" data-path="{{concat 'weaknesses.values.' key}}" data-parent="weaknesses" - title="{{categoryClassTitle weakness.class 'Weakness' ../vagueDescriptions.weaknesses}}" + title="{{PF2EBTCategoryClassTitle weakness.class 'Weakness' ../vagueDescriptions.weaknesses}}" > - {{monsterValue weakness ../vagueDescriptions.weaknesses}} + {{PF2EBTMonsterValue weakness ../vagueDescriptions.weaknesses}}
{{#if (and (not ../user.isGM) (gt ../weaknesses.currentRevealed weakness.index))}}, {{/if}} {{/if}} @@ -99,9 +99,9 @@ data-action="toggleRevealed" data-path="{{concat 'resistances.values.' key}}" data-parent="resistances" - title="{{categoryClassTitle resistance.class 'Resistance' ../vagueDescriptions.resistances}}" + title="{{PF2EBTCategoryClassTitle resistance.class 'Resistance' ../vagueDescriptions.resistances}}" > - {{monsterValue resistance ../vagueDescriptions.resistances}} + {{PF2EBTMonsterValue resistance ../vagueDescriptions.resistances}} {{#if (and (not ../user.isGM) (gt ../this.resistances.currentRevealed resistance.index))}}, {{/if}} {{/if}} @@ -122,15 +122,15 @@
{{localize "PF2EBestiary.Miscellaneous.Saves.Fortitude.Short"}}
-
{{#if (or this.user.isGM this.saves.fortitude.revealed)}}{{monsterValue this.saves.fortitude this.vagueDescriptions.saves}}{{else}}?{{/if}}
+
{{#if (or this.user.isGM this.saves.fortitude.revealed)}}{{PF2EBTMonsterValue this.saves.fortitude this.vagueDescriptions.saves}}{{else}}?{{/if}}
{{localize "PF2EBestiary.Miscellaneous.Saves.Reflex.Short"}}
-
{{#if (or this.user.isGM this.saves.reflex.revealed)}}{{monsterValue this.saves.reflex this.vagueDescriptions.saves}}{{else}}?{{/if}}
+
{{#if (or this.user.isGM this.saves.reflex.revealed)}}{{PF2EBTMonsterValue this.saves.reflex this.vagueDescriptions.saves}}{{else}}?{{/if}}
{{localize "PF2EBestiary.Miscellaneous.Saves.Will.Short"}}
-
{{#if (or this.user.isGM this.saves.will.revealed)}}{{monsterValue this.saves.will this.vagueDescriptions.saves}}{{else}}?{{/if}}
+
{{#if (or this.user.isGM this.saves.will.revealed)}}{{PF2EBTMonsterValue this.saves.will this.vagueDescriptions.saves}}{{else}}?{{/if}}
@@ -160,7 +160,7 @@
-
{{#if (or this.user.isGM this.name.revealed)}}{{this.name.value}}{{else}}{{localize "PF2EBestiary.Miscellaneous.UnknownCreature"}}{{/if}}
+
{{#if (or this.user.isGM this.name.revealed)}}{{this.name.value}}{{else}}{{localize "PF2EBestiary.Bestiary.Miscellaneous.UnknownCreature"}}{{/if}}
{{this.size}}
@@ -213,7 +213,7 @@
{{sense.label}}
{{#if (and (not ../user.isGM) (eq key 'perception'))}} - {{monsterValue sense ../vagueDescriptions.perception }} + {{PF2EBTMonsterValue sense ../vagueDescriptions.perception }} {{else}} {{sense.value}} {{/if}}