feat: implement CreditBundle purchases #989

Merged
OrdisPrime merged 5 commits from neon/SpaceNinjaServer:credit-bundles into main 2025-02-23 03:53:57 -08:00
Showing only changes of commit de9283e3a7 - Show all commits

View File

@ -330,6 +330,20 @@ const handleBoosterPackPurchase = async (
return purchaseResponse;
};
const handleCreditBundlePurchase = async (
typeName: string,
inventory: TInventoryDatabaseDocument
): Promise<IPurchaseResponse> => {
const bundleName = typeName.split(typeName).pop();
// CreditBundleA = 50.000 credits or CreditBundleC = 175.000 credits
const creditsAmount = bundleName == "CreditBundleA" ? 50_000 : 175_000;
inventory.RegularCredits += creditsAmount;
await inventory.save();
return { InventoryChanges: { RegularCredits: creditsAmount } };
};
//TODO: change to getInventory, apply changes then save at the end
const handleTypesPurchase = async (
typesName: string,
@ -345,6 +359,8 @@ const handleTypesPurchase = async (
return handleBoosterPackPurchase(typesName, inventory, quantity);
case "SlotItems":
return handleSlotPurchase(typesName, inventory, quantity);
case "CreditBundles":
return handleCreditBundlePurchase(typesName, inventory);
}
};