返回提交历史
Modified
src/services/purchaseService.ts
+20
-15
Modified
src/types/purchaseTypes.ts
+1
-1
XFEstudio/XFESpaceNinjaServer
fix: ignore purchaseQuantity when getting slots via a bundle (#1151)
Fixes #1149 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1151
4e0494f1
代码差异
2 个文件
+21
-16
@@ -256,7 +256,7 @@ export const handleStoreItemAcquisition = async (
256
256
break;
257
257
}
258
258
case "Types":
259
purchaseResponse = await handleTypesPurchase(internalName, inventory, quantity);
259
purchaseResponse = await handleTypesPurchase(internalName, inventory, quantity, ignorePurchaseQuantity);
260
260
break;
261
261
case "Boosters":
262
262
purchaseResponse = handleBoostersPurchase(storeItemName, inventory, durability);
@@ -267,16 +267,16 @@ export const handleStoreItemAcquisition = async (
267
267
};
268
268
269
269
export const slotPurchaseNameToSlotName: SlotPurchase = {
270
SuitSlotItem: { name: "SuitBin", slotsPerPurchase: 1 },
271
TwoSentinelSlotItem: { name: "SentinelBin", slotsPerPurchase: 2 },
272
TwoWeaponSlotItem: { name: "WeaponBin", slotsPerPurchase: 2 },
273
SpaceSuitSlotItem: { name: "SpaceSuitBin", slotsPerPurchase: 1 },
274
TwoSpaceWeaponSlotItem: { name: "SpaceWeaponBin", slotsPerPurchase: 2 },
275
MechSlotItem: { name: "MechBin", slotsPerPurchase: 1 },
276
TwoOperatorWeaponSlotItem: { name: "OperatorAmpBin", slotsPerPurchase: 2 },
277
RandomModSlotItem: { name: "RandomModBin", slotsPerPurchase: 3 },
278
TwoCrewShipSalvageSlotItem: { name: "CrewShipSalvageBin", slotsPerPurchase: 2 },
279
CrewMemberSlotItem: { name: "CrewMemberBin", slotsPerPurchase: 1 }
270
SuitSlotItem: { name: "SuitBin", purchaseQuantity: 1 },
271
TwoSentinelSlotItem: { name: "SentinelBin", purchaseQuantity: 2 },
272
TwoWeaponSlotItem: { name: "WeaponBin", purchaseQuantity: 2 },
273
SpaceSuitSlotItem: { name: "SpaceSuitBin", purchaseQuantity: 1 },
274
TwoSpaceWeaponSlotItem: { name: "SpaceWeaponBin", purchaseQuantity: 2 },
275
MechSlotItem: { name: "MechBin", purchaseQuantity: 1 },
276
TwoOperatorWeaponSlotItem: { name: "OperatorAmpBin", purchaseQuantity: 2 },
277
RandomModSlotItem: { name: "RandomModBin", purchaseQuantity: 3 },
278
TwoCrewShipSalvageSlotItem: { name: "CrewShipSalvageBin", purchaseQuantity: 2 },
279
CrewMemberSlotItem: { name: "CrewMemberBin", purchaseQuantity: 1 }
280
280
};
281
281
282
282
// // extra = everything above the base +2 slots (depending on slot type)
@@ -286,7 +286,8 @@ export const slotPurchaseNameToSlotName: SlotPurchase = {
286
286
const handleSlotPurchase = (
287
287
slotPurchaseNameFull: string,
288
288
inventory: TInventoryDatabaseDocument,
289
quantity: number
289
quantity: number,
290
ignorePurchaseQuantity: boolean
290
291
): IPurchaseResponse => {
291
292
logger.debug(`slot name ${slotPurchaseNameFull}`);
292
293
const slotPurchaseName = parseSlotPurchaseName(
@@ -295,7 +296,10 @@ const handleSlotPurchase = (
295
296
logger.debug(`slot purchase name ${slotPurchaseName}`);
296
297
297
298
const slotName = slotPurchaseNameToSlotName[slotPurchaseName].name;
298
const slotsPurchased = slotPurchaseNameToSlotName[slotPurchaseName].slotsPerPurchase * quantity;
299
let slotsPurchased = quantity;
300
if (!ignorePurchaseQuantity) {
301
slotsPurchased *= slotPurchaseNameToSlotName[slotPurchaseName].purchaseQuantity;
302
}
299
303
300
304
updateSlots(inventory, slotName, slotsPurchased, slotsPurchased);
301
305
@@ -360,7 +364,8 @@ const handleCreditBundlePurchase = async (
360
364
const handleTypesPurchase = async (
361
365
typesName: string,
362
366
inventory: TInventoryDatabaseDocument,
363
quantity: number
367
quantity: number,
368
ignorePurchaseQuantity: boolean
364
369
): Promise<IPurchaseResponse> => {
365
370
const typeCategory = getStoreItemTypesCategory(typesName);
366
371
logger.debug(`type category ${typeCategory}`);
@@ -370,7 +375,7 @@ const handleTypesPurchase = async (
370
375
case "BoosterPacks":
371
376
return handleBoosterPackPurchase(typesName, inventory, quantity);
372
377
case "SlotItems":
373
return handleSlotPurchase(typesName, inventory, quantity);
378
return handleSlotPurchase(typesName, inventory, quantity, ignorePurchaseQuantity);
374
379
case "CreditBundles":
375
380
return handleCreditBundlePurchase(typesName, inventory);
376
381
}
@@ -105,5 +105,5 @@ export const slotNames = [
105
105
export type SlotNames = (typeof slotNames)[number];
106
106
107
107
export type SlotPurchase = {
108
[P in SlotPurchaseName]: { name: SlotNames; slotsPerPurchase: number };
108
[P in SlotPurchaseName]: { name: SlotNames; purchaseQuantity: number };
109
109
};