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) {