From 6135fdcdb97f095c7ae226556fe320c5f06a5b4e Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Mar 2025 05:36:36 -0700 Subject: [PATCH] fix: remove credits & ducats for purchases from baro (#1232) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1232 --- src/services/purchaseService.ts | 23 +++++++++++++++++++++++ src/types/purchaseTypes.ts | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 5b3656c4..d2985f1d 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -134,6 +134,29 @@ export const handlePurchase = async ( }; switch (purchaseRequest.PurchaseParams.Source) { + case 1: { + if (purchaseRequest.PurchaseParams.SourceId! != worldState.VoidTraders[0]._id.$oid) { + throw new Error("invalid request source"); + } + const offer = worldState.VoidTraders[0].Manifest.find( + x => x.ItemType == purchaseRequest.PurchaseParams.StoreItem + ); + if (offer) { + combineInventoryChanges( + purchaseResponse.InventoryChanges, + updateCurrency(inventory, offer.RegularPrice, false) + ); + + const invItem: IMiscItem = { + ItemType: "/Lotus/Types/Items/MiscItems/PrimeBucks", + ItemCount: offer.PrimePrice * purchaseRequest.PurchaseParams.Quantity * -1 + }; + addMiscItems(inventory, [invItem]); + purchaseResponse.InventoryChanges.MiscItems ??= []; + purchaseResponse.InventoryChanges.MiscItems.push(invItem); + } + break; + } case 2: { const syndicateTag = purchaseRequest.PurchaseParams.SyndicateTag!; diff --git a/src/types/purchaseTypes.ts b/src/types/purchaseTypes.ts index d14f39f5..862bc095 100644 --- a/src/types/purchaseTypes.ts +++ b/src/types/purchaseTypes.ts @@ -14,7 +14,7 @@ export interface IPurchaseRequest { export interface IPurchaseParams { Source: number; - SourceId?: string; // for Source 7 & 18 + SourceId?: string; // for Source 1, 7 & 18 StoreItem: string; StorePage: string; SearchTerm: string;