feat: implement creditbundle purchases
This commit is contained in:
parent
bf7fd42198
commit
de9283e3a7
@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user