From a082331632424da8597223c0a0cb5080d0dacd87 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 22 Mar 2025 21:52:05 +0100 Subject: [PATCH] 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,