Skip to content

Commit

Permalink
Update aura.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kandashi committed Jan 1, 2021
1 parent 0edfcec commit 9cc672c
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/aura.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => {

const aoeHTML = `
<div class="form-group">
<label>EAura Targets:</label>
<label>Aura Targets:</label>
<label></label>
<div class="aura">
<select name="flags.${MODULE_NAME}.aura" data-dtype="String" value=${flags[MODULE_NAME]?.aura}>
Expand Down Expand Up @@ -38,8 +38,6 @@ Hooks.on("deleteToken", (scene, token) => {
});

Hooks.on("updateToken", async (scene, token, update, flags, id) => {
// console.log(token);
// console.log(updateData);
if (!("y" in update || "x" in update)) return;
MainAura(token,)
});
Expand All @@ -63,7 +61,7 @@ function MainAura(movedToken) {

for(let update of map){
if(update[1].add){
createActiveEffect(update[1].token, update[1].effect.data)
createActiveEffect(update[1].token, update[1].effect)
}
else {
removeActiveEffects(update[1].token, update[1].effect.data.label)
Expand Down Expand Up @@ -123,10 +121,15 @@ function RayDistance(token1, token2) {


async function createActiveEffect(token, effectData) {
let newEffectData = duplicate(effectData)
let newEffectData = duplicate(effectData.data)
newEffectData.flags.ActiveAuras= {
aura: "None"
}
if(newEffectData.changes[0].value.includes("@")){
let dataPath = newEffectData.changes[0].value.substring(1)
let newValue = getProperty(effectData.parent.getRollData(), dataPath)
newEffectData.changes[0].value = newValue
}
console.log(newEffectData)
if (token.actor.effects.entries.find(e => e.data.label === newEffectData.label)) return
await token.actor.createEmbeddedEntity("ActiveEffect", newEffectData);
Expand All @@ -140,12 +143,3 @@ function removeActiveEffects(token, effectLabel) {
}
}
}

//Split this up -->
//getRecipients --> create an array of recipients, their token + the mod.
//Overwrite array entry if existing token in multiple paladin auraSource

//applyAuras(recipients) --> single database update
//use updateEmbeddedEntity() or updateMany()


0 comments on commit 9cc672c

Please sign in to comment.