@@ -23,6 +23,7 @@ import {
2323 RARITY_COLORS ,
2424 HOTM ,
2525 TYPE_TO_CATEGORIES ,
26+ ENCHANTMENTS_TO_CATEGORIES ,
2627 PET_DATA ,
2728 PET_RARITY_OFFSET ,
2829 PET_LEVELS ,
@@ -915,7 +916,7 @@ export function convertHMS(seconds, format = "clock", alwaysTwoDigits = false) {
915916 }
916917}
917918
918- export function parseItemTypeFromLore ( lore ) {
919+ export function parseItemTypeFromLore ( lore , item ) {
919920 const regex = new RegExp (
920921 `^(?<recomb>a )?(?<shiny>SHINY )?(?:(?<rarity>${ RARITIES . map ( ( x ) => x . replaceAll ( "_" , " " ) . toUpperCase ( ) ) . join (
921922 "|"
@@ -947,7 +948,7 @@ export function parseItemTypeFromLore(lore) {
947948 // Parsing the match and returning data
948949 const r = match . groups ;
949950 return {
950- categories : r . type ? getCategoriesFromType ( r . type . trim ( ) . toLowerCase ( ) ) : [ ] ,
951+ categories : r . type ? getCategories ( r . type . trim ( ) . toLowerCase ( ) , item ) : [ ] ,
951952 rarity : r . rarity . replaceAll ( " " , "_" ) . toLowerCase ( ) ,
952953 recombobulated : ! ! r . recomb && ! ! r . recomb2 ,
953954 dungeon : ! ! r . dungeon ,
@@ -997,8 +998,17 @@ export function getCacheFilePath(dirPath, type, name, format = "png") {
997998 return path . resolve ( dirPath , `${ subdirs . join ( "/" ) } /${ type } _${ name } .${ format } ` ) ;
998999}
9991000
1000- function getCategoriesFromType ( type ) {
1001- return TYPE_TO_CATEGORIES [ type ] ?? [ "unknown" ] ;
1001+ function getCategories ( type , item ) {
1002+ const categories = [ ] ;
1003+
1004+ const enchantments = item ?. tag ?. ExtraAttributes ?. enchantments || { } ;
1005+ Object . keys ( enchantments ) . forEach ( ( enchantment ) =>
1006+ Object . entries ( ENCHANTMENTS_TO_CATEGORIES ) . forEach (
1007+ ( [ category , enchantmentList ] ) => enchantmentList . includes ( enchantment ) && categories . push ( category )
1008+ )
1009+ ) ;
1010+
1011+ return [ ...new Set ( categories . concat ( TYPE_TO_CATEGORIES [ type ] ) ) ] ;
10021012}
10031013
10041014export function generateDebugPets ( type = "ALL" ) {
0 commit comments