返回提交历史
Modified
src/services/purchaseService.ts
+8
-7
XFEstudio/XFESpaceNinjaServer
fix: quantity ignored when purchasing slots (#704)
27ddada3
代码差异
1 个文件
+8
-7
@@ -240,7 +240,8 @@ export const slotPurchaseNameToSlotName: SlotPurchase = {
240
240
// // number of frames = extra - slots + 2
241
241
const handleSlotPurchase = async (
242
242
slotPurchaseNameFull: string,
243
accountId: string
243
accountId: string,
244
quantity: number
244
245
): Promise<{ InventoryChanges: IInventoryChanges }> => {
245
246
logger.debug(`slot name ${slotPurchaseNameFull}`);
246
247
const slotPurchaseName = parseSlotPurchaseName(
@@ -249,21 +250,21 @@ const handleSlotPurchase = async (
249
250
logger.debug(`slot purchase name ${slotPurchaseName}`);
250
251
251
252
const slotName = slotPurchaseNameToSlotName[slotPurchaseName].name;
252
const slotsPerPurchase = slotPurchaseNameToSlotName[slotPurchaseName].slotsPerPurchase;
253
const slotsPurchased = slotPurchaseNameToSlotName[slotPurchaseName].slotsPerPurchase * quantity;
253
254
254
255
const inventory = await getInventory(accountId);
255
updateSlots(inventory, slotName, slotsPerPurchase, slotsPerPurchase);
256
updateSlots(inventory, slotName, slotsPurchased, slotsPurchased);
256
257
await inventory.save();
257
258
258
logger.debug(`added ${slotsPerPurchase} slot ${slotName}`);
259
logger.debug(`added ${slotsPurchased} slot ${slotName}`);
259
260
260
261
return {
261
262
InventoryChanges: {
262
263
[slotName]: {
263
264
count: 0,
264
265
platinum: 1,
265
Slots: slotsPerPurchase,
266
Extra: slotsPerPurchase
266
Slots: slotsPurchased,
267
Extra: slotsPurchased
267
268
}
268
269
}
269
270
};
@@ -319,7 +320,7 @@ const handleTypesPurchase = async (
319
320
case "BoosterPacks":
320
321
return await handleBoosterPackPurchase(typesName, accountId, quantity);
321
322
case "SlotItems":
322
return await handleSlotPurchase(typesName, accountId);
323
return await handleSlotPurchase(typesName, accountId, quantity);
323
324
}
324
325
};
325
326