Add EventDef notices, morning and lesson bells, and info toasts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 20:46:33 +03:00
co-authored by Cursor
parent ea3f5c7bf1
commit a554738084
38 changed files with 952 additions and 22 deletions
@@ -0,0 +1,57 @@
using HSchool.Content;
namespace HSchool.Content.Tests;
public class EventDefTests
{
private readonly CatalogLoader _loader = new();
[Fact]
public void VanillaCore_LoadsDayAndLessonStarted()
{
var catalog = LoadVanilla();
Assert.True(catalog.Events.ContainsKey("DayStarted"));
Assert.Equal(EventSeverities.Info, catalog.Events["DayStarted"].Severity);
Assert.False(catalog.Events["DayStarted"].Pause);
Assert.Equal(8000, catalog.Events["DayStarted"].TtlMs);
Assert.Equal(EventTriggers.DayStart, catalog.Events["DayStarted"].Trigger);
Assert.Equal(EventActions.None, catalog.Events["DayStarted"].Action);
Assert.True(catalog.Events.ContainsKey("LessonStarted"));
Assert.Equal(EventSeverities.Info, catalog.Events["LessonStarted"].Severity);
Assert.False(catalog.Events["LessonStarted"].Pause);
Assert.Equal(8000, catalog.Events["LessonStarted"].TtlMs);
Assert.Equal(EventTriggers.LessonStart, catalog.Events["LessonStarted"].Trigger);
Assert.Equal(EventActions.None, catalog.Events["LessonStarted"].Action);
Assert.True(catalog.Events.ContainsKey("GenerationFailed"));
Assert.Equal(EventTriggers.GenerationFailed, catalog.Events["GenerationFailed"].Trigger);
Assert.Equal("Начало дня", catalog.Label("ru", catalog.Events["DayStarted"]));
Assert.Equal("The day has started", catalog.Label("en", catalog.Events["DayStarted"]));
}
[Fact]
public void UnknownTrigger_FailsTheCatalog()
{
var documents = PackDocuments.FromDirectory(
CatalogLoader.CorePackId,
Path.Combine(AppContext.BaseDirectory, "vanilla"))
.Append(PackDocuments.Def(
CatalogLoader.CorePackId,
"events",
"bad",
"""{ "defName": "BadMoon", "severity": "info", "ttlMs": 1, "trigger": "fullMoon", "action": "none" }"""))
.ToList();
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load([CatalogLoader.CorePackId], documents));
Assert.Contains("trigger", ex.Message, StringComparison.Ordinal);
Assert.Contains("fullMoon", ex.Message, StringComparison.Ordinal);
}
private DefCatalog LoadVanilla()
{
var root = Path.Combine(AppContext.BaseDirectory, "vanilla");
return _loader.Load([CatalogLoader.CorePackId], PackDocuments.FromDirectory(CatalogLoader.CorePackId, root));
}
}