From 7a295a86ec4fb8919d60489b6a2664623f5496b1 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:00:06 -0700 Subject: [PATCH] fix: handle boosters in store item utilities (#1894) e.g. `/Lotus/Types/StoreItems/Boosters/AffinityBoosterStoreItem` Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1894 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/services/itemDataService.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/services/itemDataService.ts b/src/services/itemDataService.ts index 6e0edd23..3b3e997c 100644 --- a/src/services/itemDataService.ts +++ b/src/services/itemDataService.ts @@ -17,6 +17,7 @@ import { dict_uk, dict_zh, ExportArcanes, + ExportBoosters, ExportCustoms, ExportDrones, ExportGear, @@ -217,15 +218,30 @@ export const convertInboxMessage = (message: IInboxMessage): IMessage => { }; 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 => { + 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); }; 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 => {