Compare commits

...
1 Commits
Author SHA1 Message Date
Leonid PershinandClaude Opus 4.8 4b91b60f38 Calendar: expose time of day (hour/minute)
CI / build-test (push) Successful in 1m7s
Add Hour, Minute and MinuteOfDay to Calendar, decomposing DayProgress into
a 24x60 in-game clock so games can show a date and time, not just the day
number. Covered by a test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 13:09:58 +03:00
2 changed files with 22 additions and 0 deletions
+9
View File
@@ -51,6 +51,15 @@ public sealed class Calendar
return (float)(days - Math.Floor(days));
}
}
/// <summary>Minutes elapsed in the current day, 01439 (a day is 24×60 in-game minutes).</summary>
public int MinuteOfDay => (int)(DayProgress * 1440f) % 1440;
/// <summary>Hour of the current day, 023.</summary>
public int Hour => MinuteOfDay / 60;
/// <summary>Minute of the current hour, 059.</summary>
public int Minute => MinuteOfDay % 60;
}
/// <summary>Wires the in-game calendar into the engine.</summary>
@@ -41,6 +41,19 @@ public class CalendarTests
Assert.Equal(0.5f, calendar.DayProgress, 5);
}
[Fact]
public void HourAndMinute_DecomposeTimeOfDay()
{
var clock = new GameClock();
var calendar = new Calendar(clock, secondsPerDay: 1440f); // one minute per in-game minute
clock.Advance(14 * 60 + 30); // 14:30
Assert.Equal(14, calendar.Hour);
Assert.Equal(30, calendar.Minute);
Assert.Equal(14 * 60 + 30, calendar.MinuteOfDay);
}
[Fact]
public void Pause_DoesNotAdvanceTheCalendar()
{