From e201279eeef2d81ea486bb3abfd57976a36a2203 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sun, 12 Jan 2025 13:38:05 +0100 Subject: [PATCH 1/3] fix: remove ship decos from inventory when placed and vice-versa (#770) --- src/services/shipCustomizationsService.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/services/shipCustomizationsService.ts b/src/services/shipCustomizationsService.ts index 26aef04e..2d3ab5b5 100644 --- a/src/services/shipCustomizationsService.ts +++ b/src/services/shipCustomizationsService.ts @@ -8,6 +8,8 @@ import { } from "@/src/types/shipTypes"; import { logger } from "@/src/utils/logger"; import { Types } from "mongoose"; +import { addShipDecorations, getInventory } from "./inventoryService"; +import { config } from "./configService"; export const setShipCustomizations = async ( accountId: string, @@ -106,17 +108,28 @@ export const handleSetShipDecorations = async ( }; } - //TODO: check whether to remove from shipitems - if (placedDecoration.RemoveId) { roomToPlaceIn.PlacedDecos.pull({ _id: placedDecoration.RemoveId }); await personalRooms.save(); + + if (!config.unlockAllShipDecorations) { + const inventory = await getInventory(accountId); + addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: 1 }]); + await inventory.save(); + } + return { DecoId: placedDecoration.RemoveId, Room: placedDecoration.Room, IsApartment: placedDecoration.IsApartment, MaxCapacityIncrease: 0 }; + } else { + if (!config.unlockAllShipDecorations) { + const inventory = await getInventory(accountId); + addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: -1 }]); + await inventory.save(); + } } // TODO: handle capacity -- 2.47.2 From 1dba3aa0bd606ee5c87a7f69cb958dcd7cb79fe7 Mon Sep 17 00:00:00 2001 From: Sainan Date: Mon, 13 Jan 2025 03:38:53 +0100 Subject: [PATCH 2/3] fix: 1999 cycle not being properly aligned to Monday, 00:00 UTC+0 --- src/controllers/dynamic/worldStateController.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controllers/dynamic/worldStateController.ts b/src/controllers/dynamic/worldStateController.ts index 5af6734f..7fdd7053 100644 --- a/src/controllers/dynamic/worldStateController.ts +++ b/src/controllers/dynamic/worldStateController.ts @@ -19,9 +19,10 @@ export const worldStateController: RequestHandler = (req, res) => { ...staticWorldState }; - const day = Math.trunc(new Date().getTime() / 86400000); - const week = Math.trunc((day + 3) / 7); // week begins on mondays - const weekStart = week * 604800000; + const EPOCH = 1734307200 * 1000; // Monday, Dec 16, 2024 @ 00:00 UTC+0; should logically be winter in 1999 iteration 0 + const day = Math.trunc((new Date().getTime() - EPOCH) / 86400000); + const week = Math.trunc(day / 7); + const weekStart = EPOCH + week * 604800000; const weekEnd = weekStart + 604800000; // Elite Sanctuary Onslaught cycling every week -- 2.47.2 From d92f96cef1253a49585c1b94cf3a03d3e565b811 Mon Sep 17 00:00:00 2001 From: Sainan Date: Mon, 13 Jan 2025 03:39:32 +0100 Subject: [PATCH 3/3] feat: YearIteration cycling every 4 weeks --- src/controllers/dynamic/worldStateController.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/controllers/dynamic/worldStateController.ts b/src/controllers/dynamic/worldStateController.ts index 7fdd7053..94b6c59a 100644 --- a/src/controllers/dynamic/worldStateController.ts +++ b/src/controllers/dynamic/worldStateController.ts @@ -88,7 +88,7 @@ export const worldStateController: RequestHandler = (req, res) => { ][week % 8] }); - // 1999 Calendar Season cycling every week + // 1999 Calendar Season cycling every week + YearIteration every 4 weeks worldState.KnownCalendarSeasons[0].Activation = { $date: { $numberLong: weekStart.toString() } }; worldState.KnownCalendarSeasons[0].Expiry = { $date: { $numberLong: weekEnd.toString() } }; worldState.KnownCalendarSeasons[0].Season = ["CST_WINTER", "CST_SPRING", "CST_SUMMER", "CST_FALL"][week % 4]; @@ -98,6 +98,7 @@ export const worldStateController: RequestHandler = (req, res) => { static1999SummerDays, static1999FallDays ][week % 4]; + worldState.KnownCalendarSeasons[0].YearIteration = Math.trunc(week / 4); // Sentient Anomaly cycling every 30 minutes const halfHour = Math.trunc(new Date().getTime() / (unixTimesInMs.hour / 2)); @@ -175,4 +176,5 @@ interface ICalendarSeason { Days: { day: number; }[]; + YearIteration: number; } -- 2.47.2