refactor(mission): migrate MissionProgressService + MissionAssembler to IGameCalendarService
Swaps 6 JstPeriod.* callsites in mission code to IGameCalendarService. Also drops the manual `jstNow = now.ToOffset(+9).AddHours(-2)` shift in MissionAssembler — BP monthly missions now key off UTC calendar month, and the start/end wire timestamps become UTC-midnight month boundaries. This matches the plan's all-UTC discipline; wire fidelity for BP monthlies is not shipped yet. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -9,24 +9,27 @@ public sealed class MissionProgressService : IMissionProgressService
|
||||
private readonly IMissionCatalogRepository _catalog;
|
||||
private readonly IViewerMissionRepository _viewerRepo;
|
||||
private readonly TimeProvider _time;
|
||||
private readonly IGameCalendarService _calendar;
|
||||
|
||||
public MissionProgressService(
|
||||
SVSimDbContext db,
|
||||
IMissionCatalogRepository catalog,
|
||||
IViewerMissionRepository viewerRepo,
|
||||
TimeProvider time)
|
||||
TimeProvider time,
|
||||
IGameCalendarService calendar)
|
||||
{
|
||||
_db = db;
|
||||
_catalog = catalog;
|
||||
_viewerRepo = viewerRepo;
|
||||
_time = time;
|
||||
_calendar = calendar;
|
||||
}
|
||||
|
||||
public async Task RecordEventAsync(long viewerId, IReadOnlyList<string> eventKeys, int delta = 1, CancellationToken ct = default)
|
||||
{
|
||||
if (eventKeys.Count == 0) return;
|
||||
var now = _time.GetUtcNow();
|
||||
var periods = JstPeriod.AllPeriods(now);
|
||||
var periods = _calendar.AllPeriods(now);
|
||||
|
||||
// 1. Increment counters for every (key, period).
|
||||
foreach (var key in eventKeys)
|
||||
@@ -50,7 +53,7 @@ public sealed class MissionProgressService : IMissionProgressService
|
||||
var atLevel = catalogRows.FirstOrDefault(r => r.Level == viewerRow.Level);
|
||||
if (atLevel is null || atLevel.EventType is null) continue;
|
||||
|
||||
var count = await _viewerRepo.GetCounterAsync(viewerId, atLevel.EventType, JstPeriod.AllTime, ct);
|
||||
var count = await _viewerRepo.GetCounterAsync(viewerId, atLevel.EventType, GameCalendarService.AllTime, ct);
|
||||
if (count >= atLevel.RequireNumber && viewerRow.AchievementStatus == 0)
|
||||
{
|
||||
viewerRow.AchievementStatus = 1;
|
||||
|
||||
Reference in New Issue
Block a user