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
@@ -0,0 +1,41 @@
namespace HSchool.Content.Tests;
internal sealed class RecordingLog : IContentLog
{
public List<string> Warnings { get; } = [];
public void Warning(string message) => Warnings.Add(message);
}
internal static class PackDocuments
{
public static ContentDocument Def(string packId, string folder, string file, string jsonc) =>
new(packId, $"defs/{folder}/{file}.jsonc", jsonc);
public static ContentDocument Patch(string packId, string file, string jsonc) =>
new(packId, $"patches/{file}.jsonc", jsonc);
public static ContentDocument Locale(string packId, string language, string jsonc) =>
new(packId, $"localizations/{language}.jsonc", jsonc);
public static ContentDocument Map(string packId, string jsonc) =>
new(packId, "maps/default.jsonc", jsonc);
public static IReadOnlyList<ContentDocument> FromDirectory(string packId, string packRoot)
{
var documents = new List<ContentDocument>();
foreach (var path in Directory.EnumerateFiles(packRoot, "*.*", SearchOption.AllDirectories))
{
if (!path.EndsWith(".jsonc", StringComparison.OrdinalIgnoreCase)
&& !path.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
{
continue;
}
var relative = Path.GetRelativePath(packRoot, path).Replace('\\', '/');
documents.Add(new ContentDocument(packId, relative, File.ReadAllText(path)));
}
return documents;
}
}