From 70ec063c0f1606e042ed7d37a4d49841d2f5dc01 Mon Sep 17 00:00:00 2001 From: gamer147 Date: Sat, 4 Jul 2026 11:49:54 -0400 Subject: [PATCH] refactor(login-bonus): migrate LoginBonusService to IGameCalendarService IsDue() collapses from the JST DayKey comparison boilerplate to a single _calendar.ResetReady(viewer.LastLoginBonusClaimedAt) call. Co-Authored-By: Claude Opus 4.7 --- .../Services/LoginBonusService.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/SVSim.EmulatedEntrypoint/Services/LoginBonusService.cs b/SVSim.EmulatedEntrypoint/Services/LoginBonusService.cs index 2c785d42..500eb826 100644 --- a/SVSim.EmulatedEntrypoint/Services/LoginBonusService.cs +++ b/SVSim.EmulatedEntrypoint/Services/LoginBonusService.cs @@ -11,21 +11,17 @@ public class LoginBonusService : ILoginBonusService { private readonly IGameConfigService _config; private readonly TimeProvider _time; + private readonly IGameCalendarService _calendar; - public LoginBonusService(IGameConfigService config, TimeProvider time) + public LoginBonusService(IGameConfigService config, TimeProvider time, IGameCalendarService calendar) { _config = config; _time = time; + _calendar = calendar; } - public bool IsDue(Viewer viewer) - { - if (viewer.LastLoginBonusClaimedAt is null) return true; - var now = _time.GetUtcNow(); - var lastClaim = new DateTimeOffset( - DateTime.SpecifyKind(viewer.LastLoginBonusClaimedAt.Value, DateTimeKind.Utc)); - return JstPeriod.DayKey(lastClaim) != JstPeriod.DayKey(now); - } + public bool IsDue(Viewer viewer) => + _calendar.ResetReady(viewer.LastLoginBonusClaimedAt); public async Task GrantIfDueAsync(IInventoryTransaction tx, CancellationToken ct = default) {