From e1af6bd598feeeffb8234319ca5ed37ba7213abb Mon Sep 17 00:00:00 2001 From: nrbdev Date: Sun, 23 Feb 2025 03:53:56 -0800 Subject: [PATCH] feat: implement CreditBundle purchases (#989) This fixes purchasing one of the few bundles that include these credit bundles. Ex: Essential Damage mod bundles Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/989 Co-authored-by: nrbdev Co-committed-by: nrbdev --- src/services/missionInventoryUpdateService.ts | 4 +++- src/services/purchaseService.ts | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/services/missionInventoryUpdateService.ts b/src/services/missionInventoryUpdateService.ts index 766518e2..d579662f 100644 --- a/src/services/missionInventoryUpdateService.ts +++ b/src/services/missionInventoryUpdateService.ts @@ -62,7 +62,9 @@ export const creditBundles: Record = { "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardTwoHard": 175000, "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardThreeHard": 250000, "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsCommon": 15000, - "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsUncommon": 30000 + "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsUncommon": 30000, + "/Lotus/Types/StoreItems/CreditBundles/CreditBundleA": 50000, + "/Lotus/Types/StoreItems/CreditBundles/CreditBundleC": 175000 }; export const fusionBundles: Record = { diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index bc2ef924..7b59ab52 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -25,6 +25,7 @@ import { } from "warframe-public-export-plus"; import { config } from "./configService"; import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel"; +import { creditBundles } from "./missionInventoryUpdateService"; export const getStoreItemCategory = (storeItem: string): string => { const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/"); @@ -330,6 +331,22 @@ const handleBoosterPackPurchase = async ( return purchaseResponse; }; +const handleCreditBundlePurchase = async ( + typeName: string, + inventory: TInventoryDatabaseDocument +): Promise => { + if (typeName && typeName in creditBundles) { + const creditsAmount = creditBundles[typeName]; + + inventory.RegularCredits += creditsAmount; + await inventory.save(); + + return { InventoryChanges: { RegularCredits: creditsAmount } }; + } else { + throw new Error(`unknown credit bundle: ${typeName}`); + } +}; + //TODO: change to getInventory, apply changes then save at the end const handleTypesPurchase = async ( typesName: string, @@ -345,6 +362,8 @@ const handleTypesPurchase = async ( return handleBoosterPackPurchase(typesName, inventory, quantity); case "SlotItems": return handleSlotPurchase(typesName, inventory, quantity); + case "CreditBundles": + return handleCreditBundlePurchase(typesName, inventory); } };