fix: purchases adding currency instead of subtracting

This commit is contained in:
Sainan 2024-05-04 22:17:41 +02:00
parent 6eaa1d8959
commit 32160dfede
2 changed files with 4 additions and 4 deletions

View File

@ -27,7 +27,7 @@ export const inventorySlotsController: RequestHandler = async (req, res) => {
//TODO: check which slot was purchased because pvpBonus is also possible
const currencyChanges = await updateCurrency(-20, true, accountId);
const currencyChanges = await updateCurrency(20, true, accountId);
await updateSlots(accountId, SlotNameToInventoryName.LOADOUT, 1, 1);
//console.log({ InventoryChanges: currencyChanges }, " added loadout changes:");

View File

@ -97,11 +97,11 @@ export const updateCurrency = async (price: number, usePremium: boolean, account
if (usePremium) {
if (inventory.PremiumCreditsFree > 0) {
inventory.PremiumCreditsFree += price;
inventory.PremiumCreditsFree -= price;
}
inventory.PremiumCredits += price;
inventory.PremiumCredits -= price;
} else {
inventory.RegularCredits += price;
inventory.RegularCredits -= price;
}
const modifiedPaths = inventory.modifiedPaths();