Add start game time feature to world generation; update API and UI to support custom start dates for in-world calendar

This commit is contained in:
Leonid Pershin
2026-08-16 19:58:32 +03:00
parent 3b7fca1495
commit 9d1e3c29c7
12 changed files with 150 additions and 5 deletions
@@ -58,4 +58,20 @@ public sealed class GameTimeTests
{
Assert.Equal(expected, GameTime.IsValidTimeScale(scale));
}
[Fact]
public void ResolveStart_defaults_and_normalises()
{
Assert.Equal(GameTime.DefaultStart, GameTime.ResolveStart(null));
Assert.Equal(
new DateTime(1999, 12, 31, 23, 45, 0, DateTimeKind.Unspecified),
GameTime.ResolveStart(new DateTime(1999, 12, 31, 23, 45, 59, DateTimeKind.Utc)));
}
[Fact]
public void ResolveStart_rejects_out_of_range_years()
{
Assert.Throws<ArgumentOutOfRangeException>(() =>
GameTime.ResolveStart(new DateTime(10000, 1, 1)));
}
}
@@ -45,6 +45,29 @@ public sealed class WorldGenerationServiceTests : IDisposable
Assert.Equal("Taken", Assert.Single(await _store.ListAsync()).Name);
}
[Fact]
public async Task StartAsync_uses_requested_start_game_time_on_the_pending_clock()
{
using var service = CreateService(maxConcurrentWorlds: 2);
var start = new DateTime(1995, 6, 15, 8, 30, 0, DateTimeKind.Unspecified);
var summary = await service.StartAsync(new CreateWorldRequest
{
Name = "Custom clock",
Latitude = 31.8966010,
Longitude = -100.4858591,
SizeKm = 5,
StartGameTime = start,
}, CancellationToken.None);
Assert.NotNull(summary.Clock);
Assert.Equal(start, summary.Clock.GameTime);
var stored = await _store.GetSummaryAsync(summary.Id);
Assert.NotNull(stored?.Clock);
Assert.Equal(start, stored.Clock.GameTime);
}
private WorldGenerationService CreateService(int maxConcurrentWorlds)
{
// The capacity check runs before any Overpass work, so this generator is never invoked by the