@@ -120,21 +120,30 @@ Hooks.once("tokenActionHudCoreApiReady", async (coreModule) => {
120120 }
121121
122122 async #buildInventory( ) {
123- if ( this . items . size === 0 ) return ;
123+
124+ const invItems = this . actor . items . filter ( ( item ) => ( item . system . isGear || item . system . isEquipement ) && ! item . system . isArmor ) ;
125+
126+ if ( invItems . size === 0 ) {
127+ return ;
128+ }
124129
125130 const actionTypeId = "item" ;
126131 const inventoryMap = new Map ( ) ;
127132
128- for ( const [ itemId , itemData ] of this . items ) {
133+ for ( const itemData of invItems ) {
129134 let type = itemData . type ;
135+ const itemId = itemData . id ;
130136
131137 if (
132138 ( ( type === "weapon" || type === "equipment" ) && itemData . system ?. isActive ) ||
133139 ( ( type === "weapon" || type === "equipment" ) && this . displayUnequipped )
134140 ) {
141+ // For now - ignore this and add them separately once we have support for selecting the power to use
142+ /*
135143 if (itemData.system?.isArtifact || itemData.system?.isArtifact === "artifact") {
136144 type = "artifact";
137145 }
146+ */
138147 const typeMap = inventoryMap . get ( type ) ?? new Map ( ) ;
139148 typeMap . set ( itemId , itemData ) ;
140149 inventoryMap . set ( type , typeMap ) ;
@@ -185,20 +194,13 @@ Hooks.once("tokenActionHudCoreApiReady", async (coreModule) => {
185194 const name = this . actor . system . combat . name ;
186195 const img = this . actor . system . combat . img ;
187196 const encodedValue = [ actionTypeId , this . actor . system . combat . id ] . join ( this . delimiter ) ;
188- const typeMap = new Map ( ) ;
189- const itemData = duplicate ( this . actor . system . combat ) ;
190- itemData . type = type ;
191- typeMap . set ( itemId , itemData ) ;
192-
193- const actions = [ ...typeMap ] . map ( ( [ itemId , itemData ] ) => {
194- return {
197+ const actions = [ {
195198 itemId,
196199 name,
197200 img,
198201 listName,
199- encodedValue,
200- } ;
201- } ) ;
202+ encodedValue
203+ } ] ;
202204 this . addActions ( actions , groupData ) ;
203205 }
204206
@@ -207,22 +209,23 @@ Hooks.once("tokenActionHudCoreApiReady", async (coreModule) => {
207209 // Get traits
208210 const traits = this . actor . items . filter ( ( item ) => item . type === "trait" && item . system ?. hasScript ) ;
209211 // Exit if there are no traits with scripts
210- if ( traits . length === 0 ) return ;
212+
213+ if ( traits . length === 0 )
214+ {
215+ // Remove group Trait if there are not traits
216+ return ;
217+ }
211218
212219 // Get actions
213- const actions = Object . entries ( traits )
214- . map ( ( trait ) => {
220+ const actions = traits . map ( ( trait ) => {
215221 try {
216- const lookupId = trait [ 1 ] . name . toLowerCase ( ) . replace ( / \s / g, "" ) ;
217- const id = trait [ 1 ] . name ;
218- let name = `${ coreModule . api . Utils . i18n ( game . symbaroum . config . traitsList [ lookupId ] ) } ` ;
219- if ( name === "undefined" ) {
220- name = trait [ 1 ] . name ;
221- }
222+ const id = trait . id ;
223+ let name = trait . name ;
224+
222225 const actionTypeName = `${ coreModule . api . Utils . i18n ( ACTION_TYPE [ actionType ] ) } : ` ?? "" ;
223- const listName = `${ actionTypeName } ${ coreModule . api . Utils . i18n ( game . symbaroum . config . traitsList [ lookupId ] ) } ` ;
226+ const listName = `${ actionTypeName } ${ name } ` ;
224227 const encodedValue = [ actionType , id ] . join ( this . delimiter ) ;
225- const img = coreModule . api . Utils . getImage ( trait [ 1 ] . img ) ;
228+ const img = coreModule . api . Utils . getImage ( trait . img ) ;
226229
227230 return {
228231 id,
@@ -236,8 +239,7 @@ Hooks.once("tokenActionHudCoreApiReady", async (coreModule) => {
236239 coreModule . api . Logger . error ( trait ) ;
237240 return null ;
238241 }
239- } )
240- . filter ( ( trait ) => ! ! trait ) ;
242+ } ) ;
241243
242244 // Create group data
243245 const groupData = { id : "traits" , type : "system" } ;
@@ -249,25 +251,22 @@ Hooks.once("tokenActionHudCoreApiReady", async (coreModule) => {
249251 async #buildAbilities( ) {
250252 const actionType = "ability" ;
251253 // Get traits
252- const abilityList = this . actor . items . filter ( ( item ) => item . type === "ability" && item . system ?. script ) ;
254+ const abilities = this . actor . items . filter ( ( item ) => item . type === "ability" && item . system ?. script ) ;
253255
254- // Exit if there are no abilityList with scripts
255- if ( abilityList . length === 0 ) return ;
256+ // Exit if there are no abilities with scripts
257+ if ( abilities . length === 0 ) {
258+ return ;
259+ }
256260
257261 // Get actions
258- const actions = Object . entries ( abilityList )
259- . map ( ( ability ) => {
262+ const actions = abilities . map ( ( ability ) => {
260263 try {
261- const lookupId = ability [ 1 ] . name . toLowerCase ( ) . replace ( / \s / g, "" ) ;
262- const id = ability [ 1 ] . name ;
263- let name = `${ coreModule . api . Utils . i18n ( game . symbaroum . config . abilitiesList [ lookupId ] ) } ` ;
264- if ( name === "undefined" ) {
265- name = ability [ 1 ] . name ;
266- }
264+ const id = ability . id ;
265+ let name = ability . name ; // `${coreModule.api.Utils.i18n(game.symbaroum.config.abilitiesList[lookupId])}`;
267266 const actionTypeName = `${ coreModule . api . Utils . i18n ( ACTION_TYPE [ actionType ] ) } : ` ?? "" ;
268- const listName = `${ actionTypeName } ${ coreModule . api . Utils . i18n ( game . symbaroum . config . abilitiesList [ lookupId ] ) } ` ;
267+ const listName = `${ actionTypeName } ${ name } ` ;
269268 const encodedValue = [ actionType , id ] . join ( this . delimiter ) ;
270- const img = coreModule . api . Utils . getImage ( ability [ 1 ] . img ) ;
269+ const img = coreModule . api . Utils . getImage ( ability . img ) ;
271270 return {
272271 id,
273272 name,
@@ -280,8 +279,7 @@ Hooks.once("tokenActionHudCoreApiReady", async (coreModule) => {
280279 coreModule . api . Logger . error ( ability ) ;
281280 return null ;
282281 }
283- } )
284- . filter ( ( ability ) => ! ! ability ) ;
282+ } ) ;
285283
286284 // Create group data
287285 const groupData = { id : "abilities" , type : "system" } ;
@@ -295,22 +293,19 @@ Hooks.once("tokenActionHudCoreApiReady", async (coreModule) => {
295293 // Get traits
296294 let powers = this . actor . items . filter ( ( item ) => item . type === "mysticalPower" && item . system ?. hasScript ) ;
297295 // Exit if there are no abilities with scripts
298- if ( powers . length === 0 ) return ;
296+ if ( powers . length === 0 ) {
297+ return ;
298+ }
299299
300300 // Get actions
301- const actions = Object . entries ( powers )
302- . map ( ( power ) => {
301+ const actions = powers . map ( ( power ) => {
303302 try {
304- const lookupId = power [ 1 ] . name . toLowerCase ( ) . replace ( / \s / g, "" ) ;
305- const id = power [ 1 ] . name ;
306- let name = `${ coreModule . api . Utils . i18n ( game . symbaroum . config . powersList [ lookupId ] ) } ` ;
307- if ( name === "undefined" ) {
308- name = power [ 1 ] . name ;
309- }
303+ const id = power . id ;
304+ const name = power . name ;
310305 const actionTypeName = `${ coreModule . api . Utils . i18n ( ACTION_TYPE [ actionType ] ) } : ` ?? "" ;
311- const listName = `${ actionTypeName } ${ coreModule . api . Utils . i18n ( game . symbaroum . config . powersList [ lookupId ] ) } ` ;
306+ const listName = `${ actionTypeName } ${ power . name } ` ;
312307 const encodedValue = [ actionType , id ] . join ( this . delimiter ) ;
313- const img = coreModule . api . Utils . getImage ( power [ 1 ] . img ) ;
308+ const img = coreModule . api . Utils . getImage ( power . img ) ;
314309 return {
315310 id,
316311 name,
@@ -323,8 +318,7 @@ Hooks.once("tokenActionHudCoreApiReady", async (coreModule) => {
323318 coreModule . api . Logger . error ( power ) ;
324319 return null ;
325320 }
326- } )
327- . filter ( ( power ) => ! ! power ) ;
321+ } ) ;
328322
329323 // Create group data
330324 const groupData = { id : "mysticalpower" , type : "system" } ;
0 commit comments