Skip to content

Commit

Permalink
Added a fallback option for InCombat Combatant token missing
Browse files Browse the repository at this point in the history
  • Loading branch information
WBHarry committed Oct 31, 2024
1 parent ddb8a55 commit d39de32
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
15 changes: 10 additions & 5 deletions BestiaryTracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -9970,7 +9970,7 @@ class BestiaryThemesMenu extends HandlebarsApplicationMixin$5(
};
}

const currentVersion = "1.1.24";
const currentVersion = "1.1.25";
const bestiaryFolder = "BestiaryTracking Bestiares";

const dataTypeSetup = () => {
Expand Down Expand Up @@ -15220,10 +15220,15 @@ class PF2EBestiary extends HandlebarsApplicationMixin(
const inCombatType =
combatants &&
combatants.find(
(x) =>
x.token?.baseActor?.uuid === entity.system.uuid ||
x.actorId === entity.system.id,
);
(x) => {
const token = x.token ?? game.combat.scene.tokens.find(token => token.actorId === x.actorId);
if(token){
return token.baseActor?.uuid === entity.system.uuid ||
x.actorId === entity.system.id;
}

return false;
});
if (inCombatType) {
acc
.find((x) => x.value === "combat")
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "pf2e-bestiary-tracking",
"title": "PF2E Bestiary Tracking",
"description": "A module to track known information about enemies for players in a bestiary.",
"version": "1.1.24",
"version": "1.1.25",
"authors": [
{
"name": "HarryBoy",
Expand Down
20 changes: 15 additions & 5 deletions module/bestiary.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,21 @@ export default class PF2EBestiary extends HandlebarsApplicationMixin(
const reduceFunc = (npcCategories, combatants) => (acc, entity) => {
const inCombatType =
combatants &&
combatants.find(
(x) =>
x.token?.baseActor?.uuid === entity.system.uuid ||
x.actorId === entity.system.id,
);
combatants.find((x) => {
const token =
x.token ??
game.combat.scene.tokens.find(
(token) => token.actorId === x.actorId,
);
if (token) {
return (
token.baseActor?.uuid === entity.system.uuid ||
x.actorId === entity.system.id
);
}

return false;
});
if (inCombatType) {
acc
.find((x) => x.value === "combat")
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import BestiaryDisplayMenu from "../module/bestiaryDisplayMenu.js";
import BestiaryThemesMenu from "../module/bestiaryThemesMenu.js";

export const currentVersion = "1.1.24";
export const currentVersion = "1.1.25";
export const bestiaryFolder = "BestiaryTracking Bestiares";

export const dataTypeSetup = () => {
Expand Down

0 comments on commit d39de32

Please sign in to comment.