Skip to content

Commit 656eecf

Browse files
committed
Re-implement dice rolling
Fixes #11
1 parent 7e1ddda commit 656eecf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

module/basicfantasyrpg.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ Hooks.once("ready", async function() {
8080
Hooks.on("hotbarDrop", (bar, data, slot) => createItemMacro(data, slot));
8181
});
8282

83+
/* -------------------------------------------- */
84+
/* Token Creation Hooks */
85+
/* -------------------------------------------- */
86+
87+
Hooks.on("createToken", async function(token, options, id) {
88+
if (token.actor.type === "monster") {
89+
let newHitPoints = new Roll(`${token.actor.data.data.hitDice.number}${token.actor.data.data.hitDice.size}+${token.actor.data.data.hitDice.mod}`);
90+
await newHitPoints.evaluate({ async: true });
91+
token.actor.data.data.hitPoints.value = newHitPoints.total;
92+
token.actor.data.data.hitPoints.max = newHitPoints.total;
93+
}
94+
});
95+
8396
/* -------------------------------------------- */
8497
/* Hotbar Macros */
8598
/* -------------------------------------------- */

0 commit comments

Comments
 (0)