返回提交历史
Modified
README.md
+2
-1
Modified
config.json.example
+2
-1
Modified
src/services/configService.ts
+2
-1
Modified
src/services/worldStateService.ts
+54
-1
XFEstudio/SpaceNinjaServer
feat: add eidolonOverride & vallisOverride to replace lockTime (#2135)
I think for now it's best to keep the client time somewhat in sync with the server/database time to avoid various issues. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2135 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
870c9648
代码差异
4 个文件
+60
-4
@@ -14,7 +14,8 @@ SpaceNinjaServer requires a `config.json`. To set it up, you can copy the [confi
14
14
15
15
- `logger.level` can be `fatal`, `error`, `warn`, `info`, `http`, `debug`, or `trace`.
16
16
- `myIrcAddresses` can be used to point to an IRC server. If not provided, defaults to `[ myAddress ]`.
17
- `worldState.lockTime` will lock the time provided in worldState if nonzero, e.g. `1743202800` for night in POE.
17
- `worldState.eidolonOverride` can be set to `day` or `night` to lock the time to day/fass and night/vome on Plains of Eidolon/Cambion Drift.
18
- `worldState.vallisOverride` can be set to `warm` or `cold` to lock the temperature on Orb Vallis.
18
19
- `worldState.nightwaveOverride` will lock the nightwave season, assuming the client is new enough for it. Valid values:
19
20
- `RadioLegionIntermission13Syndicate` for Nora's Mix Vol. 9
20
21
- `RadioLegionIntermission12Syndicate` for Nora's Mix Vol. 8
@@ -55,7 +55,8 @@
55
55
"affinityBoost": false,
56
56
"resourceBoost": false,
57
57
"starDays": true,
58
"lockTime": 0,
58
"eidolonOverride": "",
59
"vallisOverride": "",
59
60
"nightwaveOverride": ""
60
61
}
61
62
}
@@ -61,7 +61,8 @@ interface IConfig {
61
61
affinityBoost?: boolean;
62
62
resourceBoost?: boolean;
63
63
starDays?: boolean;
64
lockTime?: number;
64
eidolonOverride?: string;
65
vallisOverride?: string;
65
66
nightwaveOverride?: string;
66
67
};
67
68
}
@@ -939,8 +939,61 @@ const getCalendarSeason = (week: number): ICalendarSeason => {
939
939
};
940
940
};
941
941
942
const doesTimeSatsifyConstraints = (timeSecs: number): boolean => {
943
if (config.worldState?.eidolonOverride) {
944
const eidolonEpoch = 1391992660;
945
const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000);
946
const eidolonCycleStart = eidolonEpoch + eidolonCycle * 9000;
947
const eidolonCycleEnd = eidolonCycleStart + 9000;
948
const eidolonCycleNightStart = eidolonCycleEnd - 3000;
949
if (config.worldState.eidolonOverride == "day") {
950
if (
951
//timeSecs < eidolonCycleStart ||
952
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, eidolonCycleNightStart * 1000)
953
) {
954
return false;
955
}
956
} else {
957
if (
958
timeSecs < eidolonCycleNightStart ||
959
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, eidolonCycleEnd * 1000)
960
) {
961
return false;
962
}
963
}
964
}
965
966
if (config.worldState?.vallisOverride) {
967
const vallisEpoch = 1541837628;
968
const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600);
969
const vallisCycleStart = vallisEpoch + vallisCycle * 1600;
970
const vallisCycleEnd = vallisCycleStart + 1600;
971
const vallisCycleColdStart = vallisCycleStart + 400;
972
if (config.worldState.vallisOverride == "cold") {
973
if (
974
timeSecs < vallisCycleColdStart ||
975
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, vallisCycleEnd * 1000)
976
) {
977
return false;
978
}
979
} else {
980
if (
981
//timeSecs < vallisCycleStart ||
982
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, vallisCycleColdStart * 1000)
983
) {
984
return false;
985
}
986
}
987
}
988
989
return true;
990
};
991
942
992
export const getWorldState = (buildLabel?: string): IWorldState => {
943
const timeSecs = config.worldState?.lockTime || Math.round(Date.now() / 1000);
993
let timeSecs = Math.round(Date.now() / 1000);
994
while (!doesTimeSatsifyConstraints(timeSecs)) {
995
timeSecs -= 60;
996
}
944
997
const timeMs = timeSecs * 1000;
945
998
const day = Math.trunc((timeMs - EPOCH) / 86400000);
946
999
const week = Math.trunc(day / 7);