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

SpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/SpaceNinjaServer

chore: use inventory projection in getVendorInfo (#3177)

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

334fcc2e
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

3 个文件 +7 -7
Modified src/controllers/api/getVendorInfoController.ts +2 -2
@@ -13,8 +13,8 @@ export const getVendorInfoController: RequestHandler = async (req, res) => {
13 13 // For testing purposes, authenticating with this endpoint is optional here, but would be required on live.
14 14 if (req.query.accountId) {
15 15 const accountId = await getAccountIdForRequest(req);
16 const inventory = await getInventory(accountId);
17 manifest = applyStandingToVendorManifest(inventory, manifest);
16 const inventory = await getInventory(accountId, "Affiliations");
17 manifest = applyStandingToVendorManifest(manifest, inventory.Affiliations);
18 18 if (config.dev?.keepVendorsExpired) {
19 19 manifest = {
20 20 VendorInfo: {
Modified src/services/purchaseService.ts +1 -1
@@ -116,7 +116,7 @@ export const handlePurchase = async (
116 116 if (purchaseRequest.PurchaseParams.Source == PurchaseSource.Vendor) {
117 117 let manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
118 118 if (manifest) {
119 manifest = applyStandingToVendorManifest(inventory, manifest);
119 manifest = applyStandingToVendorManifest(manifest, inventory.Affiliations);
120 120 let ItemId: string | undefined;
121 121 if (purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson) {
122 122 ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson) as { ItemId: string })
Modified src/services/serversideVendorsService.ts +4 -4
@@ -1,13 +1,13 @@
1 1 import { unixTimesInMs } from "../constants/timeConstants.ts";
2 2 import { args } from "../helpers/commandLineArguments.ts";
3 3 import { catBreadHash } from "../helpers/stringHelpers.ts";
4 import type { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel.ts";
5 4 import { mixSeeds, SRng } from "./rngService.ts";
6 5 import type { IItemManifest, IVendorInfo, IVendorManifest } from "../types/vendorTypes.ts";
7 6 import { logger } from "../utils/logger.ts";
8 7 import type { IRange, IVendor, IVendorOffer } from "warframe-public-export-plus";
9 8 import { ExportVendors } from "warframe-public-export-plus";
10 9 import { config } from "./configService.ts";
10 import type { IAffiliation } from "../types/inventoryTypes/inventoryTypes.ts";
11 11
12 12 interface IGeneratableVendorInfo extends Omit<IVendorInfo, "ItemManifest" | "Expiry"> {
13 13 cycleOffset?: number;
@@ -106,15 +106,15 @@ export const getVendorManifestByOid = (oid: string): IVendorManifest | undefined
106 106 };
107 107
108 108 export const applyStandingToVendorManifest = (
109 inventory: TInventoryDatabaseDocument,
110 vendorManifest: IVendorManifest
109 vendorManifest: IVendorManifest,
110 affiliations: IAffiliation[]
111 111 ): IVendorManifest => {
112 112 return {
113 113 VendorInfo: {
114 114 ...vendorManifest.VendorInfo,
115 115 ItemManifest: [...vendorManifest.VendorInfo.ItemManifest].map(offer => {
116 116 if (offer.Affiliation && offer.ReductionPerPositiveRank && offer.IncreasePerNegativeRank) {
117 const title: number = inventory.Affiliations.find(x => x.Tag == offer.Affiliation)?.Title ?? 0;
117 const title: number = affiliations.find(x => x.Tag == offer.Affiliation)?.Title ?? 0;
118 118 const factor =
119 119 1 + (title < 0 ? offer.IncreasePerNegativeRank : offer.ReductionPerPositiveRank) * title * -1;
120 120 //console.log(offer.Affiliation, title, factor);