feat: apply QuantityMultiplier for server-side vendor offers #605
@ -9,6 +9,7 @@ import {
 | 
				
			|||||||
    updateCurrency,
 | 
					    updateCurrency,
 | 
				
			||||||
    updateSlots
 | 
					    updateSlots
 | 
				
			||||||
} from "@/src/services/inventoryService";
 | 
					} from "@/src/services/inventoryService";
 | 
				
			||||||
 | 
					import { getVendorManifestByOid } from "@/src/services/serversideVendorsService";
 | 
				
			||||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
					import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
					import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
@ -32,6 +33,18 @@ export const getStoreItemTypesCategory = (typesItem: string) => {
 | 
				
			|||||||
export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountId: string) => {
 | 
					export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountId: string) => {
 | 
				
			||||||
    logger.debug("purchase request", purchaseRequest);
 | 
					    logger.debug("purchase request", purchaseRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (purchaseRequest.PurchaseParams.Source == 7) {
 | 
				
			||||||
 | 
					        const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
 | 
				
			||||||
 | 
					        if (manifest) {
 | 
				
			||||||
 | 
					            const offer = manifest.VendorInfo.ItemManifest.find(
 | 
				
			||||||
 | 
					                x => x.StoreItem == purchaseRequest.PurchaseParams.StoreItem
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            if (offer) {
 | 
				
			||||||
 | 
					                purchaseRequest.PurchaseParams.Quantity *= offer.QuantityMultiplier;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const purchaseResponse = await handleStoreItemAcquisition(
 | 
					    const purchaseResponse = await handleStoreItemAcquisition(
 | 
				
			||||||
        purchaseRequest.PurchaseParams.StoreItem,
 | 
					        purchaseRequest.PurchaseParams.StoreItem,
 | 
				
			||||||
        accountId,
 | 
					        accountId,
 | 
				
			||||||
@ -53,11 +66,8 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    switch (purchaseRequest.PurchaseParams.Source) {
 | 
					    switch (purchaseRequest.PurchaseParams.Source) {
 | 
				
			||||||
        case 7:
 | 
					        case 7:
 | 
				
			||||||
            if (!purchaseRequest.PurchaseParams.SourceId) {
 | 
					            if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {
 | 
				
			||||||
                throw new Error("invalid request source");
 | 
					                const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!];
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (ExportVendors[purchaseRequest.PurchaseParams.SourceId]) {
 | 
					 | 
				
			||||||
                const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId];
 | 
					 | 
				
			||||||
                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) {
 | 
				
			||||||
                    const inventory = await getInventory(accountId);
 | 
					                    const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user