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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user