forked from hermannm/foundry-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbless.js
39 lines (39 loc) · 1.2 KB
/
bless.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const effect = {
name: "Bless",
modifier: {
stat: "attack",
value: 1,
type: "status",
},
iconPath: "systems/pf2e/icons/spells/bless.jpg",
};
(async () => {
if (
(actor.data.data.customModifiers[effect.modifier.stat] || []).some(
(customModifier) => customModifier.name === effect.name
)
) {
if (token.data.effects.includes(effect.iconPath)) {
await token.toggleEffect(effect.iconPath);
}
await actor.removeCustomModifier(effect.modifier.stat, effect.name);
} else {
const itemID =
actor.items
.filter((item) => item.data.type === "action")
.find((item) => item.data.name === effect.name)?._id ??
actor.items.find((item) => item.data.name === effect.name)?._id;
if (itemID) {
game.pf2e.rollItemMacro(itemID);
}
if (!token.data.effects.includes(effect.iconPath)) {
await token.toggleEffect(effect.iconPath);
}
await actor.addCustomModifier(
effect.modifier.stat,
effect.name,
effect.modifier.value,
effect.modifier.type
);
}
})();