Skip to content

Commit c064e28

Browse files
committed
a
1 parent 5fdbd17 commit c064e28

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/config.js

+34-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function initConfig() {
88
registerItems();
99
const ARGON = CoreHUD.ARGON;
1010

11-
class DND5eTooltip extends ARGON.CORE.Tooltip{
11+
class DND5eTooltip extends ARGON.CORE.Tooltip {
1212
get classes() {
1313
const original = super.classes;
1414
return original.concat(["dnd5e2"]);
@@ -371,15 +371,15 @@ export function initConfig() {
371371
[
372372
{
373373
label: CONFIG.DND5E.abilities[ability].label,
374-
onClick: (event) => this.actor.rollAbilityCheck({ability, event}),
374+
onClick: (event) => this.actor.rollAbilityCheck({ ability, event }),
375375
},
376376
{
377377
label: addSign(abilityData.mod + (abilityData.checkBonus || 0)),
378-
onClick: (event) => this.actor.rollAbilityCheck({ability, event}),
378+
onClick: (event) => this.actor.rollAbilityCheck({ ability, event }),
379379
},
380380
{
381381
label: addSign(abilityData.save),
382-
onClick: (event) => this.actor.rollSavingThrow({ability, event }),
382+
onClick: (event) => this.actor.rollSavingThrow({ ability, event }),
383383
},
384384
],
385385
ability,
@@ -393,7 +393,7 @@ export function initConfig() {
393393
[
394394
{
395395
label: getProficiencyIcon(skillData.proficient) + CONFIG.DND5E.skills[skill].label,
396-
onClick: (event) => this.actor.rollSkill({skill, event}),
396+
onClick: (event) => this.actor.rollSkill({ skill, event }),
397397
},
398398
{
399399
label: `${addSign(skillData.total)}<span style="margin: 0 1rem; filter: brightness(0.8)">(${skillData.passive})</span>`,
@@ -741,7 +741,6 @@ export function initConfig() {
741741
}
742742

743743
get targets() {
744-
console.log("Targets")
745744
const item = this.activity;
746745
const validTargets = ["creature", "ally", "enemy"];
747746
const actionType = item.actionType;
@@ -775,7 +774,7 @@ export function initConfig() {
775774

776775
async _onLeftClick(event) {
777776
ui.ARGON.interceptNextDialog(event.currentTarget);
778-
const used = await this.item.use({event, legacy: false}, {event});
777+
const used = await this.item.use({ event, legacy: false }, { event });
779778
if (used) {
780779
DND5eItemButton.consumeActionEconomy(this.activity);
781780
}
@@ -826,7 +825,7 @@ export function initConfig() {
826825
if (useAmmo) {
827826
const ammoItem = this.item.system.ammunitionOptions[0]?.item;
828827
if (!ammoItem) return null;
829-
return Math.floor((ammoItem.system.quantity ?? 0));
828+
return Math.floor(ammoItem.system.quantity ?? 0);
830829
} else if (consumeType === "attribute") {
831830
return Math.floor(getProperty(this.actor, this.activity.consume.target) / this.activity.consume.amount);
832831
} else if (consumeType === "charges") {
@@ -921,6 +920,33 @@ export function initConfig() {
921920
}
922921
this.items = this.items.filter((item) => !itemsToIgnore.includes(item));
923922
}
923+
const magicItemsSpells = this.items.filter((item) => item.flags.dnd5e?.cachedFor?.includes("Activity"));
924+
const magicItems = magicItemsSpells.map((item) => ({ spell: item, item: this.actor.items.get(item.flags.dnd5e.cachedFor.split(".Activity.")[0].replace(".Item.", "")) }));
925+
const magicItemsMap = new Map();
926+
magicItems.forEach((item) => {
927+
const current = magicItemsMap.get(item.item);
928+
if (current) {
929+
current.push(item.spell);
930+
} else {
931+
magicItemsMap.set(item.item, [item.spell]);
932+
}
933+
});
934+
for (const [item, spells] of magicItemsMap) {
935+
const requiresAttunement = item.system.attunement === "required";
936+
const isAttuned = item.system.attuned;
937+
itemsToIgnore.push(...spells);
938+
939+
if (requiresAttunement && !isAttuned) continue;
940+
941+
this.itemsWithSpells.push({
942+
label: item.name,
943+
buttons: spells.map((spell) => new DND5eItemButton({ item: spell })),
944+
uses: () => {
945+
return { max: item.system.uses?.max, value: item.system.uses?.value };
946+
},
947+
});
948+
}
949+
if (magicItems.length) this.items = this.items.filter((item) => !itemsToIgnore.includes(item));
924950
if (this.showPreparedOnly) {
925951
const allowIfNotPrepared = ["atwill", "innate", "pact", "always"];
926952
this.items = this.items.filter((item) => {

0 commit comments

Comments
 (0)