Add HSchool.Content project for JSONC definitions, catalog, and map validation. Update solution structure to include new content and tests projects. Enhance school management to support mod packs and map instances, ensuring proper loading and validation. Revise documentation to reflect these changes and update tests for new functionality.
ci / server (push) Failing after 3m36s
ci / client (push) Successful in 13s

This commit is contained in:
Leonid Pershin
2026-08-18 14:35:09 +03:00
parent 37c39a3beb
commit 1bc75244e8
55 changed files with 2289 additions and 59 deletions
+31 -3
View File
@@ -1,11 +1,29 @@
using System.Text.Json;
using HSchool.Content;
using HSchool.Simulation;
using Microsoft.Extensions.Options;
namespace HSchool.Server.Game;
/// <summary>On-disk record of one school. Extra JSON fields are ignored so later slices can grow it.</summary>
internal sealed record SchoolSave(int Format, int Id, string Name, DateTime GameTime, bool Running, int SpeedIndex);
internal sealed class SchoolSave
{
public int Format { get; init; }
public int Id { get; init; }
public string Name { get; init; } = "";
public DateTime GameTime { get; init; }
public bool Running { get; init; }
public int SpeedIndex { get; init; }
public IReadOnlyList<string>? ModIds { get; init; }
public MapLayout? Map { get; init; }
}
/// <summary>Allocates school ids that survive a process restart.</summary>
internal sealed record SchoolSaveIndex(int NextId);
@@ -16,7 +34,7 @@ internal sealed record SchoolSaveIndex(int NextId);
/// </summary>
internal sealed class SchoolStore
{
public const int CurrentFormat = 1;
public const int CurrentFormat = 2;
private const string IndexFileName = "index.json";
@@ -99,7 +117,17 @@ internal sealed class SchoolStore
continue;
}
saves.Add(save with { GameTime = DateTime.SpecifyKind(save.GameTime, DateTimeKind.Utc) });
saves.Add(new SchoolSave
{
Format = save.Format,
Id = save.Id,
Name = save.Name,
GameTime = DateTime.SpecifyKind(save.GameTime, DateTimeKind.Utc),
Running = save.Running,
SpeedIndex = save.SpeedIndex,
ModIds = save.ModIds,
Map = save.Map,
});
}
catch (Exception ex)
{