feat: acquisition of peely pix + free pack for first visit #1292
@ -51,12 +51,17 @@ export const handlePurchase = async (
 | 
				
			|||||||
    logger.debug("purchase request", purchaseRequest);
 | 
					    logger.debug("purchase request", purchaseRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const prePurchaseInventoryChanges: IInventoryChanges = {};
 | 
					    const prePurchaseInventoryChanges: IInventoryChanges = {};
 | 
				
			||||||
    if (purchaseRequest.PurchaseParams.Source == 7 && purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson) {
 | 
					    if (purchaseRequest.PurchaseParams.Source == 7) {
 | 
				
			||||||
        const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
 | 
					        const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
 | 
				
			||||||
        if (manifest) {
 | 
					        if (manifest) {
 | 
				
			||||||
            const ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson) as { ItemId: string })
 | 
					            let ItemId: string | undefined;
 | 
				
			||||||
                .ItemId;
 | 
					            if (purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson) {
 | 
				
			||||||
            const offer = manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId);
 | 
					                ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson) as { ItemId: string })
 | 
				
			||||||
 | 
					                    .ItemId;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            const offer = ItemId
 | 
				
			||||||
 | 
					                ? manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId)
 | 
				
			||||||
 | 
					                : manifest.VendorInfo.ItemManifest.find(x => x.StoreItem == purchaseRequest.PurchaseParams.StoreItem);
 | 
				
			||||||
            if (!offer) {
 | 
					            if (!offer) {
 | 
				
			||||||
                throw new Error(`unknown vendor offer: ${ItemId}`);
 | 
					                throw new Error(`unknown vendor offer: ${ItemId}`);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -68,7 +73,7 @@ export const handlePurchase = async (
 | 
				
			|||||||
                    prePurchaseInventoryChanges
 | 
					                    prePurchaseInventoryChanges
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (!config.noVendorPurchaseLimits) {
 | 
					            if (!config.noVendorPurchaseLimits && ItemId) {
 | 
				
			||||||
                inventory.RecentVendorPurchases ??= [];
 | 
					                inventory.RecentVendorPurchases ??= [];
 | 
				
			||||||
                let vendorPurchases = inventory.RecentVendorPurchases.find(
 | 
					                let vendorPurchases = inventory.RecentVendorPurchases.find(
 | 
				
			||||||
                    x => x.VendorType == manifest.VendorInfo.TypeName
 | 
					                    x => x.VendorType == manifest.VendorInfo.TypeName
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user