XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

fix: 1999 calendar not working properly (#777)

5d436278
Sainan <sainan@calamity.inc>
提交于

代码差异

1 个文件 +7 -4
Modified src/controllers/dynamic/worldStateController.ts +7 -4
@@ -19,9 +19,10 @@ export const worldStateController: RequestHandler = (req, res) => {
19 19 ...staticWorldState
20 20 };
21 21
22 const day = Math.trunc(new Date().getTime() / 86400000);
23 const week = Math.trunc((day + 3) / 7); // week begins on mondays
24 const weekStart = week * 604800000;
22 const EPOCH = 1734307200 * 1000; // Monday, Dec 16, 2024 @ 00:00 UTC+0; should logically be winter in 1999 iteration 0
23 const day = Math.trunc((new Date().getTime() - EPOCH) / 86400000);
24 const week = Math.trunc(day / 7);
25 const weekStart = EPOCH + week * 604800000;
25 26 const weekEnd = weekStart + 604800000;
26 27
27 28 // Elite Sanctuary Onslaught cycling every week
@@ -87,7 +88,7 @@ export const worldStateController: RequestHandler = (req, res) => {
87 88 ][week % 8]
88 89 });
89 90
90 // 1999 Calendar Season cycling every week
91 // 1999 Calendar Season cycling every week + YearIteration every 4 weeks
91 92 worldState.KnownCalendarSeasons[0].Activation = { $date: { $numberLong: weekStart.toString() } };
92 93 worldState.KnownCalendarSeasons[0].Expiry = { $date: { $numberLong: weekEnd.toString() } };
93 94 worldState.KnownCalendarSeasons[0].Season = ["CST_WINTER", "CST_SPRING", "CST_SUMMER", "CST_FALL"][week % 4];
@@ -97,6 +98,7 @@ export const worldStateController: RequestHandler = (req, res) => {
97 98 static1999SummerDays,
98 99 static1999FallDays
99 100 ][week % 4];
101 worldState.KnownCalendarSeasons[0].YearIteration = Math.trunc(week / 4);
100 102
101 103 // Sentient Anomaly cycling every 30 minutes
102 104 const halfHour = Math.trunc(new Date().getTime() / (unixTimesInMs.hour / 2));
@@ -174,4 +176,5 @@ interface ICalendarSeason {
174 176 Days: {
175 177 day: number;
176 178 }[];
179 YearIteration: number;
177 180 }