Skip to content

Commit 4d703c3

Browse files
committed
a
1 parent a0ee9dc commit 4d703c3

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
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

+24-2
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,26 @@ export function initConfig() {
789789
async _getPanel() {
790790
if (this.type === "spell") {
791791
const spellLevels = CONFIG.DND5E.spellLevels;
792+
const itemsWithSpells = [];
793+
const itemsToIgnore = [];
794+
if (game.modules.get("items-with-spells-5e")?.active) {
795+
const actionType = this.items[0].system.activation?.type;
796+
console.log("items-with-spells-5e");
797+
const spellItems = this.actor.items.filter((item) => item.flags["items-with-spells-5e"]?.["item-spells"]?.length);
798+
for (const item of spellItems) {
799+
const spellData = item.flags["items-with-spells-5e"]["item-spells"];
800+
const itemsInSpell = spellData.map((spell) => this.actor.items.get(spell.id)).filter((item) => item && item.system.activation?.type === actionType);
801+
if(!itemsInSpell.length) continue;
802+
itemsToIgnore.push(...itemsInSpell);
803+
if(item.system.attunement === 1) continue;
804+
itemsWithSpells.push({
805+
label: item.name,
806+
buttons: itemsInSpell.map((item) => new DND5eItemButton({ item })),
807+
uses: () => {return { max: item.system.uses?.max, value: item.system.uses?.value }},
808+
});
809+
}
810+
this.items = this.items.filter((item) => !itemsToIgnore.includes(item));
811+
}
792812
if (this.showPreparedOnly) {
793813
const allowIfNotPrepared = ["atwill", "innate", "pact", "always"];
794814
this.items = this.items.filter((item) => {
@@ -797,7 +817,9 @@ export function initConfig() {
797817
return item.system.preparation.prepared;
798818
});
799819
}
820+
800821
const spells = [
822+
...itemsWithSpells,
801823
{
802824
label: "DND5E.SpellPrepAtWill",
803825
buttons: this.items.filter((item) => item.system.preparation.mode === "atwill").map((item) => new DND5eItemButton({ item })),
@@ -816,7 +838,7 @@ export function initConfig() {
816838
{
817839
label: "DND5E.PactMagic",
818840
buttons: this.items.filter((item) => item.system.preparation.mode === "pact").map((item) => new DND5eItemButton({ item })),
819-
uses: this.actor.system.spells.pact,
841+
uses: () => { return this.actor.system.spells.pact }
820842
},
821843
];
822844
for (const [level, label] of Object.entries(spellLevels)) {
@@ -825,7 +847,7 @@ export function initConfig() {
825847
spells.push({
826848
label,
827849
buttons: levelSpells.map((item) => new DND5eItemButton({ item })),
828-
uses: this.actor.system.spells[`spell${level}`],
850+
uses: () => { return this.actor.system.spells[`spell${level}`] },
829851
});
830852
}
831853
return new ARGON.MAIN.BUTTON_PANELS.ACCORDION.AccordionPanel({ id: this.id, accordionPanelCategories: spells.filter((spell) => spell.buttons.length).map(({ label, buttons, uses }) => new ARGON.MAIN.BUTTON_PANELS.ACCORDION.AccordionPanelCategory({ label, buttons, uses })) });

0 commit comments

Comments
 (0)