From 4e011e1ed4a1cddbc438e43f491baa076a41c5dd Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 22 Mar 2025 21:44:51 +0100 Subject: [PATCH 1/4] feat: entratiLabConquestMode.php --- .../api/entratiLabConquestModeController.ts | 61 +++++++++++++++++++ src/models/inventoryModels/inventoryModel.ts | 15 ++++- src/routes/api.ts | 2 + src/types/inventoryTypes/inventoryTypes.ts | 11 ++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/controllers/api/entratiLabConquestModeController.ts diff --git a/src/controllers/api/entratiLabConquestModeController.ts b/src/controllers/api/entratiLabConquestModeController.ts new file mode 100644 index 00000000..e32bd4ce --- /dev/null +++ b/src/controllers/api/entratiLabConquestModeController.ts @@ -0,0 +1,61 @@ +import { toMongoDate } from "@/src/helpers/inventoryHelpers"; +import { getJSONfromString } from "@/src/helpers/stringHelpers"; +import { getInventory } from "@/src/services/inventoryService"; +import { getAccountIdForRequest } from "@/src/services/loginService"; +import { RequestHandler } from "express"; + +export const entratiLabConquestModeController: RequestHandler = async (req, res) => { + const accountId = await getAccountIdForRequest(req); + const inventory = await getInventory( + accountId, + "EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission" + ); + const body = getJSONfromString(String(req.body)); + if (body.BuyMode) { + if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) { + const thisWeek = Math.trunc(Date.now() / 604800000) * 604800000; + const nextWeek = thisWeek + 604800000; + inventory.EntratiVaultCountLastPeriod = 0; + inventory.EntratiVaultCountResetDate = new Date(nextWeek); + if (inventory.EntratiLabConquestUnlocked) { + inventory.EntratiLabConquestUnlocked = 0; + } + if (inventory.EchoesHexConquestUnlocked) { + inventory.EchoesHexConquestUnlocked = 0; + } + } + inventory.EntratiVaultCountLastPeriod! += 2; + if (body.IsEchoesDeepArchemedea) { + inventory.EchoesHexConquestUnlocked = 1; + } else { + inventory.EntratiLabConquestUnlocked = 1; + } + } + if (body.IsEchoesDeepArchemedea) { + inventory.EchoesHexConquestActiveFrameVariants = body.EchoesHexConquestActiveFrameVariants!; + inventory.EchoesHexConquestActiveStickers = body.EchoesHexConquestActiveStickers!; + } else { + inventory.EntratiLabConquestActiveFrameVariants = body.EntratiLabConquestActiveFrameVariants!; + } + await inventory.save(); + res.json({ + EntratiVaultCountResetDate: inventory.EntratiVaultCountResetDate + ? toMongoDate(inventory.EntratiVaultCountResetDate) + : undefined, + EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod, + EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked, + EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission, + EchoesHexConquestUnlocked: inventory.EchoesHexConquestUnlocked, + EchoesHexConquestCacheScoreMission: inventory.EchoesHexConquestCacheScoreMission + }); +}; + +interface IEntratiLabConquestModeRequest { + BuyMode?: number; + IsEchoesDeepArchemedea?: number; + EntratiLabConquestUnlocked?: number; + EntratiLabConquestActiveFrameVariants?: string[]; + EchoesHexConquestUnlocked?: number; + EchoesHexConquestActiveFrameVariants?: string[]; + EchoesHexConquestActiveStickers?: string[]; +} diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index 8e24b4c6..ec0e1778 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -1463,7 +1463,20 @@ const inventorySchema = new Schema( DialogueHistory: dialogueHistorySchema, CalendarProgress: calenderProgressSchema, - SongChallenges: { type: [songChallengeSchema], default: undefined } + SongChallenges: { type: [songChallengeSchema], default: undefined }, + + // Netracells + Deep Archimedea + EntratiVaultCountLastPeriod: { type: Number, default: undefined }, + EntratiVaultCountResetDate: { type: Date, default: undefined }, + EntratiLabConquestUnlocked: { type: Number, default: undefined }, + EntratiLabConquestHardModeStatus: { type: Number, default: undefined }, + EntratiLabConquestCacheScoreMission: { type: Number, default: undefined }, + EntratiLabConquestActiveFrameVariants: { type: [String], default: undefined }, + EchoesHexConquestUnlocked: { type: Number, default: undefined }, + EchoesHexConquestHardModeStatus: { type: Number, default: undefined }, + EchoesHexConquestCacheScoreMission: { type: Number, default: undefined }, + EchoesHexConquestActiveFrameVariants: { type: [String], default: undefined }, + EchoesHexConquestActiveStickers: { type: [String], default: undefined } }, { timestamps: { createdAt: "Created", updatedAt: false } } ); diff --git a/src/routes/api.ts b/src/routes/api.ts index 0a1c238b..d8ad7aaf 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -30,6 +30,7 @@ import { dojoComponentRushController } from "@/src/controllers/api/dojoComponent import { dojoController } from "@/src/controllers/api/dojoController"; import { dronesController } from "@/src/controllers/api/dronesController"; import { endlessXpController } from "@/src/controllers/api/endlessXpController"; +import { entratiLabConquestModeController } from "@/src/controllers/api/entratiLabConquestModeController"; import { evolveWeaponController } from "@/src/controllers/api/evolveWeaponController"; import { findSessionsController } from "@/src/controllers/api/findSessionsController"; import { fishmongerController } from "@/src/controllers/api/fishmongerController"; @@ -182,6 +183,7 @@ apiRouter.post("/destroyDojoDeco.php", destroyDojoDecoController); apiRouter.post("/dojoComponentRush.php", dojoComponentRushController); apiRouter.post("/drones.php", dronesController); apiRouter.post("/endlessXp.php", endlessXpController); +apiRouter.post("/entratiLabConquestMode.php", entratiLabConquestModeController); apiRouter.post("/evolveWeapon.php", evolveWeaponController); apiRouter.post("/findSessions.php", findSessionsController); apiRouter.post("/fishmonger.php", fishmongerController); diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 59c1697a..27758acb 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -335,6 +335,17 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu DialogueHistory?: IDialogueHistoryClient; CalendarProgress: ICalendarProgress; SongChallenges?: ISongChallenge[]; + EntratiVaultCountLastPeriod?: number; + EntratiVaultCountResetDate?: Date; + EntratiLabConquestUnlocked?: number; + EntratiLabConquestHardModeStatus?: number; + EntratiLabConquestCacheScoreMission?: number; + EntratiLabConquestActiveFrameVariants?: string[]; + EchoesHexConquestUnlocked?: number; + EchoesHexConquestHardModeStatus?: number; + EchoesHexConquestCacheScoreMission?: number; + EchoesHexConquestActiveFrameVariants?: string[]; + EchoesHexConquestActiveStickers?: string[]; } export interface IAffiliation { -- 2.47.2 From 18062b5d91b2fdd0bd3b299c74b34d4e89404b16 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 22 Mar 2025 21:46:25 +0100 Subject: [PATCH 2/4] monday --- src/controllers/api/entratiLabConquestModeController.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/api/entratiLabConquestModeController.ts b/src/controllers/api/entratiLabConquestModeController.ts index e32bd4ce..472a8cc7 100644 --- a/src/controllers/api/entratiLabConquestModeController.ts +++ b/src/controllers/api/entratiLabConquestModeController.ts @@ -13,10 +13,13 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res) const body = getJSONfromString(String(req.body)); if (body.BuyMode) { if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) { - const thisWeek = Math.trunc(Date.now() / 604800000) * 604800000; - const nextWeek = thisWeek + 604800000; + const EPOCH = 1734307200 * 1000; // Mondays, amirite? + const day = Math.trunc((Date.now() - EPOCH) / 86400000); + const week = Math.trunc(day / 7); + const weekStart = EPOCH + week * 604800000; + const weekEnd = weekStart + 604800000; inventory.EntratiVaultCountLastPeriod = 0; - inventory.EntratiVaultCountResetDate = new Date(nextWeek); + inventory.EntratiVaultCountResetDate = new Date(weekEnd); if (inventory.EntratiLabConquestUnlocked) { inventory.EntratiLabConquestUnlocked = 0; } -- 2.47.2 From a082331632424da8597223c0a0cb5080d0dacd87 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 22 Mar 2025 21:52:05 +0100 Subject: [PATCH 3/4] also reset modifiers when week rolls over --- .../api/entratiLabConquestModeController.ts | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/controllers/api/entratiLabConquestModeController.ts b/src/controllers/api/entratiLabConquestModeController.ts index 472a8cc7..ae480402 100644 --- a/src/controllers/api/entratiLabConquestModeController.ts +++ b/src/controllers/api/entratiLabConquestModeController.ts @@ -11,22 +11,25 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res) "EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission" ); const body = getJSONfromString(String(req.body)); - if (body.BuyMode) { - if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) { - const EPOCH = 1734307200 * 1000; // Mondays, amirite? - const day = Math.trunc((Date.now() - EPOCH) / 86400000); - const week = Math.trunc(day / 7); - const weekStart = EPOCH + week * 604800000; - const weekEnd = weekStart + 604800000; - inventory.EntratiVaultCountLastPeriod = 0; - inventory.EntratiVaultCountResetDate = new Date(weekEnd); - if (inventory.EntratiLabConquestUnlocked) { - inventory.EntratiLabConquestUnlocked = 0; - } - if (inventory.EchoesHexConquestUnlocked) { - inventory.EchoesHexConquestUnlocked = 0; - } + if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) { + const EPOCH = 1734307200 * 1000; // Mondays, amirite? + const day = Math.trunc((Date.now() - EPOCH) / 86400000); + const week = Math.trunc(day / 7); + const weekStart = EPOCH + week * 604800000; + const weekEnd = weekStart + 604800000; + inventory.EntratiVaultCountLastPeriod = 0; + inventory.EntratiVaultCountResetDate = new Date(weekEnd); + if ("EntratiLabConquestUnlocked" in inventory) { + inventory.EntratiLabConquestUnlocked = 0; + inventory.EntratiLabConquestActiveFrameVariants = []; } + if ("EchoesHexConquestUnlocked" in inventory) { + inventory.EchoesHexConquestUnlocked = 0; + inventory.EchoesHexConquestActiveFrameVariants = []; + inventory.EchoesHexConquestActiveStickers = []; + } + } + if (body.BuyMode) { inventory.EntratiVaultCountLastPeriod! += 2; if (body.IsEchoesDeepArchemedea) { inventory.EchoesHexConquestUnlocked = 1; @@ -42,9 +45,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res) } await inventory.save(); res.json({ - EntratiVaultCountResetDate: inventory.EntratiVaultCountResetDate - ? toMongoDate(inventory.EntratiVaultCountResetDate) - : undefined, + EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate), EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod, EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked, EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission, -- 2.47.2 From 92013aad673a53262255be1e04af6aae59c2f1c3 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 22 Mar 2025 21:58:38 +0100 Subject: [PATCH 4/4] don't store settings until conquest is unlocked the client could just not send the request in this case but whatever... --- .../api/entratiLabConquestModeController.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/controllers/api/entratiLabConquestModeController.ts b/src/controllers/api/entratiLabConquestModeController.ts index ae480402..ae7b5845 100644 --- a/src/controllers/api/entratiLabConquestModeController.ts +++ b/src/controllers/api/entratiLabConquestModeController.ts @@ -19,11 +19,11 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res) const weekEnd = weekStart + 604800000; inventory.EntratiVaultCountLastPeriod = 0; inventory.EntratiVaultCountResetDate = new Date(weekEnd); - if ("EntratiLabConquestUnlocked" in inventory) { + if (inventory.EntratiLabConquestUnlocked) { inventory.EntratiLabConquestUnlocked = 0; inventory.EntratiLabConquestActiveFrameVariants = []; } - if ("EchoesHexConquestUnlocked" in inventory) { + if (inventory.EchoesHexConquestUnlocked) { inventory.EchoesHexConquestUnlocked = 0; inventory.EchoesHexConquestActiveFrameVariants = []; inventory.EchoesHexConquestActiveStickers = []; @@ -38,10 +38,14 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res) } } if (body.IsEchoesDeepArchemedea) { - inventory.EchoesHexConquestActiveFrameVariants = body.EchoesHexConquestActiveFrameVariants!; - inventory.EchoesHexConquestActiveStickers = body.EchoesHexConquestActiveStickers!; + if (inventory.EchoesHexConquestUnlocked) { + inventory.EchoesHexConquestActiveFrameVariants = body.EchoesHexConquestActiveFrameVariants!; + inventory.EchoesHexConquestActiveStickers = body.EchoesHexConquestActiveStickers!; + } } else { - inventory.EntratiLabConquestActiveFrameVariants = body.EntratiLabConquestActiveFrameVariants!; + if (inventory.EntratiLabConquestUnlocked) { + inventory.EntratiLabConquestActiveFrameVariants = body.EntratiLabConquestActiveFrameVariants!; + } } await inventory.save(); res.json({ -- 2.47.2