From 6142b8d2dc5a6572c054db48d728c734b933c9a1 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 8 Mar 2025 04:28:05 -0800 Subject: [PATCH] feat: config option for star days event (#1104) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1104 Co-authored-by: Sainan Co-committed-by: Sainan --- config.json.example | 5 ++- .../dynamic/worldStateController.ts | 36 +++++++++++++++++++ src/services/configService.ts | 3 ++ .../worldState/worldState.json | 1 + 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/config.json.example b/config.json.example index 89f272d2..d85b0072 100644 --- a/config.json.example +++ b/config.json.example @@ -35,5 +35,8 @@ "noDojoResearchCosts": true, "noDojoResearchTime": true, "fastClanAscension": true, - "spoofMasteryRank": -1 + "spoofMasteryRank": -1, + "events": { + "starDays": true + } } diff --git a/src/controllers/dynamic/worldStateController.ts b/src/controllers/dynamic/worldStateController.ts index a954aae9..3341992e 100644 --- a/src/controllers/dynamic/worldStateController.ts +++ b/src/controllers/dynamic/worldStateController.ts @@ -7,6 +7,7 @@ import static1999WinterDays from "@/static/fixed_responses/worldState/1999_winte import { buildConfig } from "@/src/services/buildConfigService"; import { IMongoDate, IOid } from "@/src/types/commonTypes"; import { unixTimesInMs } from "@/src/constants/timeConstants"; +import { config } from "@/src/services/configService"; export const worldStateController: RequestHandler = (req, res) => { const worldState: IWorldState = { @@ -15,10 +16,28 @@ export const worldStateController: RequestHandler = (req, res) => { ? req.query.buildLabel.split(" ").join("+") : buildConfig.buildLabel, Time: Math.round(Date.now() / 1000), + Goals: [], EndlessXpChoices: [], ...staticWorldState }; + if (config.events?.starDays) { + worldState.Goals.push({ + _id: { $oid: "67a4dcce2a198564d62e1647" }, + Activation: { $date: { $numberLong: "1738868400000" } }, + Expiry: { $date: { $numberLong: "2000000000000" } }, + Count: 0, + Goal: 0, + Success: 0, + Personal: true, + Desc: "/Lotus/Language/Events/ValentinesFortunaName", + ToolTip: "/Lotus/Language/Events/ValentinesFortunaName", + Icon: "/Lotus/Interface/Icons/WorldStatePanel/ValentinesEventIcon.png", + Tag: "FortunaValentines", + Node: "SolarisUnitedHub1" + }); + } + 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); @@ -134,8 +153,10 @@ export const worldStateController: RequestHandler = (req, res) => { }; interface IWorldState { + Version: number; // for goals BuildLabel: string; Time: number; + Goals: IGoal[]; SyndicateMissions: ISyndicateMission[]; NodeOverrides: INodeOverride[]; EndlessXpChoices: IEndlessXpChoice[]; @@ -143,6 +164,21 @@ interface IWorldState { Tmp?: string; } +interface IGoal { + _id: IOid; + Activation: IMongoDate; + Expiry: IMongoDate; + Count: number; + Goal: number; + Success: number; + Personal: boolean; + Desc: string; + ToolTip: string; + Icon: string; + Tag: string; + Node: string; +} + interface ISyndicateMission { _id: IOid; Activation: IMongoDate; diff --git a/src/services/configService.ts b/src/services/configService.ts index 84de1f6f..07860f93 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -62,6 +62,9 @@ interface IConfig { noDojoResearchTime?: boolean; fastClanAscension?: boolean; spoofMasteryRank?: number; + events?: { + starDays?: boolean; + }; } interface ILoggerConfig { diff --git a/static/fixed_responses/worldState/worldState.json b/static/fixed_responses/worldState/worldState.json index 2105a9c5..047dfd86 100644 --- a/static/fixed_responses/worldState/worldState.json +++ b/static/fixed_responses/worldState/worldState.json @@ -1,4 +1,5 @@ { + "Version": 10, "Events": [ { "Msg": "Join the OpenWF Discord!",