返回提交历史
Modified
package-lock.json
+4
-4
Modified
package.json
+1
-1
Modified
src/services/purchaseService.ts
+11
-4
XFEstudio/SpaceNinjaServer
improve: handle purchase quantity of gear items (#389)
Co-authored-by: Sainan <Sainan@users.noreply.github.com>
d3004b19
代码差异
3 个文件
+16
-9
@@ -12,7 +12,7 @@
12
12
"copyfiles": "^2.4.1",
13
13
"express": "^5.0.0-beta.3",
14
14
"mongoose": "^8.1.1",
15
"warframe-public-export-plus": "^0.3.2",
15
"warframe-public-export-plus": "^0.3.3",
16
16
"warframe-riven-info": "^0.1.0",
17
17
"winston": "^3.11.0",
18
18
"winston-daily-rotate-file": "^4.7.1"
@@ -3669,9 +3669,9 @@
3669
3669
}
3670
3670
},
3671
3671
"node_modules/warframe-public-export-plus": {
3672
"version": "0.3.2",
3673
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.3.2.tgz",
3674
"integrity": "sha512-0jAStLLrMaz0zm7wfY1/3SWLPmMJcYNNErVTPo8YqBZlot1aikVuDNu+crVmN+LWDDLrn01T7f83EYaw7TYo6w=="
3672
"version": "0.3.3",
3673
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.3.3.tgz",
3674
"integrity": "sha512-35pSMqXxe9vG4kdA+SnCyZyWO8zRGuPQbNeOPgZm5886kiujR+Qd6iY7TH0fdQYgKCk1M+q8lXonATT9VB9bbQ=="
3675
3675
},
3676
3676
"node_modules/warframe-riven-info": {
3677
3677
"version": "0.1.0",
@@ -16,7 +16,7 @@
16
16
"copyfiles": "^2.4.1",
17
17
"express": "^5.0.0-beta.3",
18
18
"mongoose": "^8.1.1",
19
"warframe-public-export-plus": "^0.3.2",
19
"warframe-public-export-plus": "^0.3.3",
20
20
"warframe-riven-info": "^0.1.0",
21
21
"winston": "^3.11.0",
22
22
"winston-daily-rotate-file": "^4.7.1"
@@ -3,7 +3,7 @@ import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers";
3
3
import { addItem, addBooster, updateCurrency, updateSlots } from "@/src/services/inventoryService";
4
4
import { IPurchaseRequest, SlotPurchase, IInventoryChanges, IBinChanges } from "@/src/types/purchaseTypes";
5
5
import { logger } from "@/src/utils/logger";
6
import { ExportBundles, TRarity } from "warframe-public-export-plus";
6
import { ExportBundles, ExportGear, TRarity } from "warframe-public-export-plus";
7
7
8
8
export const getStoreItemCategory = (storeItem: string) => {
9
9
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
@@ -75,7 +75,8 @@ const handleStoreItemAcquisition = async (
75
75
storeItemName: string,
76
76
accountId: string,
77
77
quantity: number,
78
durability: TRarity
78
durability: TRarity,
79
ignorePurchaseQuantity: boolean = false
79
80
): Promise<{ InventoryChanges: IInventoryChanges }> => {
80
81
let purchaseResponse = {
81
82
InventoryChanges: {}
@@ -92,7 +93,8 @@ const handleStoreItemAcquisition = async (
92
93
component.typeName,
93
94
accountId,
94
95
component.purchaseQuantity * quantity,
95
component.durability
96
component.durability,
97
true
96
98
)
97
99
).InventoryChanges
98
100
);
@@ -101,9 +103,14 @@ const handleStoreItemAcquisition = async (
101
103
const storeCategory = getStoreItemCategory(storeItemName);
102
104
const internalName = storeItemName.replace("/StoreItems", "");
103
105
logger.debug(`store category ${storeCategory}`);
106
if (!ignorePurchaseQuantity) {
107
if (internalName in ExportGear) {
108
quantity *= ExportGear[internalName].purchaseQuantity || 1;
109
}
110
}
104
111
switch (storeCategory) {
105
112
default:
106
purchaseResponse = await addItem(accountId, internalName);
113
purchaseResponse = await addItem(accountId, internalName, quantity);
107
114
break;
108
115
case "Types":
109
116
purchaseResponse = await handleTypesPurchase(internalName, accountId, quantity);