返回提交历史
Modified
src/services/worldStateService.ts
+19
-15
XFEstudio/SpaceNinjaServer
chore: don't use sequential values as RNG seeds directly (#1812)
This should help get a slightly better distribution Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1812 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
a67f99b6
代码差异
1 个文件
+19
-15
@@ -225,7 +225,8 @@ const pushSortieIfRelevant = (worldState: IWorldState, day: number): void => {
225
225
return;
226
226
}
227
227
228
const rng = new CRng(day);
228
const seed = new CRng(day).randomInt(0, 0xffff);
229
const rng = new CRng(seed);
229
230
230
231
const boss = rng.randomElement(sortieBosses);
231
232
@@ -354,7 +355,7 @@ const pushSortieIfRelevant = (worldState: IWorldState, day: number): void => {
354
355
Activation: { $date: { $numberLong: dayStart.toString() } },
355
356
Expiry: { $date: { $numberLong: dayEnd.toString() } },
356
357
Reward: "/Lotus/Types/Game/MissionDecks/SortieRewards",
357
Seed: day,
358
Seed: seed,
358
359
Boss: boss,
359
360
Variants: selectedNodes
360
361
});
@@ -374,7 +375,7 @@ const dailyChallenges = Object.keys(ExportNightwave.challenges).filter(x =>
374
375
const getSeasonDailyChallenge = (day: number): ISeasonChallenge => {
375
376
const dayStart = EPOCH + day * 86400000;
376
377
const dayEnd = EPOCH + (day + 3) * 86400000;
377
const rng = new CRng(day);
378
const rng = new CRng(new CRng(day).randomInt(0, 0xffff));
378
379
return {
379
380
_id: { $oid: "67e1b5ca9d00cb47" + day.toString().padStart(8, "0") },
380
381
Daily: true,
@@ -394,7 +395,7 @@ const getSeasonWeeklyChallenge = (week: number, id: number): ISeasonChallenge =>
394
395
const weekStart = EPOCH + week * 604800000;
395
396
const weekEnd = weekStart + 604800000;
396
397
const challengeId = week * 7 + id;
397
const rng = new CRng(challengeId);
398
const rng = new CRng(new CRng(challengeId).randomInt(0, 0xffff));
398
399
return {
399
400
_id: { $oid: "67e1bb2d9d00cb47" + challengeId.toString().padStart(8, "0") },
400
401
Activation: { $date: { $numberLong: weekStart.toString() } },
@@ -411,7 +412,7 @@ const getSeasonWeeklyHardChallenge = (week: number, id: number): ISeasonChalleng
411
412
const weekStart = EPOCH + week * 604800000;
412
413
const weekEnd = weekStart + 604800000;
413
414
const challengeId = week * 7 + id;
414
const rng = new CRng(challengeId);
415
const rng = new CRng(new CRng(challengeId).randomInt(0, 0xffff));
415
416
return {
416
417
_id: { $oid: "67e1bb2d9d00cb47" + challengeId.toString().padStart(8, "0") },
417
418
Activation: { $date: { $numberLong: weekStart.toString() } },
@@ -476,7 +477,7 @@ const getCalendarSeason = (week: number): ICalendarSeason => {
476
477
//logger.debug(`birthday on day ${day}`);
477
478
eventDays.push({ day, events: [] }); // This is how CET_PLOT looks in worldState as of around 38.5.0
478
479
}
479
const rng = new CRng(week);
480
const rng = new CRng(new CRng(week).randomInt(0, 0xffff));
480
481
const challenges = [
481
482
"/Lotus/Types/Challenges/Calendar1999/CalendarKillEnemiesEasy",
482
483
"/Lotus/Types/Challenges/Calendar1999/CalendarKillEnemiesMedium",
@@ -710,7 +711,7 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
710
711
}
711
712
712
713
// Elite Sanctuary Onslaught cycling every week
713
worldState.NodeOverrides.find(x => x.Node == "SolNode802")!.Seed = week; // unfaithful
714
worldState.NodeOverrides.find(x => x.Node == "SolNode802")!.Seed = new CRng(week).randomInt(0, 0xffff);
714
715
715
716
// Holdfast, Cavia, & Hex bounties cycling every 2.5 hours; unfaithful implementation
716
717
let bountyCycle = Math.trunc(Date.now() / 9000000);
@@ -749,14 +750,16 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
749
750
750
751
// TODO: xpAmounts need to be calculated based on the jobType somehow?
751
752
753
const seed = new CRng(bountyCycle).randomInt(0, 0xffff);
754
752
755
{
753
const rng = new CRng(bountyCycle);
756
const rng = new CRng(seed);
754
757
worldState.SyndicateMissions.push({
755
758
_id: { $oid: Math.trunc(bountyCycleStart / 1000).toString(16) + "0000000000000008" },
756
759
Activation: { $date: { $numberLong: bountyCycleStart.toString(10) } },
757
760
Expiry: { $date: { $numberLong: bountyCycleEnd.toString(10) } },
758
761
Tag: "CetusSyndicate",
759
Seed: bountyCycle,
762
Seed: seed,
760
763
Nodes: [],
761
764
Jobs: [
762
765
{
@@ -820,13 +823,13 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
820
823
}
821
824
822
825
{
823
const rng = new CRng(bountyCycle);
826
const rng = new CRng(seed);
824
827
worldState.SyndicateMissions.push({
825
828
_id: { $oid: Math.trunc(bountyCycleStart / 1000).toString(16) + "0000000000000025" },
826
829
Activation: { $date: { $numberLong: bountyCycleStart.toString(10) } },
827
830
Expiry: { $date: { $numberLong: bountyCycleEnd.toString(10) } },
828
831
Tag: "SolarisSyndicate",
829
Seed: bountyCycle,
832
Seed: seed,
830
833
Nodes: [],
831
834
Jobs: [
832
835
{
@@ -890,13 +893,13 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
890
893
}
891
894
892
895
{
893
const rng = new CRng(bountyCycle);
896
const rng = new CRng(seed);
894
897
worldState.SyndicateMissions.push({
895
898
_id: { $oid: Math.trunc(bountyCycleStart / 1000).toString(16) + "0000000000000002" },
896
899
Activation: { $date: { $numberLong: bountyCycleStart.toString(10) } },
897
900
Expiry: { $date: { $numberLong: bountyCycleEnd.toString(10) } },
898
901
Tag: "EntratiSyndicate",
899
Seed: bountyCycle,
902
Seed: seed,
900
903
Nodes: [],
901
904
Jobs: [
902
905
{
@@ -1119,7 +1122,8 @@ export const getLiteSortie = (week: number): ILiteSortie => {
1119
1122
}
1120
1123
}
1121
1124
1122
const rng = new CRng(week);
1125
const seed = new CRng(week).randomInt(0, 0xffff);
1126
const rng = new CRng(seed);
1123
1127
const firstNodeIndex = rng.randomInt(0, nodes.length - 1);
1124
1128
const firstNode = nodes[firstNodeIndex];
1125
1129
nodes.splice(firstNodeIndex, 1);
@@ -1133,7 +1137,7 @@ export const getLiteSortie = (week: number): ILiteSortie => {
1133
1137
Activation: { $date: { $numberLong: weekStart.toString() } },
1134
1138
Expiry: { $date: { $numberLong: weekEnd.toString() } },
1135
1139
Reward: "/Lotus/Types/Game/MissionDecks/ArchonSortieRewards",
1136
Seed: week,
1140
Seed: seed,
1137
1141
Boss: boss,
1138
1142
Missions: [
1139
1143
{