返回提交历史
Modified
src/services/purchaseService.ts
+24
-0
Modified
src/types/vendorTypes.ts
+1
-0
XFEstudio/XFESpaceNinjaServer
fix: handle credits & platinum prices from vendors (#1856)
Fixes #1837 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1856 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
66d1a65e
代码差异
2 个文件
+25
-0
@@ -66,6 +66,18 @@ export const handlePurchase = async (
66
66
if (!offer) {
67
67
throw new Error(`unknown vendor offer: ${ItemId ? ItemId : purchaseRequest.PurchaseParams.StoreItem}`);
68
68
}
69
if (offer.RegularPrice) {
70
combineInventoryChanges(
71
prePurchaseInventoryChanges,
72
updateCurrency(inventory, offer.RegularPrice[0], false)
73
);
74
}
75
if (offer.PremiumPrice) {
76
combineInventoryChanges(
77
prePurchaseInventoryChanges,
78
updateCurrency(inventory, offer.PremiumPrice[0], true)
79
);
80
}
69
81
if (offer.ItemPrices) {
70
82
handleItemPrices(
71
83
inventory,
@@ -170,6 +182,9 @@ export const handlePurchase = async (
170
182
purchaseResponse.InventoryChanges,
171
183
updateCurrency(inventory, offer.RegularPrice, false)
172
184
);
185
if (purchaseRequest.PurchaseParams.ExpectedPrice) {
186
throw new Error(`vendor purchase should not have an expected price`);
187
}
173
188
174
189
const invItem: IMiscItem = {
175
190
ItemType: "/Lotus/Types/Items/MiscItems/PrimeBucks",
@@ -229,6 +244,12 @@ export const handlePurchase = async (
229
244
updateCurrency(inventory, offer.credits, false)
230
245
);
231
246
}
247
if (typeof offer.platinum == "number") {
248
combineInventoryChanges(
249
purchaseResponse.InventoryChanges,
250
updateCurrency(inventory, offer.platinum, true)
251
);
252
}
232
253
if (offer.itemPrices) {
233
254
handleItemPrices(
234
255
inventory,
@@ -239,6 +260,9 @@ export const handlePurchase = async (
239
260
}
240
261
}
241
262
}
263
if (purchaseRequest.PurchaseParams.ExpectedPrice) {
264
throw new Error(`vendor purchase should not have an expected price`);
265
}
242
266
break;
243
267
case 18: {
244
268
if (purchaseRequest.PurchaseParams.SourceId! != worldState.PrimeVaultTraders[0]._id.$oid) {
@@ -10,6 +10,7 @@ export interface IItemManifest {
10
10
StoreItem: string;
11
11
ItemPrices?: IItemPrice[];
12
12
RegularPrice?: number[];
13
PremiumPrice?: number[];
13
14
Bin: string;
14
15
QuantityMultiplier: number;
15
16
Expiry: IMongoDate; // Either a date in the distant future or a period in milliseconds for preprocessing.