From 0d5ae819fc843ff1d09e892058e06c54e73a55f1 Mon Sep 17 00:00:00 2001 From: Vito Gamberini Date: Tue, 8 Nov 2022 06:10:45 -0500 Subject: [PATCH] feat(spell): Implement Aid --- macro-item/spell/PHB_aid.js | 12 ++++++++++++ module/data/spell/__core.json | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 macro-item/spell/PHB_aid.js diff --git a/macro-item/spell/PHB_aid.js b/macro-item/spell/PHB_aid.js new file mode 100644 index 0000000..cf84a1f --- /dev/null +++ b/macro-item/spell/PHB_aid.js @@ -0,0 +1,12 @@ +async function macro (args) { + const tactor = (await fromUuid(args[1].tokenUuid)).actor; + + const health = tactor.system.attributes.hp.value; + const healthChange = eval(args[1].efData.changes[0].value); // eslint-disable-line no-eval + + if (args[0] === "on") { + tactor.update({ "system.attributes.hp.value": health + healthChange }); + } else if (args[0] === "off") { + tactor.update({ "system.attributes.hp.value": Math.max(health - healthChange, 0) }); + } +} diff --git a/module/data/spell/__core.json b/module/data/spell/__core.json index 46b0348..e519e8a 100644 --- a/module/data/spell/__core.json +++ b/module/data/spell/__core.json @@ -1,5 +1,34 @@ { "spell": [ + { + "name": "Aid", + "source": "PHB", + "data": { + "damage.parts": [] + }, + "effects": [ + { + "changes": [ + { + "key": "system.attributes.hp.max", + "mode": "ADD", + "value": "(@item.level - 1) * 5", + "priority": 20 + }, + { + "key": "macro.itemMacro", + "mode": "CUSTOM", + "value": "", + "priority": 20 + } + ], + "duration": { + "seconds": 28800 + } + } + ], + "itemMacro": "PHB_aid.js" + }, { "name": "Aura of Purity", "source": "PHB",