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: lich trading (#3244)

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

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

代码差异

2 个文件 +45 -1
Modified src/controllers/api/tradingController.ts +44 -1
@@ -13,12 +13,13 @@ import type { RequestHandler } from "express";
13 13 import type { IPendingTrade, ITradeOffer } from "../../types/inventoryTypes/inventoryTypes.ts";
14 14 import { getJSONfromString } from "../../helpers/stringHelpers.ts";
15 15 import { logger } from "../../utils/logger.ts";
16 import { version_compare } from "../../helpers/inventoryHelpers.ts";
16 import { fromMongoDate, version_compare } from "../../helpers/inventoryHelpers.ts";
17 17 import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
18 18 import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
19 19 import { importUpgrade } from "../../services/importService.ts";
20 20 import { Guild } from "../../models/guildModel.ts";
21 21 import { ExportArcanes, ExportResources, ExportUpgrades, type TRarity } from "warframe-public-export-plus";
22 import { getInfNodes, getNemesisManifest } from "../../helpers/nemesisHelpers.ts";
22 23
23 24 export const tradingController: RequestHandler = async (req, res) => {
24 25 const account = await getAccountForRequest(req);
@@ -251,6 +252,45 @@ const applyOfferToInventory = (inventory: TInventoryDatabaseDocument, offer: ITr
251 252 }
252 253 }
253 254 }
255 if (offer.NemesisHistory) {
256 inventory.NemesisHistory ??= [];
257 if (factor == 1) {
258 if (inventory.Nemesis) {
259 logger.warn(`overwriting an existing nemesis as a new one is being requested`);
260 }
261 const manifest = getNemesisManifest(offer.NemesisHistory.manifest);
262 inventory.Nemesis = {
263 fp: BigInt(offer.NemesisHistory.fp),
264 manifest: offer.NemesisHistory.manifest,
265 KillingSuit: offer.NemesisHistory.KillingSuit,
266 killingDamageType: offer.NemesisHistory.killingDamageType,
267 ShoulderHelmet: offer.NemesisHistory.ShoulderHelmet,
268 WeaponIdx: offer.NemesisHistory.WeaponIdx,
269 AgentIdx: offer.NemesisHistory.AgentIdx,
270 BirthNode: offer.NemesisHistory.BirthNode,
271 Faction: offer.NemesisHistory.Faction,
272 Rank: 0,
273 k: false,
274 Traded: true,
275 d: fromMongoDate(offer.NemesisHistory.d),
276 InfNodes: getInfNodes(manifest, 0),
277 GuessHistory: [],
278 Hints: [],
279 HintProgress: 0,
280 Weakened: false,
281 PrevOwners: offer.NemesisHistory.PrevOwners + 1,
282 HenchmenKilled: 0,
283 SecondInCommand: false,
284 MissionCount: 0,
285 LastEnc: 0
286 };
287 } else {
288 const i = inventory.NemesisHistory.findIndex(x => x.fp == BigInt(offer.NemesisHistory!.fp));
289 if (i != -1) {
290 inventory.NemesisHistory.splice(i, 1);
291 }
292 }
293 }
254 294 if (offer.PremiumCredits) {
255 295 if (offer.PremiumCredits < 0) {
256 296 throw new Error(`negative quantity in trade offer`);
@@ -309,6 +349,9 @@ const calcuateTax = (offer: ITradeOffer): number => {
309 349 tax += item.ItemCount * (item.Sockets ? 12000 : 4000);
310 350 }
311 351 }
352 if (offer.NemesisHistory) {
353 tax += 8000;
354 }
312 355 tax += (offer.PremiumCredits ?? 0) * 500;
313 356 return tax;
314 357 };
Modified src/types/inventoryTypes/inventoryTypes.ts +1 -0
@@ -948,6 +948,7 @@ export interface ITradeOffer {
948 948 MiscItems?: IMiscItem[];
949 949 Recipes?: ITypeCount[];
950 950 FusionTreasures?: IFusionTreasure[];
951 NemesisHistory?: INemesisClient;
951 952 PremiumCredits?: number;
952 953 _SlotOrderInfo: string[];
953 954 }