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

feat: entratiLabConquestMode.php (#1291)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1291

e0d31b89
Sainan <sainan@calamity.inc>
提交于

代码差异

4 个文件 +96 -1
Added src/controllers/api/entratiLabConquestModeController.ts +69 -0
@@ -0,0 +1,69 @@
1 import { toMongoDate } from "@/src/helpers/inventoryHelpers";
2 import { getJSONfromString } from "@/src/helpers/stringHelpers";
3 import { getInventory } from "@/src/services/inventoryService";
4 import { getAccountIdForRequest } from "@/src/services/loginService";
5 import { RequestHandler } from "express";
6
7 export const entratiLabConquestModeController: RequestHandler = async (req, res) => {
8 const accountId = await getAccountIdForRequest(req);
9 const inventory = await getInventory(
10 accountId,
11 "EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
12 );
13 const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
14 if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
15 const EPOCH = 1734307200 * 1000; // Mondays, amirite?
16 const day = Math.trunc((Date.now() - EPOCH) / 86400000);
17 const week = Math.trunc(day / 7);
18 const weekStart = EPOCH + week * 604800000;
19 const weekEnd = weekStart + 604800000;
20 inventory.EntratiVaultCountLastPeriod = 0;
21 inventory.EntratiVaultCountResetDate = new Date(weekEnd);
22 if (inventory.EntratiLabConquestUnlocked) {
23 inventory.EntratiLabConquestUnlocked = 0;
24 inventory.EntratiLabConquestActiveFrameVariants = [];
25 }
26 if (inventory.EchoesHexConquestUnlocked) {
27 inventory.EchoesHexConquestUnlocked = 0;
28 inventory.EchoesHexConquestActiveFrameVariants = [];
29 inventory.EchoesHexConquestActiveStickers = [];
30 }
31 }
32 if (body.BuyMode) {
33 inventory.EntratiVaultCountLastPeriod! += 2;
34 if (body.IsEchoesDeepArchemedea) {
35 inventory.EchoesHexConquestUnlocked = 1;
36 } else {
37 inventory.EntratiLabConquestUnlocked = 1;
38 }
39 }
40 if (body.IsEchoesDeepArchemedea) {
41 if (inventory.EchoesHexConquestUnlocked) {
42 inventory.EchoesHexConquestActiveFrameVariants = body.EchoesHexConquestActiveFrameVariants!;
43 inventory.EchoesHexConquestActiveStickers = body.EchoesHexConquestActiveStickers!;
44 }
45 } else {
46 if (inventory.EntratiLabConquestUnlocked) {
47 inventory.EntratiLabConquestActiveFrameVariants = body.EntratiLabConquestActiveFrameVariants!;
48 }
49 }
50 await inventory.save();
51 res.json({
52 EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate),
53 EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
54 EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
55 EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
56 EchoesHexConquestUnlocked: inventory.EchoesHexConquestUnlocked,
57 EchoesHexConquestCacheScoreMission: inventory.EchoesHexConquestCacheScoreMission
58 });
59 };
60
61 interface IEntratiLabConquestModeRequest {
62 BuyMode?: number;
63 IsEchoesDeepArchemedea?: number;
64 EntratiLabConquestUnlocked?: number;
65 EntratiLabConquestActiveFrameVariants?: string[];
66 EchoesHexConquestUnlocked?: number;
67 EchoesHexConquestActiveFrameVariants?: string[];
68 EchoesHexConquestActiveStickers?: string[];
69 }
Modified src/models/inventoryModels/inventoryModel.ts +14 -1
@@ -1463,7 +1463,20 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1463 1463 DialogueHistory: dialogueHistorySchema,
1464 1464 CalendarProgress: calenderProgressSchema,
1465 1465
1466 SongChallenges: { type: [songChallengeSchema], default: undefined }
1466 SongChallenges: { type: [songChallengeSchema], default: undefined },
1467
1468 // Netracells + Deep Archimedea
1469 EntratiVaultCountLastPeriod: { type: Number, default: undefined },
1470 EntratiVaultCountResetDate: { type: Date, default: undefined },
1471 EntratiLabConquestUnlocked: { type: Number, default: undefined },
1472 EntratiLabConquestHardModeStatus: { type: Number, default: undefined },
1473 EntratiLabConquestCacheScoreMission: { type: Number, default: undefined },
1474 EntratiLabConquestActiveFrameVariants: { type: [String], default: undefined },
1475 EchoesHexConquestUnlocked: { type: Number, default: undefined },
1476 EchoesHexConquestHardModeStatus: { type: Number, default: undefined },
1477 EchoesHexConquestCacheScoreMission: { type: Number, default: undefined },
1478 EchoesHexConquestActiveFrameVariants: { type: [String], default: undefined },
1479 EchoesHexConquestActiveStickers: { type: [String], default: undefined }
1467 1480 },
1468 1481 { timestamps: { createdAt: "Created", updatedAt: false } }
1469 1482 );
Modified src/routes/api.ts +2 -0
@@ -30,6 +30,7 @@ import { dojoComponentRushController } from "@/src/controllers/api/dojoComponent
30 30 import { dojoController } from "@/src/controllers/api/dojoController";
31 31 import { dronesController } from "@/src/controllers/api/dronesController";
32 32 import { endlessXpController } from "@/src/controllers/api/endlessXpController";
33 import { entratiLabConquestModeController } from "@/src/controllers/api/entratiLabConquestModeController";
33 34 import { evolveWeaponController } from "@/src/controllers/api/evolveWeaponController";
34 35 import { findSessionsController } from "@/src/controllers/api/findSessionsController";
35 36 import { fishmongerController } from "@/src/controllers/api/fishmongerController";
@@ -183,6 +184,7 @@ apiRouter.post("/destroyDojoDeco.php", destroyDojoDecoController);
183 184 apiRouter.post("/dojoComponentRush.php", dojoComponentRushController);
184 185 apiRouter.post("/drones.php", dronesController);
185 186 apiRouter.post("/endlessXp.php", endlessXpController);
187 apiRouter.post("/entratiLabConquestMode.php", entratiLabConquestModeController);
186 188 apiRouter.post("/evolveWeapon.php", evolveWeaponController);
187 189 apiRouter.post("/findSessions.php", findSessionsController);
188 190 apiRouter.post("/fishmonger.php", fishmongerController);
Modified src/types/inventoryTypes/inventoryTypes.ts +11 -0
@@ -335,6 +335,17 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
335 335 DialogueHistory?: IDialogueHistoryClient;
336 336 CalendarProgress: ICalendarProgress;
337 337 SongChallenges?: ISongChallenge[];
338 EntratiVaultCountLastPeriod?: number;
339 EntratiVaultCountResetDate?: Date;
340 EntratiLabConquestUnlocked?: number;
341 EntratiLabConquestHardModeStatus?: number;
342 EntratiLabConquestCacheScoreMission?: number;
343 EntratiLabConquestActiveFrameVariants?: string[];
344 EchoesHexConquestUnlocked?: number;
345 EchoesHexConquestHardModeStatus?: number;
346 EchoesHexConquestCacheScoreMission?: number;
347 EchoesHexConquestActiveFrameVariants?: string[];
348 EchoesHexConquestActiveStickers?: string[];
338 349 }
339 350
340 351 export interface IAffiliation {