feat: handle MiscItem purchase with quantity > 1
This commit is contained in:
parent
19ba136c08
commit
a80aa0d0a0
@ -47,7 +47,7 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
|
|||||||
inventoryChanges = await handleWeaponsPurchase(internalName, accountId);
|
inventoryChanges = await handleWeaponsPurchase(internalName, accountId);
|
||||||
break;
|
break;
|
||||||
case "Types":
|
case "Types":
|
||||||
inventoryChanges = await handleTypesPurchase(internalName, accountId);
|
inventoryChanges = await handleTypesPurchase(internalName, accountId, purchaseRequest.PurchaseParams.Quantity);
|
||||||
break;
|
break;
|
||||||
case "Boosters":
|
case "Boosters":
|
||||||
inventoryChanges = await handleBoostersPurchase(internalName, accountId);
|
inventoryChanges = await handleBoostersPurchase(internalName, accountId);
|
||||||
@ -169,7 +169,7 @@ const handlePowersuitPurchase = async (powersuitName: string, accountId: string)
|
|||||||
};
|
};
|
||||||
|
|
||||||
//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 (typesName: string, accountId: string) => {
|
const handleTypesPurchase = async (typesName: string, accountId: string, quantity: number) => {
|
||||||
const typeCategory = getStoreItemTypesCategory(typesName);
|
const typeCategory = getStoreItemTypesCategory(typesName);
|
||||||
logger.debug(`type category ${typeCategory}`);
|
logger.debug(`type category ${typeCategory}`);
|
||||||
switch (typeCategory) {
|
switch (typeCategory) {
|
||||||
@ -183,7 +183,7 @@ const handleTypesPurchase = async (typesName: string, accountId: string) => {
|
|||||||
case "SlotItems":
|
case "SlotItems":
|
||||||
return await handleSlotPurchase(typesName, accountId);
|
return await handleSlotPurchase(typesName, accountId);
|
||||||
case "Items":
|
case "Items":
|
||||||
return await handleMiscItemPurchase(typesName, accountId);
|
return await handleMiscItemPurchase(typesName, accountId, quantity);
|
||||||
default:
|
default:
|
||||||
throw new Error(`unknown Types category: ${typeCategory} not implemented or new`);
|
throw new Error(`unknown Types category: ${typeCategory} not implemented or new`);
|
||||||
}
|
}
|
||||||
@ -238,12 +238,12 @@ const handleBoostersPurchase = async (boosterStoreName: string, accountId: strin
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMiscItemPurchase = async (uniqueName: string, accountId: string) => {
|
const handleMiscItemPurchase = async (uniqueName: string, accountId: string, quantity: number) => {
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const miscItemChanges = [
|
const miscItemChanges = [
|
||||||
{
|
{
|
||||||
ItemType: uniqueName,
|
ItemType: uniqueName,
|
||||||
ItemCount: 1
|
ItemCount: quantity
|
||||||
} satisfies IMiscItem
|
} satisfies IMiscItem
|
||||||
];
|
];
|
||||||
addMiscItems(inventory, miscItemChanges);
|
addMiscItems(inventory, miscItemChanges);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user