add spell item dropin for spell based triggers and actions
This commit is contained in:
Executable → Regular
Executable → Regular
+16
-3
@@ -6,8 +6,13 @@ export async function executeCastSpellAction(action, context) {
|
||||
const item = await resolveItem(actor, action.spellSelection);
|
||||
if (!item) return { success: false, consumed: false, reason: "NO_SPELL_ITEM" };
|
||||
|
||||
if (action.activationMode === "autoUse" && typeof item.use === "function") {
|
||||
await item.use({}, { configureDialog: true });
|
||||
return { success: true, consumed: true };
|
||||
}
|
||||
|
||||
item.sheet?.render(true);
|
||||
ui.notifications.info(`${item.name} wurde für ${actor.name} geöffnet. Vollautomatische Zauberauslösung folgt in einer späteren Version.`);
|
||||
ui.notifications.info(`${item.name} wurde für ${actor.name} geöffnet. Der Zauber wird aus dem Inventar des Characters über dessen Spellslots genutzt.`);
|
||||
|
||||
return { success: true, consumed: true };
|
||||
}
|
||||
@@ -22,7 +27,15 @@ function resolveCasterToken(action, context) {
|
||||
}
|
||||
|
||||
async function resolveItem(actor, selection = {}) {
|
||||
if (selection.mode === "itemUuid" && selection.itemUuid) return fromUuid(selection.itemUuid);
|
||||
if (selection.mode === "itemName" && selection.itemName) return actor.items.find(item => item.name === selection.itemName);
|
||||
if (selection.mode === "itemUuid" && selection.itemUuid) {
|
||||
const item = await fromUuid(selection.itemUuid);
|
||||
return item?.type === "spell" ? item : null;
|
||||
}
|
||||
|
||||
if (selection.mode === "itemName" && selection.itemName) {
|
||||
const expected = selection.itemName.toLocaleLowerCase();
|
||||
return actor.items.find(item => item.type === "spell" && item.name.toLocaleLowerCase() === expected) ?? null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Executable → Regular
Executable → Regular
Reference in New Issue
Block a user