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

chore: improve randomness of void storm missions (#2428)

Instead of alternating the mission pool every hour, we now use sequentiallyUniqueRandomElement which should ensure that we don't duplicate any of the last x missions (x = 3 for Lith & Axi and x = 1 Meso & Neo). Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2428 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

d6145561
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +29 -20
Modified src/services/worldStateService.ts +29 -20
@@ -971,25 +971,26 @@ const getCalendarSeason = (week: number): ICalendarSeason => {
971 971
972 972 // Not very faithful, but to avoid the same node coming up back-to-back (which is not valid), I've split these into 2 arrays which we're alternating between.
973 973
974 const voidStormMissionsA = {
975 VoidT1: ["CrewBattleNode519", "CrewBattleNode518", "CrewBattleNode515", "CrewBattleNode503"],
976 VoidT2: ["CrewBattleNode501", "CrewBattleNode534", "CrewBattleNode530"],
977 VoidT3: ["CrewBattleNode521", "CrewBattleNode516"],
974 const voidStormMissions = {
975 VoidT1: [
976 "CrewBattleNode519",
977 "CrewBattleNode518",
978 "CrewBattleNode515",
979 "CrewBattleNode503",
980 "CrewBattleNode509",
981 "CrewBattleNode522",
982 "CrewBattleNode511",
983 "CrewBattleNode512"
984 ],
985 VoidT2: ["CrewBattleNode501", "CrewBattleNode534", "CrewBattleNode530", "CrewBattleNode535", "CrewBattleNode533"],
986 VoidT3: ["CrewBattleNode521", "CrewBattleNode516", "CrewBattleNode524", "CrewBattleNode525"],
978 987 VoidT4: [
979 988 "CrewBattleNode555",
980 989 "CrewBattleNode553",
981 990 "CrewBattleNode554",
982 991 "CrewBattleNode539",
983 992 "CrewBattleNode531",
984 "CrewBattleNode527"
985 ]
986 };
987
988 const voidStormMissionsB = {
989 VoidT1: ["CrewBattleNode509", "CrewBattleNode522", "CrewBattleNode511", "CrewBattleNode512"],
990 VoidT2: ["CrewBattleNode535", "CrewBattleNode533"],
991 VoidT3: ["CrewBattleNode524", "CrewBattleNode525"],
992 VoidT4: [
993 "CrewBattleNode527",
993 994 "CrewBattleNode542",
994 995 "CrewBattleNode538",
995 996 "CrewBattleNode543",
@@ -997,18 +998,21 @@ const voidStormMissionsB = {
997 998 "CrewBattleNode550",
998 999 "CrewBattleNode529"
999 1000 ]
1000 };
1001 } as const;
1002
1003 const voidStormLookbehind = {
1004 VoidT1: 3,
1005 VoidT2: 1,
1006 VoidT3: 1,
1007 VoidT4: 3
1008 } as const;
1001 1009
1002 1010 const pushVoidStorms = (arr: IVoidStorm[], hour: number): void => {
1003 1011 const activation = hour * unixTimesInMs.hour + 40 * unixTimesInMs.minute;
1004 1012 const expiry = activation + 90 * unixTimesInMs.minute;
1005 1013 let accum = 0;
1006 const rng = new SRng(new SRng(hour).randomInt(0, 100_000));
1007 const voidStormMissions = structuredClone(hour & 1 ? voidStormMissionsA : voidStormMissionsB);
1014 const tierIdx = { VoidT1: hour * 2, VoidT2: hour, VoidT3: hour, VoidT4: hour * 2 };
1008 1015 for (const tier of ["VoidT1", "VoidT1", "VoidT2", "VoidT3", "VoidT4", "VoidT4"] as const) {
1009 const idx = rng.randomInt(0, voidStormMissions[tier].length - 1);
1010 const node = voidStormMissions[tier][idx];
1011 voidStormMissions[tier].splice(idx, 1);
1012 1016 arr.push({
1013 1017 _id: {
1014 1018 $oid:
@@ -1016,7 +1020,12 @@ const pushVoidStorms = (arr: IVoidStorm[], hour: number): void => {
1016 1020 "0321e89b" +
1017 1021 (accum++).toString().padStart(8, "0")
1018 1022 },
1019 Node: node,
1023 Node: sequentiallyUniqueRandomElement(
1024 voidStormMissions[tier],
1025 tierIdx[tier]++,
1026 voidStormLookbehind[tier],
1027 2051969264
1028 )!,
1020 1029 Activation: { $date: { $numberLong: activation.toString() } },
1021 1030 Expiry: { $date: { $numberLong: expiry.toString() } },
1022 1031 ActiveMissionTier: tier