Skip to content

Commit

Permalink
Sync spontaneous spell slot usage between actions
Browse files Browse the repository at this point in the history
  • Loading branch information
KitCat420 committed Mar 27, 2024
1 parent f5fbea6 commit 9ff282f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Remove disabled spellbooks that contain spells from action bar
- Remove spells button from showing up in action section, if no spells are available for that section
- Fix subskills not being rollable from drawer panel
- Sync spontaneous spell slot usage between actions

## v0.9.2
- Simplify spell selection if only one spellbook is active
Expand Down
11 changes: 7 additions & 4 deletions modules/argon/buttons/buttonPanelButton.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ export function spellbookButtonPanelActionButton(ARGON) {
max: (level && hasSpellUses) ? spellLevelInfo.max : null,
value: (level && hasSpellUses) ? spellLevelInfo.value : null
},
buttons: spells.filter(item => item.system.level === level)
buttons: spells.filter(item => item.system.level === level),
spellLevel: level,
spellbookId: this.spellbookId,
isSpellCategory: true
});
}

Expand Down Expand Up @@ -324,9 +327,9 @@ export function spellbookButtonPanelActionButton(ARGON) {
return new AccordionPanel({
accordionPanelCategories: this.categories
.map(category => new AccordionPanelCategory({
label: category.label,
uses: category.uses,
buttons: category.buttons.map(item => new ItemButton({item}))
...category,
buttons: category.buttons.map(item => new ItemButton({item})),
isSpellCategory: true
}))
});
}
Expand Down
2 changes: 1 addition & 1 deletion modules/argon/buttons/itemButton.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export function itemButton(ARGON) {
}

if (this.parent.isAccordionPanelCategory) {
this.parent.use();
Hooks.callAll("ECHPF1.spellUsed", this.item);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions modules/argon/panels/accordionPanel.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
let spellAccordionPanelCategories = {
"primary": {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: []},
"secondary": {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: []},
"tertiary": {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: []},
"spelllike": {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: []},
}
Hooks.on("ECHPF1.spellUsed", (item) => {
const categories = spellAccordionPanelCategories[item.system.spellbook][item.system.level];
categories.map(category => {
category.use();
})
});


export function accordionPanel(ARGON) {
return class Pathfinder1eAccordionPanel extends ARGON.MAIN.BUTTON_PANELS.ACCORDION.AccordionPanel {
get actionType() {
Expand Down Expand Up @@ -31,6 +45,10 @@ export function accordionPanelCategory(ARGON) {
constructor(args) {
super(args);
this.isAccordionPanelCategory = true;

if (args.isSpellCategory) {
spellAccordionPanelCategories[args.spellbookId][args.spellLevel].push(this);
}
}

get isUnchained() {
Expand Down

0 comments on commit 9ff282f

Please sign in to comment.