diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 6bf45e42..728f6570 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -66,6 +66,18 @@ export const handlePurchase = async ( if (!offer) { throw new Error(`unknown vendor offer: ${ItemId ? ItemId : purchaseRequest.PurchaseParams.StoreItem}`); } + if (offer.RegularPrice) { + combineInventoryChanges( + prePurchaseInventoryChanges, + updateCurrency(inventory, offer.RegularPrice[0], false) + ); + } + if (offer.PremiumPrice) { + combineInventoryChanges( + prePurchaseInventoryChanges, + updateCurrency(inventory, offer.PremiumPrice[0], true) + ); + } if (offer.ItemPrices) { handleItemPrices( inventory, @@ -170,6 +182,9 @@ export const handlePurchase = async ( purchaseResponse.InventoryChanges, updateCurrency(inventory, offer.RegularPrice, false) ); + if (purchaseRequest.PurchaseParams.ExpectedPrice) { + throw new Error(`vendor purchase should not have an expected price`); + } const invItem: IMiscItem = { ItemType: "/Lotus/Types/Items/MiscItems/PrimeBucks", @@ -229,6 +244,12 @@ export const handlePurchase = async ( updateCurrency(inventory, offer.credits, false) ); } + if (typeof offer.platinum == "number") { + combineInventoryChanges( + purchaseResponse.InventoryChanges, + updateCurrency(inventory, offer.platinum, true) + ); + } if (offer.itemPrices) { handleItemPrices( inventory, @@ -239,6 +260,9 @@ export const handlePurchase = async ( } } } + if (purchaseRequest.PurchaseParams.ExpectedPrice) { + throw new Error(`vendor purchase should not have an expected price`); + } break; case 18: { if (purchaseRequest.PurchaseParams.SourceId! != worldState.PrimeVaultTraders[0]._id.$oid) { diff --git a/src/types/vendorTypes.ts b/src/types/vendorTypes.ts index 3699b965..2976ce07 100644 --- a/src/types/vendorTypes.ts +++ b/src/types/vendorTypes.ts @@ -10,6 +10,7 @@ export interface IItemManifest { StoreItem: string; ItemPrices?: IItemPrice[]; RegularPrice?: number[]; + PremiumPrice?: number[]; Bin: string; QuantityMultiplier: number; Expiry: IMongoDate; // Either a date in the distant future or a period in milliseconds for preprocessing.