fix: tell client of PrimeTokens inventory change when buying from varzia (#1243)

Reviewed-on: OpenWF/SpaceNinjaServer#1243
This commit is contained in:
Sainan 2025-03-20 10:08:00 -07:00
parent 31ad97e215
commit b761ff1bff
2 changed files with 9 additions and 4 deletions

View File

@ -50,7 +50,7 @@ export const handlePurchase = async (
): Promise<IPurchaseResponse> => { ): Promise<IPurchaseResponse> => {
logger.debug("purchase request", purchaseRequest); logger.debug("purchase request", purchaseRequest);
const inventoryChanges: IInventoryChanges = {}; const prePurchaseInventoryChanges: IInventoryChanges = {};
if (purchaseRequest.PurchaseParams.Source == 7) { if (purchaseRequest.PurchaseParams.Source == 7) {
const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!); const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
if (manifest) { if (manifest) {
@ -65,7 +65,7 @@ export const handlePurchase = async (
inventory, inventory,
offer.ItemPrices, offer.ItemPrices,
purchaseRequest.PurchaseParams.Quantity, purchaseRequest.PurchaseParams.Quantity,
inventoryChanges prePurchaseInventoryChanges
); );
} }
if (!config.noVendorPurchaseLimits) { if (!config.noVendorPurchaseLimits) {
@ -94,7 +94,7 @@ export const handlePurchase = async (
Expiry: new Date(parseInt(offer.Expiry.$date.$numberLong)) Expiry: new Date(parseInt(offer.Expiry.$date.$numberLong))
}); });
} }
inventoryChanges.RecentVendorPurchases = [ prePurchaseInventoryChanges.RecentVendorPurchases = [
{ {
VendorType: manifest.VendorInfo.TypeName, VendorType: manifest.VendorInfo.TypeName,
PurchaseHistory: [ PurchaseHistory: [
@ -121,7 +121,7 @@ export const handlePurchase = async (
inventory, inventory,
purchaseRequest.PurchaseParams.Quantity purchaseRequest.PurchaseParams.Quantity
); );
combineInventoryChanges(purchaseResponse.InventoryChanges, inventoryChanges); combineInventoryChanges(purchaseResponse.InventoryChanges, prePurchaseInventoryChanges);
const currencyChanges = updateCurrency( const currencyChanges = updateCurrency(
inventory, inventory,
@ -240,6 +240,10 @@ export const handlePurchase = async (
purchaseResponse.InventoryChanges.MiscItems.push(invItem); purchaseResponse.InventoryChanges.MiscItems.push(invItem);
} else if (!config.infiniteRegalAya) { } else if (!config.infiniteRegalAya) {
inventory.PrimeTokens -= offer.PrimePrice! * purchaseRequest.PurchaseParams.Quantity; inventory.PrimeTokens -= offer.PrimePrice! * purchaseRequest.PurchaseParams.Quantity;
purchaseResponse.InventoryChanges.PrimeTokens ??= 0;
purchaseResponse.InventoryChanges.PrimeTokens -=
offer.PrimePrice! * purchaseRequest.PurchaseParams.Quantity;
} }
} }
break; break;

View File

@ -36,6 +36,7 @@ export type IInventoryChanges = {
RegularCredits?: number; RegularCredits?: number;
PremiumCredits?: number; PremiumCredits?: number;
PremiumCreditsFree?: number; PremiumCreditsFree?: number;
PrimeTokens?: number;
InfestedFoundry?: IInfestedFoundryClient; InfestedFoundry?: IInfestedFoundryClient;
Drones?: IDroneClient[]; Drones?: IDroneClient[];
MiscItems?: IMiscItem[]; MiscItems?: IMiscItem[];