feat: implement creditbundle purchases
All checks were successful
Build / build (20) (pull_request) Successful in 34s
Build / build (18) (pull_request) Successful in 1m1s
Build / build (22) (pull_request) Successful in 1m12s

This commit is contained in:
nrbdev 2025-02-22 16:12:55 -05:00
parent bf7fd42198
commit de9283e3a7

View File

@ -330,6 +330,20 @@ const handleBoosterPackPurchase = async (
return purchaseResponse; 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 //TODO: change to getInventory, apply changes then save at the end
const handleTypesPurchase = async ( const handleTypesPurchase = async (
typesName: string, typesName: string,
@ -345,6 +359,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);
} }
}; };