@@ -73,24 +73,14 @@ export async function loadGameConfigurations(): Promise<void> {
7373
7474/**
7575 * find all items in all select groups
76- * @param groupKey string or array of string of which to find items connected with
76+ * @param groupKeys array of string of which to find items connected with
7777 * @return itemsKeys array of itemkeys in all select groups
7878 */
79- export const findItemTagsInGroup = ( groupKey : string | string [ ] ) : string [ ] => {
80- if ( ! groupKey ) {
81- return [ ] ;
82- }
83-
84- if ( Array . isArray ( groupKey ) ) {
85- const collection : Record < string , boolean > = { }
86- groupKey . forEach ( ( currentGroup ) => {
87- const items = findItemTagsInGroup ( currentGroup ) ;
88- items . forEach ( ( item ) => collection [ item ] = true )
89- } )
90- return Object . keys ( collection )
91- }
92-
93- return Object . keys ( itemGroupMap [ groupKey ] || { } )
79+ export const findItemTagsInGroups = ( groupKeys : string [ ] ) : string [ ] => {
80+ return Object . keys ( groupKeys . reduce < Record < string , boolean > > ( ( all , groupKey ) => {
81+ const items = itemGroupMap [ groupKey ] || { } ;
82+ return { ...all , ...items } ;
83+ } , { } ) ) ;
9484}
9585
9686
@@ -103,7 +93,7 @@ export const findItemTagsInGroupFilter = (groupKeys: string[]): string[] => {
10393 if ( ! groupKeys || groupKeys . length === 0 ) {
10494 return [ ] ;
10595 }
106- let collection : Record < string , boolean > | undefined = undefined
96+ let collection : Record < string , boolean > | undefined = undefined ;
10797 groupKeys . forEach ( ( groupKey ) => {
10898 if ( ! collection ) {
10999 collection = { ...( itemGroupMap [ groupKey ] || { } ) } ;
@@ -115,10 +105,10 @@ export const findItemTagsInGroupFilter = (groupKeys: string[]): string[] => {
115105 if ( ! ( existingItemKey in current ) ) {
116106 delete collection [ existingItemKey ] ;
117107 }
118- } )
119- } )
108+ } ) ;
109+ } ) ;
120110
121- return Object . keys ( collection )
111+ return Object . keys ( collection ) ;
122112}
123113
124114
0 commit comments