29 lines
932 B
JavaScript
29 lines
932 B
JavaScript
const tokens = canvas.tokens.controlled;
|
|
const actors = tokens.map((t) => t.actor);
|
|
const EFFECT_OBJECT = {
|
|
name: 'Effect',
|
|
type: 'macro',
|
|
dice: null,
|
|
resourcesUsed: null,
|
|
modifier: '',
|
|
override: '',
|
|
uuid: 'Compendium.swade-mb-helpers.helper-macros.Macro.AjuA11hQ48UJNwlH',
|
|
macroActor: 'self',
|
|
isHeavyWeapon: false,
|
|
};
|
|
for (const actor of actors) {
|
|
const updates = [];
|
|
for (const power of actor.items.filter((i) => i.type === 'power')) {
|
|
if (Object.values(power.system.actions.additional).find((action) => action.name === 'Effect')) {
|
|
continue;
|
|
}
|
|
const _id = power.id;
|
|
const additional = foundry.utils.deepClone(power.system.actions.additional);
|
|
additional[foundry.utils.randomID(8)] = foundry.utils.deepClone(EFFECT_OBJECT);
|
|
updates.push({ _id, 'system.actions.additional': additional });
|
|
}
|
|
if (updates.length > 0) {
|
|
actor.updateEmbeddedDocuments('Item', updates);
|
|
}
|
|
}
|