fix: handle boosters in store item utilities (#1894)
e.g. `/Lotus/Types/StoreItems/Boosters/AffinityBoosterStoreItem` Reviewed-on: #1894 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									88d00eaaa1
								
							
						
					
					
						commit
						7a295a86ec
					
				@ -17,6 +17,7 @@ import {
 | 
				
			|||||||
    dict_uk,
 | 
					    dict_uk,
 | 
				
			||||||
    dict_zh,
 | 
					    dict_zh,
 | 
				
			||||||
    ExportArcanes,
 | 
					    ExportArcanes,
 | 
				
			||||||
 | 
					    ExportBoosters,
 | 
				
			||||||
    ExportCustoms,
 | 
					    ExportCustoms,
 | 
				
			||||||
    ExportDrones,
 | 
					    ExportDrones,
 | 
				
			||||||
    ExportGear,
 | 
					    ExportGear,
 | 
				
			||||||
@ -217,15 +218,30 @@ export const convertInboxMessage = (message: IInboxMessage): IMessage => {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const isStoreItem = (type: string): boolean => {
 | 
					export const isStoreItem = (type: string): boolean => {
 | 
				
			||||||
    return type.startsWith("/Lotus/StoreItems/");
 | 
					    return type.startsWith("/Lotus/StoreItems/") || type in ExportBoosters;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const toStoreItem = (type: string): string => {
 | 
					export const toStoreItem = (type: string): string => {
 | 
				
			||||||
 | 
					    if (type.startsWith("/Lotus/Types/StoreItems/Boosters/")) {
 | 
				
			||||||
 | 
					        const boosterEntry = Object.entries(ExportBoosters).find(arr => arr[1].typeName == type);
 | 
				
			||||||
 | 
					        if (boosterEntry) {
 | 
				
			||||||
 | 
					            return boosterEntry[0];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        throw new Error(`could not convert ${type} to a store item`);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    return "/Lotus/StoreItems/" + type.substring("/Lotus/".length);
 | 
					    return "/Lotus/StoreItems/" + type.substring("/Lotus/".length);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const fromStoreItem = (type: string): string => {
 | 
					export const fromStoreItem = (type: string): string => {
 | 
				
			||||||
    return "/Lotus/" + type.substring("/Lotus/StoreItems/".length);
 | 
					    if (type.startsWith("/Lotus/StoreItems/")) {
 | 
				
			||||||
 | 
					        return "/Lotus/" + type.substring("/Lotus/StoreItems/".length);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (type in ExportBoosters) {
 | 
				
			||||||
 | 
					        return ExportBoosters[type].typeName;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    throw new Error(`${type} is not a store item`);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getDefaultUpgrades = (parts: string[]): IDefaultUpgrade[] | undefined => {
 | 
					export const getDefaultUpgrades = (parts: string[]): IDefaultUpgrade[] | undefined => {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user