From 3b74ce2a5b0bec5422a144f358e2eaf63c046bae Mon Sep 17 00:00:00 2001
From: Johannes Loher <johannes.loher@fg4f.de>
Date: Thu, 19 May 2022 02:36:05 +0200
Subject: [PATCH] feat: add rollItem hook

---
 src/item/item.ts          | 7 +++++++
 src/item/spell/spell.ts   | 2 ++
 src/item/weapon/weapon.ts | 2 ++
 3 files changed, 11 insertions(+)

diff --git a/src/item/item.ts b/src/item/item.ts
index d3041604..7a279bcd 100644
--- a/src/item/item.ts
+++ b/src/item/item.ts
@@ -11,6 +11,13 @@ declare global {
     interface DocumentClassConfig {
         Item: typeof DS4Item;
     }
+
+    // eslint-disable-next-line @typescript-eslint/no-namespace
+    namespace Hooks {
+        interface StaticCallbacks {
+            "ds4.rollItem": (item: DS4Item) => void;
+        }
+    }
 }
 
 /**
diff --git a/src/item/spell/spell.ts b/src/item/spell/spell.ts
index efcf8f1a..cf1fea29 100644
--- a/src/item/spell/spell.ts
+++ b/src/item/spell/spell.ts
@@ -55,6 +55,8 @@ export class DS4Spell extends DS4Item {
             flavorData: { actor: speaker.alias ?? this.actor.name, spell: this.name },
             speaker,
         });
+
+        Hooks.callAll("ds4.rollItem", this);
     }
 }
 
diff --git a/src/item/weapon/weapon.ts b/src/item/weapon/weapon.ts
index dabea48f..8d3bc2df 100644
--- a/src/item/weapon/weapon.ts
+++ b/src/item/weapon/weapon.ts
@@ -47,6 +47,8 @@ export class DS4Weapon extends DS4Item {
             flavorData: { actor: speaker.alias ?? this.actor.name, weapon: this.name },
             speaker,
         });
+
+        Hooks.callAll("ds4.rollItem", this);
     }
 
     private async getCombatValueKeyForAttackType(attackType: AttackType): Promise<"meleeAttack" | "rangedAttack"> {