@@ -8,7 +8,7 @@ export function initConfig() {
8
8
registerItems ( ) ;
9
9
const ARGON = CoreHUD . ARGON ;
10
10
11
- class DND5eTooltip extends ARGON . CORE . Tooltip {
11
+ class DND5eTooltip extends ARGON . CORE . Tooltip {
12
12
get classes ( ) {
13
13
const original = super . classes ;
14
14
return original . concat ( [ "dnd5e2" ] ) ;
@@ -371,15 +371,15 @@ export function initConfig() {
371
371
[
372
372
{
373
373
label : CONFIG . DND5E . abilities [ ability ] . label ,
374
- onClick : ( event ) => this . actor . rollAbilityCheck ( { ability, event} ) ,
374
+ onClick : ( event ) => this . actor . rollAbilityCheck ( { ability, event } ) ,
375
375
} ,
376
376
{
377
377
label : addSign ( abilityData . mod + ( abilityData . checkBonus || 0 ) ) ,
378
- onClick : ( event ) => this . actor . rollAbilityCheck ( { ability, event} ) ,
378
+ onClick : ( event ) => this . actor . rollAbilityCheck ( { ability, event } ) ,
379
379
} ,
380
380
{
381
381
label : addSign ( abilityData . save ) ,
382
- onClick : ( event ) => this . actor . rollSavingThrow ( { ability, event } ) ,
382
+ onClick : ( event ) => this . actor . rollSavingThrow ( { ability, event } ) ,
383
383
} ,
384
384
] ,
385
385
ability ,
@@ -393,7 +393,7 @@ export function initConfig() {
393
393
[
394
394
{
395
395
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 } ) ,
397
397
} ,
398
398
{
399
399
label : `${ addSign ( skillData . total ) } <span style="margin: 0 1rem; filter: brightness(0.8)">(${ skillData . passive } )</span>` ,
@@ -741,7 +741,6 @@ export function initConfig() {
741
741
}
742
742
743
743
get targets ( ) {
744
- console . log ( "Targets" )
745
744
const item = this . activity ;
746
745
const validTargets = [ "creature" , "ally" , "enemy" ] ;
747
746
const actionType = item . actionType ;
@@ -775,7 +774,7 @@ export function initConfig() {
775
774
776
775
async _onLeftClick ( event ) {
777
776
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 } ) ;
779
778
if ( used ) {
780
779
DND5eItemButton . consumeActionEconomy ( this . activity ) ;
781
780
}
@@ -826,7 +825,7 @@ export function initConfig() {
826
825
if ( useAmmo ) {
827
826
const ammoItem = this . item . system . ammunitionOptions [ 0 ] ?. item ;
828
827
if ( ! ammoItem ) return null ;
829
- return Math . floor ( ( ammoItem . system . quantity ?? 0 ) ) ;
828
+ return Math . floor ( ammoItem . system . quantity ?? 0 ) ;
830
829
} else if ( consumeType === "attribute" ) {
831
830
return Math . floor ( getProperty ( this . actor , this . activity . consume . target ) / this . activity . consume . amount ) ;
832
831
} else if ( consumeType === "charges" ) {
@@ -921,6 +920,33 @@ export function initConfig() {
921
920
}
922
921
this . items = this . items . filter ( ( item ) => ! itemsToIgnore . includes ( item ) ) ;
923
922
}
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 ) ) ;
924
950
if ( this . showPreparedOnly ) {
925
951
const allowIfNotPrepared = [ "atwill" , "innate" , "pact" , "always" ] ;
926
952
this . items = this . items . filter ( ( item ) => {
0 commit comments