Skip to content

Commit

Permalink
Merge pull request #47 from kandashi/0.1.30
Browse files Browse the repository at this point in the history
0.1.30
  • Loading branch information
kandashi authored Jan 21, 2021
2 parents 5cfc1b9 + 78fe131 commit c0aa6a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Active-Auras",
"description": "Active-Auras",
"author": "Kandashi",
"version": "0.1.29",
"version": "0.1.3",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9",
"packs": [
Expand Down
24 changes: 19 additions & 5 deletions src/aura.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Hooks.on("ready", () => {
* Hooks onto effect sheet to add aura configuration
*/
Hooks.on("renderActiveEffectConfig", async (sheet, html) => {
await sheet.object.setFlag(`${MODULE_NAME}`, 'aura')
if(!sheet.object.data.flags?.ActiveAuras?.aura) {
await sheet.object.setFlag(`${MODULE_NAME}`, 'aura')
}
const flags = sheet.object.data.flags;

const FormIsAura = game.i18n.format("ACTIVEAURAS.FORM_IsAura");
Expand Down Expand Up @@ -120,7 +122,7 @@ Hooks.on("ready", () => {
*/
Hooks.on("updateToken", (scene, token, update, flags, id) => {
if (("y" in update || "x" in update || "elevation" in update))
MainAura(token,)
MainAura(token)
if ((update?.actorData?.effects) || ("hidden" in update)) {
setTimeout(() => {
CollateAuras(canvas, true, true)
Expand Down Expand Up @@ -177,7 +179,13 @@ Hooks.on("ready", () => {
}
}


function IsAuraToken(token,canvas){
let MapKey = canvas.scene._id;
MapObject = AuraMap.get(MapKey);
for (let effect of MapObject.effects){
if(effect.tokenId === token._id) return true;
}
}

function CollateAuras(canvas, checkAuras, removeAuras) {
let gm = game.user === game.users.find((u) => u.isGM && u.active)
Expand Down Expand Up @@ -253,8 +261,14 @@ Hooks.on("ready", () => {
if (!gm) return;

let map = new Map();

UpdateAllTokens(map, canvas.tokens.placeables)
let updateTokens = canvas.tokens.placeables
if(movedToken !== undefined){
if(!IsAuraToken(movedToken, canvas)) {
updateTokens = [];
updateTokens.push(canvas.tokens.get(movedToken._id))
}
}
UpdateAllTokens(map, updateTokens)

for (let mapEffect of map) {
let MapKey = mapEffect[0]
Expand Down

0 comments on commit c0aa6a3

Please sign in to comment.