forked from OpenWF/SpaceNinjaServer
		
	use creditBundles
This commit is contained in:
		
							parent
							
								
									af7df53799
								
							
						
					
					
						commit
						ab111d5c57
					
				@ -62,7 +62,9 @@ export const creditBundles: Record<string, number> = {
 | 
			
		||||
    "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardTwoHard": 175000,
 | 
			
		||||
    "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardThreeHard": 250000,
 | 
			
		||||
    "/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> = {
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,7 @@ import {
 | 
			
		||||
} from "warframe-public-export-plus";
 | 
			
		||||
import { config } from "./configService";
 | 
			
		||||
import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
 | 
			
		||||
import { creditBundles } from "./missionInventoryUpdateService";
 | 
			
		||||
 | 
			
		||||
export const getStoreItemCategory = (storeItem: string): string => {
 | 
			
		||||
    const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
 | 
			
		||||
@ -335,24 +336,16 @@ const handleCreditBundlePurchase = async (
 | 
			
		||||
    inventory: TInventoryDatabaseDocument
 | 
			
		||||
): Promise<IPurchaseResponse> => {
 | 
			
		||||
    const bundleName = typeName.split("/").pop();
 | 
			
		||||
    let creditsAmount = 0;
 | 
			
		||||
 | 
			
		||||
    // CreditBundleA = 50.000 credits or CreditBundleC = 175.000 credits
 | 
			
		||||
    switch (bundleName) {
 | 
			
		||||
        case "CreditBundleA":
 | 
			
		||||
            creditsAmount = 50_000;
 | 
			
		||||
            break;
 | 
			
		||||
        case "CreditBundleC":
 | 
			
		||||
            creditsAmount = 175_000;
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            throw new Error("invalid credit bundle: " + bundleName);
 | 
			
		||||
    if (bundleName && bundleName in creditBundles) {
 | 
			
		||||
        const creditsAmount = creditBundles[bundleName];
 | 
			
		||||
        inventory.RegularCredits += creditsAmount;
 | 
			
		||||
        await inventory.save();
 | 
			
		||||
 | 
			
		||||
        return { InventoryChanges: { RegularCredits: creditsAmount } };
 | 
			
		||||
    } else {
 | 
			
		||||
        throw new Error(`unknown credit bundle: ${typeName}`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    inventory.RegularCredits += creditsAmount;
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
 | 
			
		||||
    return { InventoryChanges: { RegularCredits: creditsAmount } };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//TODO: change to getInventory, apply changes then save at the end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user