forked from OpenWF/SpaceNinjaServer
		
	fix: handle credits & platinum prices from vendors (#1856)
Fixes #1837 Reviewed-on: OpenWF/SpaceNinjaServer#1856 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									48eefd8db1
								
							
						
					
					
						commit
						66d1a65e63
					
				@ -66,6 +66,18 @@ export const handlePurchase = async (
 | 
				
			|||||||
            if (!offer) {
 | 
					            if (!offer) {
 | 
				
			||||||
                throw new Error(`unknown vendor offer: ${ItemId ? ItemId : purchaseRequest.PurchaseParams.StoreItem}`);
 | 
					                throw new Error(`unknown vendor offer: ${ItemId ? ItemId : purchaseRequest.PurchaseParams.StoreItem}`);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            if (offer.RegularPrice) {
 | 
				
			||||||
 | 
					                combineInventoryChanges(
 | 
				
			||||||
 | 
					                    prePurchaseInventoryChanges,
 | 
				
			||||||
 | 
					                    updateCurrency(inventory, offer.RegularPrice[0], false)
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (offer.PremiumPrice) {
 | 
				
			||||||
 | 
					                combineInventoryChanges(
 | 
				
			||||||
 | 
					                    prePurchaseInventoryChanges,
 | 
				
			||||||
 | 
					                    updateCurrency(inventory, offer.PremiumPrice[0], true)
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if (offer.ItemPrices) {
 | 
					            if (offer.ItemPrices) {
 | 
				
			||||||
                handleItemPrices(
 | 
					                handleItemPrices(
 | 
				
			||||||
                    inventory,
 | 
					                    inventory,
 | 
				
			||||||
@ -170,6 +182,9 @@ export const handlePurchase = async (
 | 
				
			|||||||
                    purchaseResponse.InventoryChanges,
 | 
					                    purchaseResponse.InventoryChanges,
 | 
				
			||||||
                    updateCurrency(inventory, offer.RegularPrice, false)
 | 
					                    updateCurrency(inventory, offer.RegularPrice, false)
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
 | 
					                if (purchaseRequest.PurchaseParams.ExpectedPrice) {
 | 
				
			||||||
 | 
					                    throw new Error(`vendor purchase should not have an expected price`);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const invItem: IMiscItem = {
 | 
					                const invItem: IMiscItem = {
 | 
				
			||||||
                    ItemType: "/Lotus/Types/Items/MiscItems/PrimeBucks",
 | 
					                    ItemType: "/Lotus/Types/Items/MiscItems/PrimeBucks",
 | 
				
			||||||
@ -229,6 +244,12 @@ export const handlePurchase = async (
 | 
				
			|||||||
                            updateCurrency(inventory, offer.credits, false)
 | 
					                            updateCurrency(inventory, offer.credits, false)
 | 
				
			||||||
                        );
 | 
					                        );
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (typeof offer.platinum == "number") {
 | 
				
			||||||
 | 
					                        combineInventoryChanges(
 | 
				
			||||||
 | 
					                            purchaseResponse.InventoryChanges,
 | 
				
			||||||
 | 
					                            updateCurrency(inventory, offer.platinum, true)
 | 
				
			||||||
 | 
					                        );
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    if (offer.itemPrices) {
 | 
					                    if (offer.itemPrices) {
 | 
				
			||||||
                        handleItemPrices(
 | 
					                        handleItemPrices(
 | 
				
			||||||
                            inventory,
 | 
					                            inventory,
 | 
				
			||||||
@ -239,6 +260,9 @@ export const handlePurchase = async (
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            if (purchaseRequest.PurchaseParams.ExpectedPrice) {
 | 
				
			||||||
 | 
					                throw new Error(`vendor purchase should not have an expected price`);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case 18: {
 | 
					        case 18: {
 | 
				
			||||||
            if (purchaseRequest.PurchaseParams.SourceId! != worldState.PrimeVaultTraders[0]._id.$oid) {
 | 
					            if (purchaseRequest.PurchaseParams.SourceId! != worldState.PrimeVaultTraders[0]._id.$oid) {
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,7 @@ export interface IItemManifest {
 | 
				
			|||||||
    StoreItem: string;
 | 
					    StoreItem: string;
 | 
				
			||||||
    ItemPrices?: IItemPrice[];
 | 
					    ItemPrices?: IItemPrice[];
 | 
				
			||||||
    RegularPrice?: number[];
 | 
					    RegularPrice?: number[];
 | 
				
			||||||
 | 
					    PremiumPrice?: number[];
 | 
				
			||||||
    Bin: string;
 | 
					    Bin: string;
 | 
				
			||||||
    QuantityMultiplier: number;
 | 
					    QuantityMultiplier: number;
 | 
				
			||||||
    Expiry: IMongoDate; // Either a date in the distant future or a period in milliseconds for preprocessing.
 | 
					    Expiry: IMongoDate; // Either a date in the distant future or a period in milliseconds for preprocessing.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user