Skip to content

Commit

Permalink
Merge pull request #258 from DarkByteZero/main
Browse files Browse the repository at this point in the history
Add Basic Support for isSuppressed & Change Support for dnd5e
  • Loading branch information
MrPrimate authored Dec 27, 2022
2 parents 9976bf8 + ef23bf7 commit 8331cc9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/AAhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,31 @@ Hooks.on("updateToken", async (token, update, _flags, _id) => {
});


/**
* On item Change for example equipped state change
*/
Hooks.on("updateItem", (item, update, _flags, _id) => {
if (AAdebug) console.log("updateItemHookArgs", {item, update, _flags, _id});
if (canvas.scene === null) { if (AAdebug) { console.log("Active Auras disabled due to no canvas") } return }
if (!AAgm) return;
// check if item has active Effect with ActiveAura
if (!item.effects.map(i => i.flags?.ActiveAuras?.isAura).includes(true)) { return }

// isSuppressed Checks for dnd5e
// dnd5e makes an effect isSuppressed when equipped or attunement status changes


if (hasProperty(update, "system.equipped")) {
if (AAdebug) console.log(`equipped, collate auras true true`);
debouncedCollate(canvas.scene.id, true, true, "updateItem, equipped");
} else if (hasProperty(update, "system.attunement")) {
if (AAdebug) console.log(`attunement, collate auras true true`);
debouncedCollate(canvas.scene.id, true, true, "updateItem, attunement");
}

});


/**
*/
Hooks.on("updateActiveEffect", (effect, _update) => {
Expand Down
3 changes: 3 additions & 0 deletions src/collateAuras.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async function CollateAuras(sceneID, checkAuras, removeAuras, source) {
for (const testEffect of testToken?.actor?.effects.contents) {
if (testEffect.flags?.ActiveAuras?.isAura) {
if (testEffect.disabled) continue;
if (testEffect.isSuppressed) continue; // effect is supressed for example because it is unequipped
const newEffect = { data: duplicate(testEffect), parentActorLink: testEffect.parent.prototypeToken.actorLink, parentActorId: testEffect.parent.id, entityType: "token", entityId: testToken.id };
const re = /@[\w\.]+/g;
const rollData = testToken.actor.getRollData();
Expand Down Expand Up @@ -89,6 +90,7 @@ function RetrieveTemplateAuras(effectArray) {
for (const template of auraTemplates) {
for (const testEffect of template.document.flags?.ActiveAuras?.IsAura) {
if (testEffect.disabled) continue;
if (testEffect.isSuppressed) continue; // effect is supressed for example because it is unequipped
const newEffect = duplicate(testEffect);
const parts = testEffect.data.origin.split(".")
const [entityName, entityId, embeddedName, embeddedId] = parts;
Expand Down Expand Up @@ -124,6 +126,7 @@ function RetrieveDrawingAuras(effectArray) {
for (const drawing of auraDrawings) {
for (const testEffect of drawing.document.flags?.ActiveAuras?.IsAura) {
if (testEffect.disabled) continue;
if (testEffect.isSuppressed) continue; // effect is supressed
const newEffect = { data: duplicate(testEffect), parentActorId: false, parentActorLink: false, entityType: "drawing", entityId: drawing.id, };
const parts = testEffect.origin.split(".");
const [entityName, entityId, embeddedName, embeddedId] = parts;
Expand Down

0 comments on commit 8331cc9

Please sign in to comment.