@@ -789,6 +789,26 @@ export function initConfig() {
789
789
async _getPanel ( ) {
790
790
if ( this . type === "spell" ) {
791
791
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
+ }
792
812
if ( this . showPreparedOnly ) {
793
813
const allowIfNotPrepared = [ "atwill" , "innate" , "pact" , "always" ] ;
794
814
this . items = this . items . filter ( ( item ) => {
@@ -797,7 +817,9 @@ export function initConfig() {
797
817
return item . system . preparation . prepared ;
798
818
} ) ;
799
819
}
820
+
800
821
const spells = [
822
+ ...itemsWithSpells ,
801
823
{
802
824
label : "DND5E.SpellPrepAtWill" ,
803
825
buttons : this . items . filter ( ( item ) => item . system . preparation . mode === "atwill" ) . map ( ( item ) => new DND5eItemButton ( { item } ) ) ,
@@ -816,7 +838,7 @@ export function initConfig() {
816
838
{
817
839
label : "DND5E.PactMagic" ,
818
840
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 }
820
842
} ,
821
843
] ;
822
844
for ( const [ level , label ] of Object . entries ( spellLevels ) ) {
@@ -825,7 +847,7 @@ export function initConfig() {
825
847
spells . push ( {
826
848
label,
827
849
buttons : levelSpells . map ( ( item ) => new DND5eItemButton ( { item } ) ) ,
828
- uses : this . actor . system . spells [ `spell${ level } ` ] ,
850
+ uses : ( ) => { return this . actor . system . spells [ `spell${ level } ` ] } ,
829
851
} ) ;
830
852
}
831
853
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