feat: implement CreditBundle purchases (#989)
This fixes purchasing one of the few bundles that include these credit bundles. Ex: Essential Damage mod bundles Reviewed-on: OpenWF/SpaceNinjaServer#989 Co-authored-by: nrbdev <itzneonrb@gmail.com> Co-committed-by: nrbdev <itzneonrb@gmail.com>
This commit is contained in:
		
							parent
							
								
									0142aa72a8
								
							
						
					
					
						commit
						e1af6bd598
					
				@ -62,7 +62,9 @@ export const creditBundles: Record<string, number> = {
 | 
				
			|||||||
    "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardTwoHard": 175000,
 | 
					    "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardTwoHard": 175000,
 | 
				
			||||||
    "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardThreeHard": 250000,
 | 
					    "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardThreeHard": 250000,
 | 
				
			||||||
    "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsCommon": 15000,
 | 
					    "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsCommon": 15000,
 | 
				
			||||||
    "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsUncommon": 30000
 | 
					    "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsUncommon": 30000,
 | 
				
			||||||
 | 
					    "/Lotus/Types/StoreItems/CreditBundles/CreditBundleA": 50000,
 | 
				
			||||||
 | 
					    "/Lotus/Types/StoreItems/CreditBundles/CreditBundleC": 175000
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const fusionBundles: Record<string, number> = {
 | 
					export const fusionBundles: Record<string, number> = {
 | 
				
			||||||
 | 
				
			|||||||
@ -25,6 +25,7 @@ import {
 | 
				
			|||||||
} from "warframe-public-export-plus";
 | 
					} from "warframe-public-export-plus";
 | 
				
			||||||
import { config } from "./configService";
 | 
					import { config } from "./configService";
 | 
				
			||||||
import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
 | 
					import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
 | 
				
			||||||
 | 
					import { creditBundles } from "./missionInventoryUpdateService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getStoreItemCategory = (storeItem: string): string => {
 | 
					export const getStoreItemCategory = (storeItem: string): string => {
 | 
				
			||||||
    const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
 | 
					    const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
 | 
				
			||||||
@ -330,6 +331,22 @@ const handleBoosterPackPurchase = async (
 | 
				
			|||||||
    return purchaseResponse;
 | 
					    return purchaseResponse;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const handleCreditBundlePurchase = async (
 | 
				
			||||||
 | 
					    typeName: string,
 | 
				
			||||||
 | 
					    inventory: TInventoryDatabaseDocument
 | 
				
			||||||
 | 
					): Promise<IPurchaseResponse> => {
 | 
				
			||||||
 | 
					    if (typeName && typeName in creditBundles) {
 | 
				
			||||||
 | 
					        const creditsAmount = creditBundles[typeName];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        inventory.RegularCredits += creditsAmount;
 | 
				
			||||||
 | 
					        await inventory.save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return { InventoryChanges: { RegularCredits: creditsAmount } };
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        throw new Error(`unknown credit bundle: ${typeName}`);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//TODO: change to getInventory, apply changes then save at the end
 | 
					//TODO: change to getInventory, apply changes then save at the end
 | 
				
			||||||
const handleTypesPurchase = async (
 | 
					const handleTypesPurchase = async (
 | 
				
			||||||
    typesName: string,
 | 
					    typesName: string,
 | 
				
			||||||
@ -345,6 +362,8 @@ const handleTypesPurchase = async (
 | 
				
			|||||||
            return handleBoosterPackPurchase(typesName, inventory, quantity);
 | 
					            return handleBoosterPackPurchase(typesName, inventory, quantity);
 | 
				
			||||||
        case "SlotItems":
 | 
					        case "SlotItems":
 | 
				
			||||||
            return handleSlotPurchase(typesName, inventory, quantity);
 | 
					            return handleSlotPurchase(typesName, inventory, quantity);
 | 
				
			||||||
 | 
					        case "CreditBundles":
 | 
				
			||||||
 | 
					            return handleCreditBundlePurchase(typesName, inventory);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user