Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Update swade-br2sw.js (#300)
Browse files Browse the repository at this point in the history
* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update module.json

* Update swade-br2sw.js

Improve the functionality of _toggleStatus in br2sw
This makes the effect gain the flags.core.statusId = actionId property and also future-proofs in case SWADE system or other functionality has already added the relevant active effect to the token.
  • Loading branch information
zk-sn authored Jul 3, 2021
1 parent 881b473 commit d92bf23
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions scripts/rollHandlers/swade/swade-br2sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,16 @@ export class RollHandlerBR2SWSwade extends RollHandler {
update.data.status[status] = !actor.data.data.status[status];

await actor.update(update);

const effect = CONFIG.SWADE.statusEffects.find(e=>e.id===actionId);
const existingOnToken = actor.effects.find(e => e.getFlag("core", "statusId") === actionId);

if (!existingOnToken == !existingOnSheet) {
canvas.tokens.get(tokenId).toggleEffect(effect);
}
// SWADE system will eventually set the active effect on the token, this future-proofs it so duplicate effects don't occur
setTimeout(() => {
const existingOnToken = actor.effects.find(e => e.getFlag("core", "statusId") === actionId);

if (!existingOnToken == !existingOnSheet) {
const effect = CONFIG.SWADE.statusEffects.find(e=>e.id===actionId);
effect["flags.core.statusId"] = actionId;
canvas.tokens.get(tokenId).toggleEffect(effect);
}
}, 10);
}

/** @private */
Expand Down

0 comments on commit d92bf23

Please sign in to comment.