From a601e3bc77bb8764516db246cb2e70e10bc9c35f Mon Sep 17 00:00:00 2001 From: Sainan Date: Sun, 23 Feb 2025 14:44:20 +0100 Subject: [PATCH] chore: use PE+ for boosters --- package-lock.json | 8 ++++---- package.json | 2 +- src/services/purchaseService.ts | 26 +++++++------------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index a46ffbde..478f3d4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.4", - "warframe-public-export-plus": "^0.5.35", + "warframe-public-export-plus": "^0.5.36", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" @@ -4093,9 +4093,9 @@ } }, "node_modules/warframe-public-export-plus": { - "version": "0.5.35", - "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.35.tgz", - "integrity": "sha512-YLQP1n5sOV+PS5hfC4Kuoapa9gsqOy5Qy/E4EYfRV/xJBruFl3tPhbdbgFn3HhL2OBrgRJ8yzT5bjIvaHKhOCw==" + "version": "0.5.36", + "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.36.tgz", + "integrity": "sha512-FYZECqBSnynl6lQvcQyEqpnGW9l84wzusekhtwKjvg3280CYdn7g5x0Q9tOMhj1jpc/1tuY+akHtHa94sPtqKw==" }, "node_modules/warframe-riven-info": { "version": "0.1.2", diff --git a/package.json b/package.json index 64eb538f..d3446687 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.4", - "warframe-public-export-plus": "^0.5.35", + "warframe-public-export-plus": "^0.5.36", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 7b59ab52..a24c725c 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -16,8 +16,10 @@ import { logger } from "@/src/utils/logger"; import worldState from "@/static/fixed_responses/worldState/worldState.json"; import { ExportBoosterPacks, + ExportBoosters, ExportBundles, ExportGear, + ExportMisc, ExportResources, ExportSyndicates, ExportVendors, @@ -247,7 +249,7 @@ export const handleStoreItemAcquisition = async ( purchaseResponse = await handleTypesPurchase(internalName, inventory, quantity); break; case "Boosters": - purchaseResponse = handleBoostersPurchase(internalName, inventory, durability); + purchaseResponse = handleBoostersPurchase(storeItemName, inventory, durability); break; } } @@ -367,32 +369,18 @@ const handleTypesPurchase = async ( } }; -const boosterCollection = [ - "/Lotus/Types/Boosters/ResourceAmountBooster", - "/Lotus/Types/Boosters/AffinityBooster", - "/Lotus/Types/Boosters/ResourceDropChanceBooster", - "/Lotus/Types/Boosters/CreditBooster" -]; - -const boosterDuration: Record = { - COMMON: 3 * 86400, - UNCOMMON: 7 * 86400, - RARE: 30 * 86400, - LEGENDARY: 90 * 86400 -}; - const handleBoostersPurchase = ( boosterStoreName: string, inventory: TInventoryDatabaseDocument, durability: TRarity ): { InventoryChanges: IInventoryChanges } => { - const ItemType = boosterStoreName.replace("StoreItem", ""); - if (!boosterCollection.find(x => x == ItemType)) { - logger.error(`unknown booster type: ${ItemType}`); + if (!(boosterStoreName in ExportBoosters)) { + logger.error(`unknown booster type: ${boosterStoreName}`); return { InventoryChanges: {} }; } - const ExpiryDate = boosterDuration[durability]; + const ItemType = ExportBoosters[boosterStoreName].typeName; + const ExpiryDate = ExportMisc.boosterDurations[durability]; addBooster(ItemType, ExpiryDate, inventory);