improve: handle purchase quantity of gear items (#389)
Co-authored-by: Sainan <Sainan@users.noreply.github.com>
This commit is contained in:
parent
887d4eb952
commit
d3004b19dd
8
package-lock.json
generated
8
package-lock.json
generated
@ -12,7 +12,7 @@
|
|||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^5.0.0-beta.3",
|
"express": "^5.0.0-beta.3",
|
||||||
"mongoose": "^8.1.1",
|
"mongoose": "^8.1.1",
|
||||||
"warframe-public-export-plus": "^0.3.2",
|
"warframe-public-export-plus": "^0.3.3",
|
||||||
"warframe-riven-info": "^0.1.0",
|
"warframe-riven-info": "^0.1.0",
|
||||||
"winston": "^3.11.0",
|
"winston": "^3.11.0",
|
||||||
"winston-daily-rotate-file": "^4.7.1"
|
"winston-daily-rotate-file": "^4.7.1"
|
||||||
@ -3669,9 +3669,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/warframe-public-export-plus": {
|
"node_modules/warframe-public-export-plus": {
|
||||||
"version": "0.3.2",
|
"version": "0.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.3.3.tgz",
|
||||||
"integrity": "sha512-0jAStLLrMaz0zm7wfY1/3SWLPmMJcYNNErVTPo8YqBZlot1aikVuDNu+crVmN+LWDDLrn01T7f83EYaw7TYo6w=="
|
"integrity": "sha512-35pSMqXxe9vG4kdA+SnCyZyWO8zRGuPQbNeOPgZm5886kiujR+Qd6iY7TH0fdQYgKCk1M+q8lXonATT9VB9bbQ=="
|
||||||
},
|
},
|
||||||
"node_modules/warframe-riven-info": {
|
"node_modules/warframe-riven-info": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^5.0.0-beta.3",
|
"express": "^5.0.0-beta.3",
|
||||||
"mongoose": "^8.1.1",
|
"mongoose": "^8.1.1",
|
||||||
"warframe-public-export-plus": "^0.3.2",
|
"warframe-public-export-plus": "^0.3.3",
|
||||||
"warframe-riven-info": "^0.1.0",
|
"warframe-riven-info": "^0.1.0",
|
||||||
"winston": "^3.11.0",
|
"winston": "^3.11.0",
|
||||||
"winston-daily-rotate-file": "^4.7.1"
|
"winston-daily-rotate-file": "^4.7.1"
|
||||||
|
@ -3,7 +3,7 @@ import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers";
|
|||||||
import { addItem, addBooster, updateCurrency, updateSlots } from "@/src/services/inventoryService";
|
import { addItem, addBooster, updateCurrency, updateSlots } from "@/src/services/inventoryService";
|
||||||
import { IPurchaseRequest, SlotPurchase, IInventoryChanges, IBinChanges } from "@/src/types/purchaseTypes";
|
import { IPurchaseRequest, SlotPurchase, IInventoryChanges, IBinChanges } from "@/src/types/purchaseTypes";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { ExportBundles, TRarity } from "warframe-public-export-plus";
|
import { ExportBundles, ExportGear, TRarity } from "warframe-public-export-plus";
|
||||||
|
|
||||||
export const getStoreItemCategory = (storeItem: string) => {
|
export const getStoreItemCategory = (storeItem: string) => {
|
||||||
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
|
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
|
||||||
@ -75,7 +75,8 @@ const handleStoreItemAcquisition = async (
|
|||||||
storeItemName: string,
|
storeItemName: string,
|
||||||
accountId: string,
|
accountId: string,
|
||||||
quantity: number,
|
quantity: number,
|
||||||
durability: TRarity
|
durability: TRarity,
|
||||||
|
ignorePurchaseQuantity: boolean = false
|
||||||
): Promise<{ InventoryChanges: IInventoryChanges }> => {
|
): Promise<{ InventoryChanges: IInventoryChanges }> => {
|
||||||
let purchaseResponse = {
|
let purchaseResponse = {
|
||||||
InventoryChanges: {}
|
InventoryChanges: {}
|
||||||
@ -92,7 +93,8 @@ const handleStoreItemAcquisition = async (
|
|||||||
component.typeName,
|
component.typeName,
|
||||||
accountId,
|
accountId,
|
||||||
component.purchaseQuantity * quantity,
|
component.purchaseQuantity * quantity,
|
||||||
component.durability
|
component.durability,
|
||||||
|
true
|
||||||
)
|
)
|
||||||
).InventoryChanges
|
).InventoryChanges
|
||||||
);
|
);
|
||||||
@ -101,9 +103,14 @@ const handleStoreItemAcquisition = async (
|
|||||||
const storeCategory = getStoreItemCategory(storeItemName);
|
const storeCategory = getStoreItemCategory(storeItemName);
|
||||||
const internalName = storeItemName.replace("/StoreItems", "");
|
const internalName = storeItemName.replace("/StoreItems", "");
|
||||||
logger.debug(`store category ${storeCategory}`);
|
logger.debug(`store category ${storeCategory}`);
|
||||||
|
if (!ignorePurchaseQuantity) {
|
||||||
|
if (internalName in ExportGear) {
|
||||||
|
quantity *= ExportGear[internalName].purchaseQuantity || 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (storeCategory) {
|
switch (storeCategory) {
|
||||||
default:
|
default:
|
||||||
purchaseResponse = await addItem(accountId, internalName);
|
purchaseResponse = await addItem(accountId, internalName, quantity);
|
||||||
break;
|
break;
|
||||||
case "Types":
|
case "Types":
|
||||||
purchaseResponse = await handleTypesPurchase(internalName, accountId, quantity);
|
purchaseResponse = await handleTypesPurchase(internalName, accountId, quantity);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user