fix: purchasing an arcane pack does not consume vosfor
This commit is contained in:
		
							parent
							
								
									cbdd1cd0a7
								
							
						
					
					
						commit
						c203cf76e8
					
				
							
								
								
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -12,7 +12,7 @@
 | 
			
		||||
        "copyfiles": "^2.4.1",
 | 
			
		||||
        "express": "^5",
 | 
			
		||||
        "mongoose": "^8.9.2",
 | 
			
		||||
        "warframe-public-export-plus": "^0.5.8",
 | 
			
		||||
        "warframe-public-export-plus": "^0.5.9",
 | 
			
		||||
        "warframe-riven-info": "^0.1.2",
 | 
			
		||||
        "winston": "^3.17.0",
 | 
			
		||||
        "winston-daily-rotate-file": "^5.0.0"
 | 
			
		||||
@ -3877,9 +3877,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-public-export-plus": {
 | 
			
		||||
      "version": "0.5.8",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.8.tgz",
 | 
			
		||||
      "integrity": "sha512-ZhHrKIkI6nhjKDlxhrNcfN8r2Yc9g+eeKLS6+9w7gzC4NscIt6TU8tH8bfjJTDeo6nRrzt88szX1/Oo3WnUY4Q=="
 | 
			
		||||
      "version": "0.5.9",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.9.tgz",
 | 
			
		||||
      "integrity": "sha512-qwQVtYI7wghatg7UrJ3CFstXba5Hsks398L6ngv16auqoTVAfw/cLBqFv9DzsEpqvcVWL22IZIH+cNWiq1JXOQ=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-riven-info": {
 | 
			
		||||
      "version": "0.1.2",
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@
 | 
			
		||||
    "copyfiles": "^2.4.1",
 | 
			
		||||
    "express": "^5",
 | 
			
		||||
    "mongoose": "^8.9.2",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.8",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.9",
 | 
			
		||||
    "warframe-riven-info": "^0.1.2",
 | 
			
		||||
    "winston": "^3.17.0",
 | 
			
		||||
    "winston-daily-rotate-file": "^5.0.0"
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,18 @@
 | 
			
		||||
import { parseSlotPurchaseName } from "@/src/helpers/purchaseHelpers";
 | 
			
		||||
import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import {
 | 
			
		||||
    addItem,
 | 
			
		||||
    addBooster,
 | 
			
		||||
    addItem,
 | 
			
		||||
    addMiscItems,
 | 
			
		||||
    combineInventoryChanges,
 | 
			
		||||
    getInventory,
 | 
			
		||||
    updateCurrency,
 | 
			
		||||
    updateSlots
 | 
			
		||||
} from "@/src/services/inventoryService";
 | 
			
		||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { ExportBundles, ExportGear, TRarity } from "warframe-public-export-plus";
 | 
			
		||||
import { ExportBundles, ExportGear, ExportVendors, TRarity } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const getStoreItemCategory = (storeItem: string) => {
 | 
			
		||||
    const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
 | 
			
		||||
@ -43,12 +46,46 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
 | 
			
		||||
        purchaseRequest.PurchaseParams.UsePremium,
 | 
			
		||||
        accountId
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    purchaseResponse.InventoryChanges = {
 | 
			
		||||
        ...currencyChanges,
 | 
			
		||||
        ...purchaseResponse.InventoryChanges
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    switch (purchaseRequest.PurchaseParams.Source) {
 | 
			
		||||
        case 7:
 | 
			
		||||
            if (!purchaseRequest.PurchaseParams.SourceId) {
 | 
			
		||||
                throw new Error("invalid request source");
 | 
			
		||||
            }
 | 
			
		||||
            if (ExportVendors[purchaseRequest.PurchaseParams.SourceId]) {
 | 
			
		||||
                const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId];
 | 
			
		||||
                const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
 | 
			
		||||
                if (offer) {
 | 
			
		||||
                    const inventory = await getInventory(accountId);
 | 
			
		||||
                    for (const item of offer.itemPrices) {
 | 
			
		||||
                        const invItem: IMiscItem = {
 | 
			
		||||
                            ItemType: item.ItemType,
 | 
			
		||||
                            ItemCount: item.ItemCount * -1
 | 
			
		||||
                        };
 | 
			
		||||
 | 
			
		||||
                        addMiscItems(inventory, [invItem]);
 | 
			
		||||
 | 
			
		||||
                        purchaseResponse.InventoryChanges.MiscItems ??= [];
 | 
			
		||||
                        const change = (purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).find(
 | 
			
		||||
                            x => x.ItemType == item.ItemType
 | 
			
		||||
                        );
 | 
			
		||||
                        if (change) {
 | 
			
		||||
                            change.ItemCount -= item.ItemCount;
 | 
			
		||||
                        } else {
 | 
			
		||||
                            (purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).push(invItem);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    await inventory.save();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return purchaseResponse;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ export interface IPurchaseRequest {
 | 
			
		||||
 | 
			
		||||
export interface IPurchaseParams {
 | 
			
		||||
    Source: number;
 | 
			
		||||
    SourceId?: string; // for Source 7
 | 
			
		||||
    StoreItem: string;
 | 
			
		||||
    StorePage: string;
 | 
			
		||||
    SearchTerm: string;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user