XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

fix: only use getPrice for market purchases (#3274)

We know for sure market transactions use credits or platinum in non-zero amounts, so erroring only when the amount is zero here + getPrice can't fill it in either seems more appropriate. Closes #3268 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3274 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

798194df
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +21 -18
Modified src/services/purchaseService.ts +21 -18
@@ -214,25 +214,19 @@ export const handlePurchase = async (
214 214 );
215 215 combineInventoryChanges(purchaseResponse.InventoryChanges, prePurchaseInventoryChanges);
216 216
217 if (!purchaseRequest.PurchaseParams.ExpectedPrice) {
218 logger.debug(`client didn't provide ExpectedPrice, attempt to get it from PE+`);
219 purchaseRequest.PurchaseParams.ExpectedPrice = getPrice(
220 purchaseRequest.PurchaseParams.StoreItem,
221 purchaseRequest.PurchaseParams.Quantity,
222 purchaseRequest.PurchaseParams.Durability,
223 purchaseRequest.PurchaseParams.UsePremium,
224 purchaseRequest.buildLabel
225 );
226 }
227
228 updateCurrency(
229 inventory,
230 purchaseRequest.PurchaseParams.ExpectedPrice,
231 purchaseRequest.PurchaseParams.UsePremium,
232 purchaseResponse.InventoryChanges
233 );
234
235 217 switch (purchaseRequest.PurchaseParams.Source) {
218 case PurchaseSource.Market:
219 if (!purchaseRequest.PurchaseParams.ExpectedPrice) {
220 logger.debug(`client didn't provide ExpectedPrice, attempt to get it from PE+`);
221 purchaseRequest.PurchaseParams.ExpectedPrice = getPrice(
222 purchaseRequest.PurchaseParams.StoreItem,
223 purchaseRequest.PurchaseParams.Quantity,
224 purchaseRequest.PurchaseParams.Durability,
225 purchaseRequest.PurchaseParams.UsePremium,
226 purchaseRequest.buildLabel
227 );
228 }
229 break;
236 230 case PurchaseSource.VoidTrader: {
237 231 const worldState = getWorldState(purchaseRequest.buildLabel);
238 232 if (purchaseRequest.PurchaseParams.SourceId! != worldState.VoidTraders[0]._id.$oid) {
@@ -377,6 +371,15 @@ export const handlePurchase = async (
377 371 }
378 372 }
379 373
374 if (purchaseRequest.PurchaseParams.ExpectedPrice) {
375 updateCurrency(
376 inventory,
377 purchaseRequest.PurchaseParams.ExpectedPrice,
378 purchaseRequest.PurchaseParams.UsePremium,
379 purchaseResponse.InventoryChanges
380 );
381 }
382
380 383 return purchaseResponse;
381 384 };
382 385