返回提交历史
Modified
src/services/worldStateService.ts
+20
-28
XFEstudio/SpaceNinjaServer
fix: ensure nightwave weekly challenges are unique (#2423)
Re #2411 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2423 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
ea3e2998
代码差异
1 个文件
+20
-28
@@ -394,34 +394,26 @@ const getSeasonDailyChallenge = (pools: IRotatingSeasonChallengePools, day: numb
394
394
};
395
395
};
396
396
397
const getSeasonWeeklyChallenge = (pools: IRotatingSeasonChallengePools, week: number, id: number): ISeasonChallenge => {
398
const weekStart = EPOCH + week * 604800000;
399
const weekEnd = weekStart + 604800000;
400
const challengeId = week * 7 + id;
401
const rng = new SRng(new SRng(challengeId).randomInt(0, 100_000));
402
return {
403
_id: { $oid: "67e1bb2d9d00cb47" + challengeId.toString().padStart(8, "0") },
404
Activation: { $date: { $numberLong: weekStart.toString() } },
405
Expiry: { $date: { $numberLong: weekEnd.toString() } },
406
Challenge: rng.randomElement(pools.weekly)!
407
};
408
};
409
410
const getSeasonWeeklyHardChallenge = (
411
pools: IRotatingSeasonChallengePools,
397
const pushSeasonWeeklyChallenge = (
398
activeChallenges: ISeasonChallenge[],
399
pool: string[],
412
400
week: number,
413
401
id: number
414
): ISeasonChallenge => {
402
): void => {
415
403
const weekStart = EPOCH + week * 604800000;
416
404
const weekEnd = weekStart + 604800000;
417
405
const challengeId = week * 7 + id;
418
406
const rng = new SRng(new SRng(challengeId).randomInt(0, 100_000));
419
return {
407
let challenge: string;
408
do {
409
challenge = rng.randomElement(pool)!;
410
} while (activeChallenges.some(x => x.Challenge == challenge));
411
activeChallenges.push({
420
412
_id: { $oid: "67e1bb2d9d00cb47" + challengeId.toString().padStart(8, "0") },
421
413
Activation: { $date: { $numberLong: weekStart.toString() } },
422
414
Expiry: { $date: { $numberLong: weekEnd.toString() } },
423
Challenge: rng.randomElement(pools.hardWeekly)!
424
};
415
Challenge: challenge
416
});
425
417
};
426
418
427
419
const pushWeeklyActs = (
@@ -432,8 +424,8 @@ const pushWeeklyActs = (
432
424
const weekStart = EPOCH + week * 604800000;
433
425
const weekEnd = weekStart + 604800000;
434
426
435
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 0));
436
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 1));
427
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 0);
428
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 1);
437
429
if (pools.hasWeeklyPermanent) {
438
430
activeChallenges.push({
439
431
_id: { $oid: "67e1b96e9d00cb47" + (week * 7 + 0).toString().padStart(8, "0") },
@@ -453,14 +445,14 @@ const pushWeeklyActs = (
453
445
Expiry: { $date: { $numberLong: weekEnd.toString() } },
454
446
Challenge: "/Lotus/Types/Challenges/Seasons/Weekly/SeasonWeeklyPermanentKillEnemies"
455
447
});
456
activeChallenges.push(getSeasonWeeklyHardChallenge(pools, week, 2));
457
activeChallenges.push(getSeasonWeeklyHardChallenge(pools, week, 3));
448
pushSeasonWeeklyChallenge(activeChallenges, pools.hardWeekly, week, 2);
449
pushSeasonWeeklyChallenge(activeChallenges, pools.hardWeekly, week, 3);
458
450
} else {
459
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 2));
460
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 3));
461
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 4));
462
activeChallenges.push(getSeasonWeeklyHardChallenge(pools, week, 5));
463
activeChallenges.push(getSeasonWeeklyHardChallenge(pools, week, 6));
451
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 2);
452
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 3);
453
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 4);
454
pushSeasonWeeklyChallenge(activeChallenges, pools.hardWeekly, week, 5);
455
pushSeasonWeeklyChallenge(activeChallenges, pools.hardWeekly, week, 6);
464
456
}
465
457
};
466
458