返回提交历史
Modified
src/controllers/api/nemesisController.ts
+18
-1
Modified
src/models/inventoryModels/inventoryModel.ts
+4
-1
Modified
src/services/importService.ts
+26
-2
Modified
src/types/inventoryTypes/inventoryTypes.ts
+3
-1
XFEstudio/SpaceNinjaServer
feat: nemesis mode t / LastNemesisAllySpawnTime (#2869)
Also some import stuff. Closes #2867 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2869 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
af6f422f
代码差异
4 个文件
+51
-5
@@ -1,4 +1,4 @@
1
import { fromDbOid, version_compare } from "../../helpers/inventoryHelpers.ts";
1
import { fromDbOid, toMongoDate, version_compare } from "../../helpers/inventoryHelpers.ts";
2
2
import type { IKnifeResponse } from "../../helpers/nemesisHelpers.ts";
3
3
import {
4
4
antivirusMods,
@@ -310,6 +310,15 @@ export const nemesisController: RequestHandler = async (req, res) => {
310
310
res.json({
311
311
target: inventory.toJSON().Nemesis
312
312
});
313
} else if ((req.query.mode as string) == "t") {
314
const inventory = await getInventory(account._id.toString(), "LastNemesisAllySpawnTime");
315
//const body = getJSONfromString<IUpdateAllySpawnTimeRequest>(String(req.body));
316
const now = new Date(Math.trunc(Date.now() / 1000) * 1000);
317
inventory.LastNemesisAllySpawnTime = now;
318
await inventory.save();
319
res.json({
320
NewTime: toMongoDate(now)
321
} satisfies IUpdateAllySpawnTimeResponse);
313
322
} else if ((req.query.mode as string) == "d") {
314
323
const inventory = await getInventory(account._id.toString(), "NemesisHistory");
315
324
const body = getJSONfromString<IRelinquishAdversariesRequest>(String(req.body));
@@ -462,3 +471,11 @@ const consumeModCharge = (
462
471
interface IRelinquishAdversariesRequest {
463
472
nemesisFingerprints: (bigint | number)[];
464
473
}
474
475
// interface IUpdateAllySpawnTimeRequest {
476
// LastSpawnTime: IMongoDate;
477
// }
478
479
interface IUpdateAllySpawnTimeResponse {
480
NewTime: IMongoDate;
481
}
@@ -1743,7 +1743,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1743
1743
NemesisAbandonedRewards: { type: [String], default: [] },
1744
1744
Nemesis: nemesisSchema,
1745
1745
NemesisHistory: { type: [nemesisSchema], default: undefined },
1746
//LastNemesisAllySpawnTime: Schema.Types.Mixed,
1746
LastNemesisAllySpawnTime: { type: Date, default: undefined },
1747
1747
1748
1748
//TradingRulesConfirmed,ShowFriendInvNotifications(Option->Social)
1749
1749
Settings: settingsSchema,
@@ -1864,6 +1864,9 @@ inventorySchema.set("toJSON", {
1864
1864
if (inventoryDatabase.BlessingCooldown) {
1865
1865
inventoryResponse.BlessingCooldown = toMongoDate(inventoryDatabase.BlessingCooldown);
1866
1866
}
1867
if (inventoryDatabase.LastNemesisAllySpawnTime) {
1868
inventoryResponse.LastNemesisAllySpawnTime = toMongoDate(inventoryDatabase.LastNemesisAllySpawnTime);
1869
}
1867
1870
if (inventoryDatabase.NextRefill) {
1868
1871
inventoryResponse.NextRefill = toMongoDate(inventoryDatabase.NextRefill);
1869
1872
}
@@ -73,6 +73,7 @@ import type {
73
73
ITailorShop,
74
74
ITailorShopDatabase
75
75
} from "../types/personalRoomsTypes.ts";
76
import { fromMongoDate } from "../helpers/inventoryHelpers.ts";
76
77
77
78
const convertDate = (value: IMongoDate): Date => {
78
79
return new Date(parseInt(value.$date.$numberLong));
@@ -326,7 +327,14 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
326
327
"GiftsRemaining",
327
328
"ChallengesFixVersion",
328
329
"Founder",
329
"Guide"
330
"Guide",
331
"EntratiVaultCountLastPeriod",
332
"EntratiLabConquestUnlocked",
333
"EntratiLabConquestHardModeStatus",
334
"EntratiLabConquestCacheScoreMission",
335
"EchoesHexConquestUnlocked",
336
"EchoesHexConquestHardModeStatus",
337
"EchoesHexConquestCacheScoreMission"
330
338
] as const) {
331
339
if (client[key] !== undefined) {
332
340
db[key] = client[key];
@@ -354,12 +362,28 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
354
362
"NodeIntrosCompleted",
355
363
"DeathMarks",
356
364
"Wishlist",
357
"NemesisAbandonedRewards"
365
"NemesisAbandonedRewards",
366
"EntratiLabConquestActiveFrameVariants",
367
"EchoesHexConquestActiveFrameVariants",
368
"EchoesHexConquestActiveStickers"
358
369
] as const) {
359
370
if (client[key] !== undefined) {
360
371
db[key] = client[key];
361
372
}
362
373
}
374
// IMongoDate
375
for (const key of [
376
"Created",
377
"TrainingDate",
378
"BlessingCooldown",
379
"LastNemesisAllySpawnTime",
380
"NextRefill",
381
"EntratiVaultCountResetDate"
382
] as const) {
383
if (client[key] !== undefined) {
384
db[key] = fromMongoDate(client[key]);
385
}
386
}
363
387
// IRewardAtten[]
364
388
for (const key of ["SortieRewardAttenuation", "SpecialItemRewardAttenuation"] as const) {
365
389
if (client[key] !== undefined) {
@@ -92,6 +92,7 @@ export interface IInventoryDatabase
92
92
| "NextRefill"
93
93
| "Nemesis"
94
94
| "NemesisHistory"
95
| "LastNemesisAllySpawnTime"
95
96
| "EntratiVaultCountResetDate"
96
97
| "BrandedSuits"
97
98
| "LockedWeaponGroup"
@@ -136,6 +137,7 @@ export interface IInventoryDatabase
136
137
NextRefill?: Date;
137
138
Nemesis?: INemesisDatabase;
138
139
NemesisHistory?: INemesisBaseDatabase[];
140
LastNemesisAllySpawnTime?: Date;
139
141
EntratiVaultCountResetDate?: Date;
140
142
BrandedSuits?: Types.ObjectId[];
141
143
LockedWeaponGroup?: ILockedWeaponGroupDatabase;
@@ -372,7 +374,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
372
374
//InvasionChainProgress: IInvasionChainProgress[];
373
375
Nemesis?: INemesisClient;
374
376
NemesisHistory?: INemesisBaseClient[];
375
//LastNemesisAllySpawnTime?: IMongoDate;
377
LastNemesisAllySpawnTime?: IMongoDate;
376
378
Settings?: ISettings;
377
379
PersonalTechProjects: IPersonalTechProjectClient[];
378
380
PlayerSkills: IPlayerSkills;