返回提交历史
Modified
src/controllers/api/tradingController.ts
+36
-7
Modified
src/controllers/custom/setAccountCheatController.ts
+5
-1
Modified
src/models/tradingModel.ts
+19
-2
Modified
src/services/importService.ts
+4
-4
Modified
src/types/tradingTypes.ts
+4
-0
XFEstudio/XFESpaceNinjaServer
feat: syndicate weapon trading (#4196)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4196 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
1df121ff
代码差异
5 个文件
+68
-14
@@ -4,7 +4,9 @@ import {
4
4
addMiscItem,
5
5
addMods,
6
6
addRecipes,
7
freeUpSlot,
7
8
getInventory2,
9
occupySlot,
8
10
updateCredits,
9
11
updatePlatinum
10
12
} from "../../services/inventoryService.ts";
@@ -14,16 +16,17 @@ import type { RequestHandler } from "express";
14
16
import type { IPendingTradeDatabase, ITradeOffer } from "../../types/tradingTypes.ts";
15
17
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
16
18
import { logger } from "../../utils/logger.ts";
17
import { fromMongoDate, version_compare } from "../../helpers/inventoryHelpers.ts";
19
import { fromMongoDate, fromOid, version_compare } from "../../helpers/inventoryHelpers.ts";
18
20
import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
19
21
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
20
import { importUpgrade } from "../../services/importService.ts";
22
import { importEquipment, importUpgrade } from "../../services/importService.ts";
21
23
import { Guild } from "../../models/guildModel.ts";
22
24
import { ExportArcanes, ExportResources, ExportUpgrades, type TRarity } from "warframe-public-export-plus";
23
25
import { getInfNodes, getNemesisManifest } from "../../helpers/nemesisHelpers.ts";
24
26
import { PendingTrade } from "../../models/tradingModel.ts";
25
27
import type { HydratedDocument, QueryFilter } from "mongoose";
26
28
import { exportTrade } from "../../services/tradingService.ts";
29
import { eInventorySlot } from "../../types/inventoryTypes/inventoryTypes.ts";
27
30
28
31
export const tradingController: RequestHandler = async (req, res) => {
29
32
const account = await getAccountForRequest(req);
@@ -83,6 +86,10 @@ export const tradingController: RequestHandler = async (req, res) => {
83
86
"RawUpgrades",
84
87
"MiscItems",
85
88
"Recipes",
89
"LongGuns",
90
"Pistols",
91
"Melee",
92
"WeaponBin",
86
93
"HybridFusionTreasures",
87
94
"NemesisHistory",
88
95
"Nemesis",
@@ -101,6 +108,10 @@ export const tradingController: RequestHandler = async (req, res) => {
101
108
"RawUpgrades",
102
109
"MiscItems",
103
110
"Recipes",
111
"LongGuns",
112
"Pistols",
113
"Melee",
114
"WeaponBin",
104
115
"HybridFusionTreasures",
105
116
"NemesisHistory",
106
117
"Nemesis",
@@ -223,6 +234,10 @@ const applyOfferToInventory = (
223
234
| "RawUpgrades"
224
235
| "MiscItems"
225
236
| "Recipes"
237
| "LongGuns"
238
| "Pistols"
239
| "Melee"
240
| "WeaponBin"
226
241
| "HybridFusionTreasures"
227
242
| "NemesisHistory"
228
243
| "Nemesis"
@@ -236,7 +251,7 @@ const applyOfferToInventory = (
236
251
if (offer.RandomUpgrades) {
237
252
for (const item of offer.RandomUpgrades) {
238
253
if (factor == -1) {
239
inventory.Upgrades.pull({ _id: item.ItemId.$oid });
254
inventory.Upgrades.pull({ _id: fromOid(item.ItemId) });
240
255
} else {
241
256
inventory.Upgrades.push(importUpgrade(item));
242
257
}
@@ -245,7 +260,7 @@ const applyOfferToInventory = (
245
260
if (offer.Upgrades) {
246
261
for (const item of offer.Upgrades) {
247
262
if (factor == -1) {
248
inventory.Upgrades.pull({ _id: item.ItemId.$oid });
263
inventory.Upgrades.pull({ _id: fromOid(item.ItemId) });
249
264
} else {
250
265
inventory.Upgrades.push(importUpgrade(item));
251
266
}
@@ -283,6 +298,19 @@ const applyOfferToInventory = (
283
298
}
284
299
}
285
300
}
301
for (const key of ["LongGuns", "Pistols", "Melee"] as const) {
302
if (offer[key]) {
303
for (const item of offer[key]) {
304
if (factor == 1) {
305
inventory[key].push(importEquipment(item));
306
occupySlot(inventory, eInventorySlot.WEAPONS, false);
307
} else {
308
inventory[key].pull({ _id: fromOid(item.ItemId) });
309
freeUpSlot(inventory, eInventorySlot.WEAPONS);
310
}
311
}
312
}
313
}
286
314
if (offer.FusionTreasures) {
287
315
if (factor == 1) {
288
316
addFusionTreasures(inventory, offer.FusionTreasures);
@@ -384,9 +412,10 @@ const calcuateTax = (offer: ITradeOffer): number => {
384
412
}
385
413
}
386
414
}
387
if (offer.Recipes) {
388
tax += offer.Recipes.length * 2000;
389
}
415
tax += (offer.Recipes?.length ?? 0) * 2000;
416
tax += (offer.LongGuns?.length ?? 0) * 2000;
417
tax += (offer.Pistols?.length ?? 0) * 2000;
418
tax += (offer.Melee?.length ?? 0) * 2000;
390
419
if (offer.FusionTreasures) {
391
420
for (const item of offer.FusionTreasures) {
392
421
tax += item.ItemCount * (item.Sockets ? 12000 : 4000);
@@ -54,7 +54,11 @@ export const setAccountCheatController: RequestHandler = async (req, res) => {
54
54
if (["infiniteCredits", "infinitePlatinum", "infiniteEndo", "infiniteRegalAya"].indexOf(payload.key) != -1) {
55
55
// Game and all webui tabs need to refresh the inventory
56
56
sendWsBroadcastTo(account._id.toString(), { update_inventory: true, sync_inventory: true });
57
} else if (["infiniteTrades", "infiniteGifts", "skipAllDialogue", "skipAllPopups"].indexOf(payload.key) != -1) {
57
} else if (
58
["infiniteTrades", "infiniteGifts", "skipAllDialogue", "skipAllPopups", "spoofMasteryRank"].indexOf(
59
payload.key
60
) != -1
61
) {
58
62
// Only game and other webui tabs need to refresh the inventory
59
63
sendWsBroadcastEx(
60
64
{ update_inventory: true, sync_inventory: true },
@@ -1,13 +1,30 @@
1
1
import { model, Schema, Types } from "mongoose";
2
2
import type { IPendingTradeDatabase, ITradeOffer } from "../types/tradingTypes.ts";
3
3
4
const tradeOfferSchema = new Schema<ITradeOffer>(
5
{
6
RandomUpgrades: Schema.Types.Mixed,
7
Upgrades: Schema.Types.Mixed,
8
RawUpgrades: Schema.Types.Mixed,
9
MiscItems: Schema.Types.Mixed,
10
Recipes: Schema.Types.Mixed,
11
LongGuns: Schema.Types.Mixed,
12
Pistols: Schema.Types.Mixed,
13
Melee: Schema.Types.Mixed,
14
FusionTreasures: Schema.Types.Mixed,
15
NemesisHistory: Schema.Types.Mixed,
16
PremiumCredits: Number,
17
_SlotOrderInfo: { type: [String] }
18
},
19
{ _id: false }
20
);
4
21
const defaultTradeOffer: ITradeOffer = { _SlotOrderInfo: ["", "", "", "", "", ""] };
5
22
6
23
const pendingTradeSchema = new Schema<IPendingTradeDatabase>({
7
24
a: { type: Types.ObjectId, required: true },
8
25
b: { type: Types.ObjectId, required: true },
9
aOffer: { type: Schema.Types.Mixed, default: defaultTradeOffer },
10
bOffer: { type: Schema.Types.Mixed, default: defaultTradeOffer },
26
aOffer: { type: tradeOfferSchema, default: defaultTradeOffer },
27
bOffer: { type: tradeOfferSchema, default: defaultTradeOffer },
11
28
aReady: { type: Boolean, default: false },
12
29
bReady: { type: Boolean, default: false },
13
30
aAccepted: { type: Boolean, default: false },
@@ -96,7 +96,7 @@ const convertOptionalDate = (value: IMongoDateWithLegacySupport | undefined): Da
96
96
return value ? fromMongoDate(value) : undefined;
97
97
};
98
98
99
const convertEquipment = (client: IEquipmentClient): IEquipmentDatabase | IKubrowPetDatabase => {
99
export const importEquipment = (client: IEquipmentClient): IEquipmentDatabase | IKubrowPetDatabase => {
100
100
const { ItemId, ...rest } = client;
101
101
return {
102
102
...rest,
@@ -210,7 +210,7 @@ export const importCrewShipMembers = (client: ICrewShipMembersClient): ICrewShip
210
210
const convertInfestedFoundry = (client: IInfestedFoundryClient): IInfestedFoundryDatabase => {
211
211
return {
212
212
...client,
213
LastConsumedSuit: client.LastConsumedSuit ? convertEquipment(client.LastConsumedSuit) : undefined,
213
LastConsumedSuit: client.LastConsumedSuit ? importEquipment(client.LastConsumedSuit) : undefined,
214
214
AbilityOverrideUnlockCooldown: convertOptionalDate(client.AbilityOverrideUnlockCooldown)
215
215
};
216
216
};
@@ -310,11 +310,11 @@ const convertPeriodicMissionCompletion = (
310
310
export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
311
311
for (const key of equipmentKeys) {
312
312
if (client[key] !== undefined) {
313
replaceArray<IEquipmentDatabase>(db[key], client[key].map(convertEquipment));
313
replaceArray<IEquipmentDatabase>(db[key], client[key].map(importEquipment));
314
314
}
315
315
}
316
316
if (client.OperatorSuits !== undefined) {
317
replaceArray<IEquipmentDatabase>(db.OperatorSuits, client.OperatorSuits.map(convertEquipment));
317
replaceArray<IEquipmentDatabase>(db.OperatorSuits, client.OperatorSuits.map(importEquipment));
318
318
}
319
319
if (client.WeaponSkins !== undefined) {
320
320
replaceArray<IWeaponSkinDatabase>(db.WeaponSkins, client.WeaponSkins.map(convertWeaponSkin));
@@ -1,6 +1,7 @@
1
1
import type { Types } from "mongoose";
2
2
import type { IOid, ITypeCount } from "./commonTypes.ts";
3
3
import type { IFusionTreasure, INemesisClient, IRawUpgrade, IUpgradeClient } from "./inventoryTypes/inventoryTypes.ts";
4
import type { IEquipmentClient } from "./equipmentTypes.ts";
4
5
5
6
export interface ITradeOffer {
6
7
RandomUpgrades?: IUpgradeClient[];
@@ -8,6 +9,9 @@ export interface ITradeOffer {
8
9
RawUpgrades?: IRawUpgrade[];
9
10
MiscItems?: ITypeCount[];
10
11
Recipes?: ITypeCount[];
12
LongGuns?: IEquipmentClient[];
13
Pistols?: IEquipmentClient[];
14
Melee?: IEquipmentClient[];
11
15
FusionTreasures?: IFusionTreasure[];
12
16
NemesisHistory?: INemesisClient;
13
17
PremiumCredits?: number;