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

feat: vendor syndicate discounts & standing costs (#3351)

Closes #3347 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3351 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

2f4ec5c3
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

5 个文件 +51 -9
Modified package-lock.json +4 -4
@@ -18,7 +18,7 @@
18 18 "morgan": "^1.10.0",
19 19 "ncp": "^2.0.0",
20 20 "undici": "^7.10.0",
21 "warframe-public-export-plus": "^0.5.99",
21 "warframe-public-export-plus": "^0.5.100",
22 22 "warframe-riven-info": "^0.1.2",
23 23 "winston": "^3.17.0",
24 24 "winston-daily-rotate-file": "^5.0.0",
@@ -3964,9 +3964,9 @@
3964 3964 }
3965 3965 },
3966 3966 "node_modules/warframe-public-export-plus": {
3967 "version": "0.5.99",
3968 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.99.tgz",
3969 "integrity": "sha512-9z1bGuvO/evRJPbyeY1/w6PRT+dnpW6EgcXlB1FrAtt5K1yZVwSj11jn/EbeU4j6IGDd485c3QBszHsMPLb7hA=="
3967 "version": "0.5.100",
3968 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.100.tgz",
3969 "integrity": "sha512-WQAxD+wxhOKdFXWL6pD3dbnnMGAZQXgrVx6JLKCVQAr7nchE9dAGXJ84P+gI/ab5BECtIwDuZ5cT8dwPSjDIHg=="
3970 3970 },
3971 3971 "node_modules/warframe-riven-info": {
3972 3972 "version": "0.1.2",
Modified package.json +1 -1
@@ -35,7 +35,7 @@
35 35 "morgan": "^1.10.0",
36 36 "ncp": "^2.0.0",
37 37 "undici": "^7.10.0",
38 "warframe-public-export-plus": "^0.5.99",
38 "warframe-public-export-plus": "^0.5.100",
39 39 "warframe-riven-info": "^0.1.2",
40 40 "winston": "^3.17.0",
41 41 "winston-daily-rotate-file": "^5.0.0",
Modified src/services/purchaseService.ts +39 -3
@@ -311,6 +311,9 @@ export const handlePurchase = async (
311 311 await handleDailyDealPurchase(inventory, purchaseRequest.PurchaseParams, purchaseResponse);
312 312 break;
313 313 case PurchaseSource.Vendor:
314 if (purchaseRequest.PurchaseParams.ExpectedPrice) {
315 throw new Error(`vendor purchase should not have an expected price`);
316 }
314 317 if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {
315 318 const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!];
316 319 const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
@@ -330,9 +333,42 @@ export const handlePurchase = async (
330 333 );
331 334 }
332 335 }
333 }
334 if (purchaseRequest.PurchaseParams.ExpectedPrice) {
335 throw new Error(`vendor purchase should not have an expected price`);
336 } else {
337 let manifest = getVendorManifestByOid(
338 purchaseRequest.PurchaseParams.SourceId!,
339 purchaseRequest.buildLabel
340 );
341 if (manifest) {
342 manifest = applyStandingToVendorManifest(manifest, inventory.Affiliations);
343 let ItemId: string | undefined;
344 if (purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson) {
345 ItemId = (
346 JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson) as { ItemId: string }
347 ).ItemId;
348 }
349 const offer = ItemId
350 ? manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId)
351 : manifest.VendorInfo.ItemManifest.find(
352 x => x.StoreItem == purchaseRequest.PurchaseParams.StoreItem
353 );
354 if (!offer) {
355 throw new Error(
356 `unknown vendor offer: ${ItemId ? ItemId : purchaseRequest.PurchaseParams.StoreItem}`
357 );
358 }
359 if (offer.StandingCost && !inventory.dontSubtractPurchaseStandingCost) {
360 const affiliation = inventory.Affiliations.find(x => x.Tag == offer.Affiliation!);
361 if (affiliation) {
362 purchaseResponse.Standing = [
363 {
364 Tag: offer.Affiliation!,
365 Standing: offer.StandingCost * purchaseRequest.PurchaseParams.Quantity
366 }
367 ];
368 affiliation.Standing -= offer.StandingCost * purchaseRequest.PurchaseParams.Quantity;
369 }
370 }
371 }
336 372 }
337 373 break;
338 374 case PurchaseSource.PrimeVaultTrader: {
Modified src/services/serversideVendorsService.ts +5 -0
@@ -399,6 +399,11 @@ const generateVendorManifest = (
399 399 Expiry: { $date: { $numberLong: expiry.toString() } },
400 400 PurchaseQuantityLimit: rawItem.purchaseLimit,
401 401 RotatedWeekly: rawItem.rotatedWeekly,
402 Affiliation: rawItem.syndicate?.tag,
403 MinAffiliationRank: rawItem.syndicate?.minRank,
404 ReductionPerPositiveRank: rawItem.syndicate?.reductionPerPositiveRank,
405 IncreasePerNegativeRank: rawItem.syndicate?.increasePerNegativeRank,
406 StandingCost: rawItem.syndicate?.standingCost,
402 407 AllowMultipurchase: rawItem.purchaseLimit !== 1,
403 408 Id: {
404 409 $oid:
Modified src/types/vendorTypes.ts +2 -1
@@ -15,11 +15,12 @@ export interface IItemManifest {
15 15 QuantityMultiplier: number;
16 16 Expiry: IMongoDate; // Either a date in the distant future or a period in milliseconds for preprocessing.
17 17 PurchaseQuantityLimit?: number;
18 RotatedWeekly?: boolean;
18 19 Affiliation?: string;
19 20 MinAffiliationRank?: number;
20 21 ReductionPerPositiveRank?: number;
21 22 IncreasePerNegativeRank?: number;
22 RotatedWeekly?: boolean;
23 StandingCost?: number;
23 24 AllowMultipurchase: boolean;
24 25 LocTagRandSeed?: number | bigint;
25 26 Id: IOid;