fix: quantity ignored when purchasing slots (#704)

This commit is contained in:
Sainan 2025-01-05 02:43:06 +01:00 committed by GitHub
parent 571d244985
commit 27ddada3f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -240,7 +240,8 @@ export const slotPurchaseNameToSlotName: SlotPurchase = {
// // number of frames = extra - slots + 2 // // number of frames = extra - slots + 2
const handleSlotPurchase = async ( const handleSlotPurchase = async (
slotPurchaseNameFull: string, slotPurchaseNameFull: string,
accountId: string accountId: string,
quantity: number
): Promise<{ InventoryChanges: IInventoryChanges }> => { ): Promise<{ InventoryChanges: IInventoryChanges }> => {
logger.debug(`slot name ${slotPurchaseNameFull}`); logger.debug(`slot name ${slotPurchaseNameFull}`);
const slotPurchaseName = parseSlotPurchaseName( const slotPurchaseName = parseSlotPurchaseName(
@ -249,21 +250,21 @@ const handleSlotPurchase = async (
logger.debug(`slot purchase name ${slotPurchaseName}`); logger.debug(`slot purchase name ${slotPurchaseName}`);
const slotName = slotPurchaseNameToSlotName[slotPurchaseName].name; const slotName = slotPurchaseNameToSlotName[slotPurchaseName].name;
const slotsPerPurchase = slotPurchaseNameToSlotName[slotPurchaseName].slotsPerPurchase; const slotsPurchased = slotPurchaseNameToSlotName[slotPurchaseName].slotsPerPurchase * quantity;
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
updateSlots(inventory, slotName, slotsPerPurchase, slotsPerPurchase); updateSlots(inventory, slotName, slotsPurchased, slotsPurchased);
await inventory.save(); await inventory.save();
logger.debug(`added ${slotsPerPurchase} slot ${slotName}`); logger.debug(`added ${slotsPurchased} slot ${slotName}`);
return { return {
InventoryChanges: { InventoryChanges: {
[slotName]: { [slotName]: {
count: 0, count: 0,
platinum: 1, platinum: 1,
Slots: slotsPerPurchase, Slots: slotsPurchased,
Extra: slotsPerPurchase Extra: slotsPurchased
} }
} }
}; };
@ -319,7 +320,7 @@ const handleTypesPurchase = async (
case "BoosterPacks": case "BoosterPacks":
return await handleBoosterPackPurchase(typesName, accountId, quantity); return await handleBoosterPackPurchase(typesName, accountId, quantity);
case "SlotItems": case "SlotItems":
return await handleSlotPurchase(typesName, accountId); return await handleSlotPurchase(typesName, accountId, quantity);
} }
}; };