Skip to content

Commit

Permalink
Fixes #802
Browse files Browse the repository at this point in the history
  • Loading branch information
PrototypeESBU committed May 26, 2024
1 parent 20f52ab commit f56ec53
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
8 changes: 8 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v2.2.2

## Bugfixes
* [#799] Character Generator incorrectly generating character stats
* [#802] Light sources counting down to quickly with multiple GMs logged in

---

# v2.2.1

## Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion system/src/apps/LightSourceTrackerSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export default class LightSourceTrackerSD extends Application {
}

async onUpdateWorldTime(worldTime, worldDelta) {
if (!(this._isEnabled() && game.user.isGM)) return;
if (!(this._isEnabled() && shadowdark.utils.isPrimaryGM())) return;
if (this.updatingLightSources) return;

const updateSecs = game.settings.get(
Expand Down
1 change: 1 addition & 0 deletions system/src/hooks/light-source-tracker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const LightSourceTrackerHooks = {
const lst = game.shadowdark.lightSourceTracker;

if (game.user.isGM) {
game.user.setFlag("shadowdark", "primaryGM", false);
game.shadowdark.lightSourceTracker.start();
Hooks.on("deleteActor", lst._deleteActorHook.bind(lst));
Hooks.on("deleteItem", lst._deleteItemHook.bind(lst));
Expand Down
24 changes: 24 additions & 0 deletions system/src/utils/UtilitySD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,28 @@ export default class UtilitySD {
}
return itemObj;
}

static isPrimaryGM() {
if (!game.user.isGM) return false;

// if primaryGM flag is true, return
if (game.user.getFlag("shadowdark", "primaryGM")) {
return true;
}
else {
// locate the primary GM
const primaryGMs = game.users.filter(x =>
x.active === true && x.flags.shadowdark.primaryGM === true
);
if (primaryGMs.length === 0) {
// if no primary GM, set current user as primary GM
game.user.setFlag("shadowdark", "primaryGM", true);
shadowdark.log("Promoted to Primary GM");
return true;
}
else {
return false;
}
}
}
}

0 comments on commit f56ec53

Please sign in to comment.