From db21ca93b0458fdbe25b0d764be14bed033c7a6c Mon Sep 17 00:00:00 2001 From: Byroks Date: Sun, 26 Nov 2023 13:13:13 +0100 Subject: [PATCH] subtract ap when casting spell Changes: + subtract AP when casting a spell --- source/module/items/M5Item.ts | 6 ++++++ source/module/sheets/M5CharacterSheet.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/source/module/items/M5Item.ts b/source/module/items/M5Item.ts index 34e09bb..c759191 100644 --- a/source/module/items/M5Item.ts +++ b/source/module/items/M5Item.ts @@ -215,6 +215,12 @@ export class M5Item extends Item { } }); + if (item.type === "spell" || item.type === "kampfkunst") { + if (this.actor["system"].ap.value >= item.system.ap) { + this.actor["system"].ap.value -= item.system.ap; + } + } + const roll = new M5Roll(rollData, this.actor, item.name); return roll.toMessage(); } else { diff --git a/source/module/sheets/M5CharacterSheet.ts b/source/module/sheets/M5CharacterSheet.ts index 9aeb08f..655ef3e 100644 --- a/source/module/sheets/M5CharacterSheet.ts +++ b/source/module/sheets/M5CharacterSheet.ts @@ -160,6 +160,7 @@ export default class M5CharacterSheet extends ActorSheet { const context = this.actor as any; const item = context.items.get(itemId) as M5Item; await item.roll(); + this.render(); }); html.find(".roll-brawl-button").on("click", async (event) => {