Event-driven dialog queue, story flag command, mod unit tests

Push-based event chains, runtime fixes (single end, goto lifecycle, if,
busy box, held delay, empty options, timed/animated/effect actions), the
'flag name value' DSL command, autoplay --dialogs=N, 19 mod unit tests.
This commit is contained in:
cthangover committed 2026-10-21 12:31:52 +02:00
1 parent 9f86bdbb0c
commit bd55716349
86 files changed
+3173 -2181

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
namespace Cthangover.Mods.Dialog.Tests
{
using System.Threading.Tasks;
using Cthangover.Core.Mods.Testing;
using Cthangover.Core.Scenes;
using Cthangover.Core.Settings;
using Cthangover.Mods.Dialog.Scenarios;
/// <summary>
/// The scenario <c>flag</c> command sets a story flag of the game: once the
/// dialog reaches it, scenario conditions see the value, the game state
/// holds it (so saves carry it), and conditions are rescanned.
/// </summary>
public class StoryFlagTests
{
private const string Flag = "__test_story_flag";
[ModTest("flags/flag_command_sets_game_flag", TimeoutSeconds = 10)]
static async Task FlagCommandSetsGameFlag(ModTestContext ctx)
{
var stage = await DialogStage.Create();
var flags = GameData.Instance.Runtime.Flags;
try
{
var dlg = new ScenarioConverter().Convert($"flag {Flag} open\nend\n");
var versionBefore = ConditionStateMonitor.Version;
ModAssert.False(ScenarioCondition.Evaluate($"{Flag} == \"open\""), "condition false before the dialog");
ModAssert.True(stage.Box.SetDialogQueueAndRun(dlg, null, 0, null), "dialog starts");
ModAssert.True(ScenarioCondition.Evaluate($"{Flag} == \"open\""), "condition sees the flag");
ModAssert.Equal("open", flags.TryGetValue(Flag, out var value) ? value : null, "game state holds the flag");
ModAssert.True(ConditionStateMonitor.Version > versionBefore, "conditions are rescanned");
}
finally
{
flags.Remove(Flag);
stage.Free();
}
}
}
}