chore: cleanup purchase stuff #2266
@ -75,18 +75,12 @@ export const handlePurchase = async (
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            if (!config.dontSubtractPurchaseCreditCost) {
 | 
					            if (!config.dontSubtractPurchaseCreditCost) {
 | 
				
			||||||
                if (offer.RegularPrice) {
 | 
					                if (offer.RegularPrice) {
 | 
				
			||||||
                    combineInventoryChanges(
 | 
					                    updateCurrency(inventory, offer.RegularPrice[0], false, prePurchaseInventoryChanges);
 | 
				
			||||||
                        prePurchaseInventoryChanges,
 | 
					 | 
				
			||||||
                        updateCurrency(inventory, offer.RegularPrice[0], false)
 | 
					 | 
				
			||||||
                    );
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (!config.dontSubtractPurchasePlatinumCost) {
 | 
					            if (!config.dontSubtractPurchasePlatinumCost) {
 | 
				
			||||||
                if (offer.PremiumPrice) {
 | 
					                if (offer.PremiumPrice) {
 | 
				
			||||||
                    combineInventoryChanges(
 | 
					                    updateCurrency(inventory, offer.PremiumPrice[0], true, prePurchaseInventoryChanges);
 | 
				
			||||||
                        prePurchaseInventoryChanges,
 | 
					 | 
				
			||||||
                        updateCurrency(inventory, offer.PremiumPrice[0], true)
 | 
					 | 
				
			||||||
                    );
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (!config.dontSubtractPurchaseItemCost) {
 | 
					            if (!config.dontSubtractPurchaseItemCost) {
 | 
				
			||||||
@ -172,15 +166,12 @@ export const handlePurchase = async (
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
    combineInventoryChanges(purchaseResponse.InventoryChanges, prePurchaseInventoryChanges);
 | 
					    combineInventoryChanges(purchaseResponse.InventoryChanges, prePurchaseInventoryChanges);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const currencyChanges = updateCurrency(
 | 
					    updateCurrency(
 | 
				
			||||||
        inventory,
 | 
					        inventory,
 | 
				
			||||||
        purchaseRequest.PurchaseParams.ExpectedPrice,
 | 
					        purchaseRequest.PurchaseParams.ExpectedPrice,
 | 
				
			||||||
        purchaseRequest.PurchaseParams.UsePremium
 | 
					        purchaseRequest.PurchaseParams.UsePremium,
 | 
				
			||||||
 | 
					        prePurchaseInventoryChanges
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    purchaseResponse.InventoryChanges = {
 | 
					 | 
				
			||||||
        ...currencyChanges,
 | 
					 | 
				
			||||||
        ...purchaseResponse.InventoryChanges
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (purchaseRequest.PurchaseParams.Source) {
 | 
					    switch (purchaseRequest.PurchaseParams.Source) {
 | 
				
			||||||
        case PurchaseSource.VoidTrader: {
 | 
					        case PurchaseSource.VoidTrader: {
 | 
				
			||||||
@ -192,10 +183,7 @@ export const handlePurchase = async (
 | 
				
			|||||||
            );
 | 
					            );
 | 
				
			||||||
            if (offer) {
 | 
					            if (offer) {
 | 
				
			||||||
                if (!config.dontSubtractPurchaseCreditCost) {
 | 
					                if (!config.dontSubtractPurchaseCreditCost) {
 | 
				
			||||||
                    combineInventoryChanges(
 | 
					                    updateCurrency(inventory, offer.RegularPrice, false, purchaseResponse.InventoryChanges);
 | 
				
			||||||
                        purchaseResponse.InventoryChanges,
 | 
					 | 
				
			||||||
                        updateCurrency(inventory, offer.RegularPrice, false)
 | 
					 | 
				
			||||||
                    );
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (purchaseRequest.PurchaseParams.ExpectedPrice) {
 | 
					                if (purchaseRequest.PurchaseParams.ExpectedPrice) {
 | 
				
			||||||
                    throw new Error(`vendor purchase should not have an expected price`);
 | 
					                    throw new Error(`vendor purchase should not have an expected price`);
 | 
				
			||||||
@ -256,16 +244,10 @@ export const handlePurchase = async (
 | 
				
			|||||||
                const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
 | 
					                const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
 | 
				
			||||||
                if (offer) {
 | 
					                if (offer) {
 | 
				
			||||||
                    if (typeof offer.credits == "number" && !config.dontSubtractPurchaseCreditCost) {
 | 
					                    if (typeof offer.credits == "number" && !config.dontSubtractPurchaseCreditCost) {
 | 
				
			||||||
                        combineInventoryChanges(
 | 
					                        updateCurrency(inventory, offer.credits, false, purchaseResponse.InventoryChanges);
 | 
				
			||||||
                            purchaseResponse.InventoryChanges,
 | 
					 | 
				
			||||||
                            updateCurrency(inventory, offer.credits, false)
 | 
					 | 
				
			||||||
                        );
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if (typeof offer.platinum == "number" && !config.dontSubtractPurchasePlatinumCost) {
 | 
					                    if (typeof offer.platinum == "number" && !config.dontSubtractPurchasePlatinumCost) {
 | 
				
			||||||
                        combineInventoryChanges(
 | 
					                        updateCurrency(inventory, offer.platinum, true, purchaseResponse.InventoryChanges);
 | 
				
			||||||
                            purchaseResponse.InventoryChanges,
 | 
					 | 
				
			||||||
                            updateCurrency(inventory, offer.platinum, true)
 | 
					 | 
				
			||||||
                        );
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if (offer.itemPrices && !config.dontSubtractPurchaseItemCost) {
 | 
					                    if (offer.itemPrices && !config.dontSubtractPurchaseItemCost) {
 | 
				
			||||||
                        handleItemPrices(
 | 
					                        handleItemPrices(
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user