Skip to content

Commit

Permalink
Add GM check for advantage scenarios
Browse files Browse the repository at this point in the history
Abort Advantage updates if not the GM when
- adding a condition
- creating a combatant
- deleting a combatant
  • Loading branch information
Jagusti committed Jul 31, 2022
1 parent 9b1032a commit 121ee10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format

## Unreleased
See [Issue Backlog](../../issues) and [Roadmap](../../milestones).
- *Fixed* issue where players would see permission errors during advantage updates on other users' actors.

## [Version 0.9.4.2](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/releases/tag/v0.9.4.2) (2022-07-29)
- *Added* localization improvements for Condition Check and Secret Group Test macros. (Thanks @Txus5012!) [[#141](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/pull/141)]
Expand Down
5 changes: 3 additions & 2 deletions modules/advantage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ Hooks.on("createActiveEffect", async function(conditionEffect) {

// Exit if not using condition automation, or if Group Advantage is in play
if ((!game.settings.get(GMToolkit.MODULE_ID, "automateConditionAdvantage")) || (game.settings.get("wfrp4e", "useGroupAdvantage"))) return
if ((!game.user.isUniqueGM)) return

if (!conditionEffect.isCondition) return
let condId = conditionEffect.conditionId
Expand All @@ -434,15 +435,15 @@ Hooks.on("createActiveEffect", async function(conditionEffect) {
Hooks.on("createCombatant", function(combatant) {
// ADDING TO COMBAT: clear token Advantange only if enabled, and Group Advantage is not being used.
// If Group Advantage is used, the system handles syncing individual advantage with the group
if (game.settings.get(GMToolkit.MODULE_ID, "clearAdvantageCombatJoin") && !(game.settings.get("wfrp4e", "useGroupAdvantage"))) {
if (game.user.isUniqueGM && game.settings.get(GMToolkit.MODULE_ID, "clearAdvantageCombatJoin") && !(game.settings.get("wfrp4e", "useGroupAdvantage"))) {
let token = canvas.tokens.placeables.filter(a => a.data._id == combatant.data.tokenId)[0]
Advantage.update(token, "clear", "createCombatant");
Advantage.unsetFlags([combatant])
}
});

Hooks.on("deleteCombatant", function(combatant) {
if (game.settings.get(GMToolkit.MODULE_ID, "clearAdvantageCombatLeave")) {
if (game.user.isUniqueGM && game.settings.get(GMToolkit.MODULE_ID, "clearAdvantageCombatLeave")) {
let token = canvas.tokens.placeables.filter(a => a.data._id == combatant.data.tokenId)[0]
Advantage.update(token, "clear", "deleteCombatant");
Advantage.unsetFlags([combatant], true)
Expand Down

0 comments on commit 121ee10

Please sign in to comment.