Skip to content

Commit d0a0046

Browse files
committed
fix: actions macro
1 parent 6dce8aa commit d0a0046

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

module/projectfu.mjs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ Handlebars.registerHelper('getIconClass', function (item, equippedItems) {
372372
if (itemId === equippedItems.mainHand && item.type === 'shield') {
373373
return 'ra ra-heavy-shield ra-1xh';
374374
}
375-
// Special case: if item is in tthe phantom slot
375+
// Special case: if item is in the phantom slot
376376
if (item.type === 'weapon' && itemId === equippedItems.phantom) {
377377
return 'ra ra-daggers ra-1xh';
378378
}
@@ -445,8 +445,11 @@ Hooks.once('ready', async function () {
445445
Hooks.on('hotbarDrop', (bar, data, slot) => createItemMacro(data, slot));
446446

447447
Hooks.on('rollEquipment', (actor, slot) => {
448+
// Detect if the shift key is currently pressed
449+
const isShift = game.keyboard.isModifierActive(KeyboardManager.MODIFIER_KEYS.SHIFT);
450+
448451
// Call the rollEquipment function
449-
rollEquipment(actor, slot);
452+
rollEquipment(actor, slot, isShift);
450453
});
451454

452455
Hooks.on('promptCheckCalled', (actor) => {
@@ -645,28 +648,30 @@ function rollItemMacro(itemUuid) {
645648
*/
646649
function rollEquipment(actor, slot, isShift) {
647650
// Check if the slot is valid
648-
const validSlots = ['mainHand', 'offHand', 'armor', 'accessory'];
651+
const validSlots = ['mainHand', 'offHand', 'armor', 'accessory', 'phantom', 'arcanum'];
649652
if (!validSlots.includes(slot)) {
650653
ui.notifications.warn(`Invalid slot: ${slot}!`);
651654
return;
652655
}
653656

654-
// Filter items based on the provided slot
655-
const sameSlotItems = actor.items.filter((item) => {
656-
return item.system.isEquipped && item.system.isEquipped.slot === slot;
657-
});
657+
// Get the equipped item for the specified slot from actor.system.equipped
658+
const equippedItemId = actor.system.equipped[slot];
658659

659-
// Check if any item is found in the specified slot
660-
if (sameSlotItems.length === 0) {
660+
// If no item is equipped in the specified slot
661+
if (!equippedItemId) {
661662
ui.notifications.warn(`No item equipped in ${slot} slot!`);
662663
return;
663664
}
664665

665-
// Get the first item from the filtered collection
666-
const item = sameSlotItems[0];
666+
// Find the item in the actor's items by ID
667+
const item = actor.items.get(equippedItemId);
667668

668-
// Roll the item
669-
item.roll(isShift);
669+
// If the item exists, roll it
670+
if (item) {
671+
item.roll(isShift);
672+
} else {
673+
ui.notifications.warn(`Equipped item in ${slot} slot not found!`);
674+
}
670675
}
671676

672677
const logo = document.getElementById('logo');

0 commit comments

Comments
 (0)