@@ -104,6 +104,7 @@ class EventManager {
104
104
105
105
return 0
106
106
} )
107
+ this . addAvailable ( category )
107
108
}
108
109
109
110
/**
@@ -342,46 +343,51 @@ class EventManager {
342
343
try {
343
344
const newMf = await generate ( true , historical , dbRarity )
344
345
this . masterfile = newMf ?? this . masterfile
345
- this . addAvailable ( )
346
+ this . addAllAvailable ( )
346
347
} catch ( e ) {
347
348
log . warn ( HELPERS . event , 'Failed to generate latest masterfile:\n' , e )
348
349
}
349
350
}
350
351
351
- addAvailable ( ) {
352
- Object . entries ( this . available ) . forEach ( ( [ c , entries ] ) => {
353
- const category = /** @type {keyof EventManager['available'] } */ ( c )
354
- entries . forEach ( ( item ) => {
355
- if ( ! Number . isNaN ( parseInt ( item . charAt ( 0 ) ) ) ) {
356
- const [ id , form ] = item . split ( '-' )
357
- if ( ! this . masterfile . pokemon [ id ] ) {
358
- this . masterfile . pokemon [ id ] = {
359
- name : '' ,
360
- pokedexId : + id ,
361
- types : [ ] ,
362
- quickMoves : [ ] ,
363
- chargedMoves : [ ] ,
364
- defaultFormId : + form ,
365
- forms : { } ,
366
- genId : 0 ,
367
- }
368
- log . warn ( HELPERS . event , `Added ${ id } to Pokemon, seems suspicious` )
369
- }
370
- if ( ! this . masterfile . pokemon [ id ] . forms ) {
371
- this . masterfile . pokemon [ id ] . forms = { }
372
- }
373
- if ( ! this . masterfile . pokemon [ id ] . forms [ form ] ) {
374
- this . masterfile . pokemon [ id ] . forms [ form ] = { name : '*' , category }
375
- log . info (
376
- HELPERS . event ,
377
- `Added ${ this . masterfile . pokemon [ id ] . name } Key: ${ item } to masterfile. (${ category } )` ,
378
- )
352
+ /** @param {keyof EventManager['available'] } category */
353
+ addAvailable ( category ) {
354
+ this . available [ category ] . forEach ( ( item ) => {
355
+ if ( ! Number . isNaN ( parseInt ( item . charAt ( 0 ) ) ) ) {
356
+ const [ id , form ] = item . split ( '-' )
357
+ if ( ! this . masterfile . pokemon [ id ] ) {
358
+ this . masterfile . pokemon [ id ] = {
359
+ name : '' ,
360
+ pokedexId : + id ,
361
+ types : [ ] ,
362
+ quickMoves : [ ] ,
363
+ chargedMoves : [ ] ,
364
+ defaultFormId : + form ,
365
+ forms : { } ,
366
+ genId : 0 ,
379
367
}
368
+ log . warn ( HELPERS . event , `Added ${ id } to Pokemon, seems suspicious` )
380
369
}
381
- } )
370
+ if ( ! this . masterfile . pokemon [ id ] . forms ) {
371
+ this . masterfile . pokemon [ id ] . forms = { }
372
+ }
373
+ if ( ! this . masterfile . pokemon [ id ] . forms [ form ] ) {
374
+ this . masterfile . pokemon [ id ] . forms [ form ] = { name : '*' , category }
375
+ log . info (
376
+ HELPERS . event ,
377
+ `Added ${ this . masterfile . pokemon [ id ] . name } Key: ${ item } to masterfile. (${ category } )` ,
378
+ )
379
+ }
380
+ }
382
381
} )
383
382
}
384
383
384
+ addAllAvailable ( ) {
385
+ Object . keys ( this . available ) . forEach (
386
+ ( /** @type {keyof EventManager['available'] } */ category ) =>
387
+ this . addAvailable ( category ) ,
388
+ )
389
+ }
390
+
385
391
async getWebhooks ( ) {
386
392
const apis = await Promise . allSettled (
387
393
config
0 commit comments