fix: tell client of PrimeTokens inventory change when buying from varzia #1243
@ -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;
 | 
				
			||||||
 | 
				
			|||||||
@ -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[];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user