diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 508cb736..d042afe5 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -5,12 +5,15 @@ import { addBooster, addCustomization, addMechSuit, + addMiscItems, addPowerSuit, addSentinel, addWeapon, + getInventory, updateCurrency, updateSlots } from "@/src/services/inventoryService"; +import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes"; import { IPurchaseRequest, IPurchaseResponse, SlotNameToInventoryName, SlotPurchase } from "@/src/types/purchaseTypes"; import { logger } from "@/src/utils/logger"; @@ -179,6 +182,8 @@ const handleTypesPurchase = async (typesName: string, accountId: string) => { return await handleSentinelPurchase(typesName, accountId); case "SlotItems": return await handleSlotPurchase(typesName, accountId); + case "Items": + return await handleMiscItemPurchase(typesName, accountId); default: throw new Error(`unknown Types category: ${typeCategory} not implemented or new`); } @@ -232,3 +237,20 @@ const handleBoostersPurchase = async (boosterStoreName: string, accountId: strin } }; }; + +const handleMiscItemPurchase = async (uniqueName: string, accountId: string) => { + const inventory = await getInventory(accountId); + const miscItemChanges = [ + { + ItemType: uniqueName, + ItemCount: 1 + } satisfies IMiscItem + ]; + addMiscItems(inventory, miscItemChanges); + await inventory.save(); + return { + InventoryChanges: { + MiscItems: miscItemChanges + } + }; +};