chore: cleanup purchase stuff #2266
@ -75,18 +75,12 @@ export const handlePurchase = async (
|
||||
}
|
||||
if (!config.dontSubtractPurchaseCreditCost) {
|
||||
if (offer.RegularPrice) {
|
||||
combineInventoryChanges(
|
||||
prePurchaseInventoryChanges,
|
||||
updateCurrency(inventory, offer.RegularPrice[0], false)
|
||||
);
|
||||
updateCurrency(inventory, offer.RegularPrice[0], false, prePurchaseInventoryChanges);
|
||||
}
|
||||
}
|
||||
if (!config.dontSubtractPurchasePlatinumCost) {
|
||||
if (offer.PremiumPrice) {
|
||||
combineInventoryChanges(
|
||||
prePurchaseInventoryChanges,
|
||||
updateCurrency(inventory, offer.PremiumPrice[0], true)
|
||||
);
|
||||
updateCurrency(inventory, offer.PremiumPrice[0], true, prePurchaseInventoryChanges);
|
||||
}
|
||||
}
|
||||
if (!config.dontSubtractPurchaseItemCost) {
|
||||
@ -172,15 +166,12 @@ export const handlePurchase = async (
|
||||
);
|
||||
combineInventoryChanges(purchaseResponse.InventoryChanges, prePurchaseInventoryChanges);
|
||||
|
||||
const currencyChanges = updateCurrency(
|
||||
updateCurrency(
|
||||
inventory,
|
||||
purchaseRequest.PurchaseParams.ExpectedPrice,
|
||||
purchaseRequest.PurchaseParams.UsePremium
|
||||
purchaseRequest.PurchaseParams.UsePremium,
|
||||
prePurchaseInventoryChanges
|
||||
);
|
||||
purchaseResponse.InventoryChanges = {
|
||||
...currencyChanges,
|
||||
...purchaseResponse.InventoryChanges
|
||||
};
|
||||
|
||||
switch (purchaseRequest.PurchaseParams.Source) {
|
||||
case PurchaseSource.VoidTrader: {
|
||||
@ -192,10 +183,7 @@ export const handlePurchase = async (
|
||||
);
|
||||
if (offer) {
|
||||
if (!config.dontSubtractPurchaseCreditCost) {
|
||||
combineInventoryChanges(
|
||||
purchaseResponse.InventoryChanges,
|
||||
updateCurrency(inventory, offer.RegularPrice, false)
|
||||
);
|
||||
updateCurrency(inventory, offer.RegularPrice, false, purchaseResponse.InventoryChanges);
|
||||
}
|
||||
if (purchaseRequest.PurchaseParams.ExpectedPrice) {
|
||||
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);
|
||||
if (offer) {
|
||||
if (typeof offer.credits == "number" && !config.dontSubtractPurchaseCreditCost) {
|
||||
combineInventoryChanges(
|
||||
purchaseResponse.InventoryChanges,
|
||||
updateCurrency(inventory, offer.credits, false)
|
||||
);
|
||||
updateCurrency(inventory, offer.credits, false, purchaseResponse.InventoryChanges);
|
||||
}
|
||||
if (typeof offer.platinum == "number" && !config.dontSubtractPurchasePlatinumCost) {
|
||||
combineInventoryChanges(
|
||||
purchaseResponse.InventoryChanges,
|
||||
updateCurrency(inventory, offer.platinum, true)
|
||||
);
|
||||
updateCurrency(inventory, offer.platinum, true, purchaseResponse.InventoryChanges);
|
||||
}
|
||||
if (offer.itemPrices && !config.dontSubtractPurchaseItemCost) {
|
||||
handleItemPrices(
|
||||
|
Loading…
x
Reference in New Issue
Block a user