Skip to content

Commit

Permalink
Added a failsafe for if the Party token is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
WBHarry committed Oct 18, 2024
1 parent 79474e9 commit c61a449
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
40 changes: 27 additions & 13 deletions BestiaryTracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -5846,7 +5846,7 @@ class Creature extends foundry.abstract.TypeDataModel {
? game.user.character.system.details.level.value
: null;
const contextLevel = vagueDescriptions.settings.playerBased
? !Number.isNaN(gmLevel) && game.user.isGM
? (gmLevel && !Number.isNaN(gmLevel) && game.user.isGM)
? gmLevel
: (playerLevel ?? this.level.value)
: this.level.value;
Expand Down Expand Up @@ -9721,7 +9721,7 @@ class BestiaryThemesMenu extends HandlebarsApplicationMixin$5(
};
}

const currentVersion = "1.1.16";
const currentVersion = "1.1.17";
const bestiaryFolder = "BestiaryTracking Bestiares";

const dataTypeSetup = () => {
Expand Down Expand Up @@ -9891,7 +9891,7 @@ const configSettings = () => {
required: true,
}),
requiresReload: true,
default: 'coreLight'
default: "coreLight",
});

game.settings.register("pf2e-bestiary-tracking", "bestiary-theme", {
Expand All @@ -9909,10 +9909,10 @@ const configSettings = () => {

game.user.setFlag("pf2e-bestiary-tracking", "bestiary-theme", value);
},
default: 'default'
default: "default",
});
};

const generalNonConfigSettings = () => {
game.settings.register("pf2e-bestiary-tracking", "version", {
name: game.i18n.localize("PF2EBestiary.Settings.Version.Name"),
Expand Down Expand Up @@ -17561,13 +17561,22 @@ Hooks.once("ready", async () => {
});

Hooks.once("setup", () => {
const userTheme = game.user.getFlag("pf2e-bestiary-tracking", "bestiary-theme");
if(userTheme){
const userTheme = game.user.getFlag(
"pf2e-bestiary-tracking",
"bestiary-theme",
);
if (userTheme) {
game.settings.set("pf2e-bestiary-tracking", "bestiary-theme", userTheme);
}

const selectedTheme = game.settings.get("pf2e-bestiary-tracking", "bestiary-theme");
const theme = selectedTheme === 'default' ? game.settings.get("pf2e-bestiary-tracking", "bestiary-default-theme") : selectedTheme;
const selectedTheme = game.settings.get(
"pf2e-bestiary-tracking",
"bestiary-theme",
);
const theme =
selectedTheme === "default"
? game.settings.get("pf2e-bestiary-tracking", "bestiary-default-theme")
: selectedTheme;
setupTheme(extendedBestiaryThemes()[theme].props);

if (typeof libWrapper === "function") {
Expand Down Expand Up @@ -18259,10 +18268,15 @@ Hooks.on("renderActorSheet", (sheet) => {
});

Hooks.on(socketEvent.ResetBestiaryTheme, () => {
const selectedTheme = game.settings.get("pf2e-bestiary-tracking", "bestiary-theme");
const theme = selectedTheme === 'default' ? game.settings.get("pf2e-bestiary-tracking", "bestiary-default-theme") : selectedTheme;
const resetTheme =
extendedBestiaryThemes()[theme];
const selectedTheme = game.settings.get(
"pf2e-bestiary-tracking",
"bestiary-theme",
);
const theme =
selectedTheme === "default"
? game.settings.get("pf2e-bestiary-tracking", "bestiary-default-theme")
: selectedTheme;
const resetTheme = extendedBestiaryThemes()[theme];
setupTheme(
resetTheme ? resetTheme.props : extendedBestiaryThemes()["coreLight"].props,
);
Expand Down
2 changes: 1 addition & 1 deletion data/creature.js
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ export class Creature extends foundry.abstract.TypeDataModel {
? game.user.character.system.details.level.value
: null;
const contextLevel = vagueDescriptions.settings.playerBased
? !Number.isNaN(gmLevel) && game.user.isGM
? gmLevel && !Number.isNaN(gmLevel) && game.user.isGM
? gmLevel
: (playerLevel ?? this.level.value)
: this.level.value;
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "pf2e-bestiary-tracking",
"title": "PF2E Bestiary Tracking",
"description": "A module to track known information about enemies for players in a bestiary.",
"version": "1.1.16",
"version": "1.1.17",
"authors": [
{
"name": "HarryBoy"
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import BestiaryDisplayMenu from "../module/bestiaryDisplayMenu.js";
import BestiaryThemesMenu from "../module/bestiaryThemesMenu.js";

export const currentVersion = "1.1.16";
export const currentVersion = "1.1.17";
export const bestiaryFolder = "BestiaryTracking Bestiares";

export const dataTypeSetup = () => {
Expand Down

0 comments on commit c61a449

Please sign in to comment.