返回提交历史
Modified
package-lock.json
+4
-4
Modified
package.json
+1
-1
Modified
src/services/purchaseService.ts
+40
-3
Modified
src/types/purchaseTypes.ts
+1
-0
XFEstudio/SpaceNinjaServer
fix: purchasing an arcane pack does not consume vosfor (#601)
9fd6ed3b
代码差异
4 个文件
+46
-8
@@ -12,7 +12,7 @@
12
12
"copyfiles": "^2.4.1",
13
13
"express": "^5",
14
14
"mongoose": "^8.9.2",
15
"warframe-public-export-plus": "^0.5.8",
15
"warframe-public-export-plus": "^0.5.9",
16
16
"warframe-riven-info": "^0.1.2",
17
17
"winston": "^3.17.0",
18
18
"winston-daily-rotate-file": "^5.0.0"
@@ -3877,9 +3877,9 @@
3877
3877
}
3878
3878
},
3879
3879
"node_modules/warframe-public-export-plus": {
3880
"version": "0.5.8",
3881
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.8.tgz",
3882
"integrity": "sha512-ZhHrKIkI6nhjKDlxhrNcfN8r2Yc9g+eeKLS6+9w7gzC4NscIt6TU8tH8bfjJTDeo6nRrzt88szX1/Oo3WnUY4Q=="
3880
"version": "0.5.9",
3881
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.9.tgz",
3882
"integrity": "sha512-qwQVtYI7wghatg7UrJ3CFstXba5Hsks398L6ngv16auqoTVAfw/cLBqFv9DzsEpqvcVWL22IZIH+cNWiq1JXOQ=="
3883
3883
},
3884
3884
"node_modules/warframe-riven-info": {
3885
3885
"version": "0.1.2",
@@ -16,7 +16,7 @@
16
16
"copyfiles": "^2.4.1",
17
17
"express": "^5",
18
18
"mongoose": "^8.9.2",
19
"warframe-public-export-plus": "^0.5.8",
19
"warframe-public-export-plus": "^0.5.9",
20
20
"warframe-riven-info": "^0.1.2",
21
21
"winston": "^3.17.0",
22
22
"winston-daily-rotate-file": "^5.0.0"
@@ -1,15 +1,18 @@
1
1
import { parseSlotPurchaseName } from "@/src/helpers/purchaseHelpers";
2
2
import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers";
3
3
import {
4
addItem,
5
4
addBooster,
5
addItem,
6
addMiscItems,
6
7
combineInventoryChanges,
8
getInventory,
7
9
updateCurrency,
8
10
updateSlots
9
11
} from "@/src/services/inventoryService";
12
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
10
13
import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
11
14
import { logger } from "@/src/utils/logger";
12
import { ExportBundles, ExportGear, TRarity } from "warframe-public-export-plus";
15
import { ExportBundles, ExportGear, ExportVendors, TRarity } from "warframe-public-export-plus";
13
16
14
17
export const getStoreItemCategory = (storeItem: string) => {
15
18
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
@@ -43,12 +46,46 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
43
46
purchaseRequest.PurchaseParams.UsePremium,
44
47
accountId
45
48
);
46
47
49
purchaseResponse.InventoryChanges = {
48
50
...currencyChanges,
49
51
...purchaseResponse.InventoryChanges
50
52
};
51
53
54
switch (purchaseRequest.PurchaseParams.Source) {
55
case 7:
56
if (!purchaseRequest.PurchaseParams.SourceId) {
57
throw new Error("invalid request source");
58
}
59
if (ExportVendors[purchaseRequest.PurchaseParams.SourceId]) {
60
const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId];
61
const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
62
if (offer) {
63
const inventory = await getInventory(accountId);
64
for (const item of offer.itemPrices) {
65
const invItem: IMiscItem = {
66
ItemType: item.ItemType,
67
ItemCount: item.ItemCount * -1
68
};
69
70
addMiscItems(inventory, [invItem]);
71
72
purchaseResponse.InventoryChanges.MiscItems ??= [];
73
const change = (purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).find(
74
x => x.ItemType == item.ItemType
75
);
76
if (change) {
77
change.ItemCount -= item.ItemCount;
78
} else {
79
(purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).push(invItem);
80
}
81
}
82
83
await inventory.save();
84
}
85
}
86
break;
87
}
88
52
89
return purchaseResponse;
53
90
};
54
91
@@ -5,6 +5,7 @@ export interface IPurchaseRequest {
5
5
6
6
export interface IPurchaseParams {
7
7
Source: number;
8
SourceId?: string; // for Source 7
8
9
StoreItem: string;
9
10
StorePage: string;
10
11
SearchTerm: string;