@@ -170,7 +170,7 @@ class ItemsAPI extends WorkerKV {
170
170
if ( ! items ) {
171
171
items = Object . values ( cache . Item ) ;
172
172
}
173
- const categories = ( await this . getCategories ( context , info ) ) . filter ( cat => names . includes ( cat . enumName ) ) ;
173
+ const categories = ( await context . data . worker . handbook . getCategories ( context , info ) ) . filter ( cat => names . includes ( cat . enumName ) ) ;
174
174
return items . filter ( ( item ) => {
175
175
return item . categories . some ( catId => categories . some ( cat => cat . id === catId ) ) ;
176
176
} ) ;
@@ -181,7 +181,7 @@ class ItemsAPI extends WorkerKV {
181
181
if ( ! items ) {
182
182
items = Object . values ( cache . Item ) ;
183
183
}
184
- const categories = ( await this . getHandbookCategories ( context , info ) ) . filter ( cat => names . includes ( cat . enumName ) ) ;
184
+ const categories = ( await context . data . worker . handbook . getHandbookCategories ( context , info ) ) . filter ( cat => names . includes ( cat . enumName ) ) ;
185
185
return items . filter ( ( item ) => {
186
186
return item . handbookCategories . some ( catId => categories . some ( cat => cat . id === catId ) ) ;
187
187
} ) ;
@@ -216,108 +216,24 @@ class ItemsAPI extends WorkerKV {
216
216
} ) ;
217
217
}
218
218
219
- async getCategory ( context , info , id ) {
220
- const { cache } = await this . getCache ( context , info ) ;
221
- return cache . ItemCategory [ id ] || cache . HandbookCategory [ id ] ;
222
- }
223
-
224
- async getTopCategory ( context , info , id ) {
225
- const cat = await this . getCategory ( context , info , id ) ;
226
- if ( cat && cat . parent_id ) return this . getTopCategory ( context , info , cat . parent_id ) ;
227
- return cat ;
228
- }
229
-
230
- async getCategories ( context , info ) {
231
- const { cache } = await this . getCache ( context , info ) ;
232
- if ( ! cache ) {
233
- return Promise . reject ( new Error ( 'Item cache is empty' ) ) ;
234
- }
235
- const categories = [ ] ;
236
- for ( const id in cache . ItemCategory ) {
237
- categories . push ( cache . ItemCategory [ id ] ) ;
238
- }
239
- return categories ;
240
- }
241
-
242
- async getCategoriesEnum ( context , info ) {
243
- const cats = await this . getCategories ( context , info ) ;
244
- const map = { } ;
245
- for ( const id in cats ) {
246
- map [ cats [ id ] . enumName ] = cats [ id ] ;
247
- }
248
- return map ;
249
- }
250
-
251
- async getHandbookCategory ( context , info , id ) {
252
- const { cache } = await this . getCache ( context , info ) ;
253
- return cache . HandbookCategory [ id ] ;
254
- }
255
-
256
- async getHandbookCategories ( context , info ) {
257
- const { cache } = await this . getCache ( context , info ) ;
258
- if ( ! cache ) {
259
- return Promise . reject ( new Error ( 'Item cache is empty' ) ) ;
260
- }
261
- return Object . values ( cache . HandbookCategory ) ;
262
- }
263
-
264
219
async getFleaMarket ( context , info ) {
265
220
const { cache } = await this . getCache ( context , info ) ;
266
221
return cache . FleaMarket ;
267
222
}
268
223
269
- async getArmorMaterials ( context , info ) {
270
- const { cache } = await this . getCache ( context , info ) ;
271
- return Object . values ( cache . ArmorMaterial ) . sort ( ) ;
272
- }
273
-
274
- async getArmorMaterial ( context , info , matKey ) {
275
- const { cache } = await this . getCache ( context , info ) ;
276
- return cache . ArmorMaterial [ matKey ] ;
277
- }
278
-
279
- async getMasterings ( context , info ) {
280
- const { cache } = await this . getCache ( context , info ) ;
281
- return cache . Mastering ;
282
- }
283
-
284
- async getMastering ( context , info , mastId ) {
285
- const { cache } = await this . getCache ( context , info ) ;
286
- return cache . Mastering . find ( m => m . id === mastId ) ;
287
- }
288
-
289
- async getSkills ( context , info ) {
290
- const { cache } = await this . getCache ( context , info ) ;
291
- return cache . Skill ;
292
- }
293
-
294
- async getSkill ( context , info , skillId ) {
295
- const { cache } = await this . getCache ( context , info ) ;
296
- return cache . Skill . find ( s => s . id === skillId ) ;
297
- }
298
-
299
224
async getAmmoList ( context , info ) {
300
225
const allAmmo = await this . getItemsByBsgCategoryId ( context , info , '5485a8684bdc2da71d8b4567' ) . then ( ammoItems => {
301
226
// ignore bb
302
227
return ammoItems . filter ( item => item . id !== '6241c316234b593b5676b637' ) ;
303
228
} ) ;
229
+ const itemProperties = await context . data . worker . handbook . getAllItemProperties ( context , info ) ;
304
230
return allAmmo . map ( item => {
305
231
return {
306
232
...item ,
307
- ...item . properties
233
+ ...itemProperties [ item . id ] ,
308
234
} ;
309
235
} ) ;
310
236
}
311
-
312
- async getPlayerLevels ( context , info ) {
313
- const { cache } = await this . getCache ( context , info ) ;
314
- return cache . PlayerLevel ;
315
- }
316
-
317
- async getTypes ( context , info ) {
318
- const { cache } = await this . getCache ( context , info ) ;
319
- return cache . ItemType ;
320
- }
321
237
}
322
238
323
239
export default ItemsAPI ;
0 commit comments