Retry a failed portrait from the notice with the same scene builder.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-21 01:48:30 +03:00
co-authored by Cursor
parent 3c70227229
commit 3061e09d3e
32 changed files with 712 additions and 105 deletions
+31 -7
View File
@@ -11,12 +11,12 @@ public class NoticeBoardTests
{
var board = new NoticeBoard(maxSticky: 8);
Assert.True(board.TryPost(Info(), personId: 0, out var info));
Assert.True(board.TryPost(Info(), personKey: "", kind: "", out var info));
Assert.False(info.Pause);
Assert.False(board.HasPausing);
Assert.Empty(board.Sticky);
Assert.True(board.TryPost(Pausing(), personId: 0, out var warning));
Assert.True(board.TryPost(Pausing(), personKey: "", kind: "", out var warning));
Assert.True(warning.Pause);
Assert.True(board.HasPausing);
Assert.Equal("GenerationFailed", Assert.Single(board.Sticky).DefName);
@@ -29,10 +29,10 @@ public class NoticeBoardTests
var board = new NoticeBoard(maxSticky: 8);
for (var i = 0; i < 8; i++)
{
Assert.True(board.TryPost(Pausing(), personId: 0, out _));
Assert.True(board.TryPost(Pausing(), personKey: "", kind: "", out _));
}
Assert.False(board.TryPost(Pausing(), personId: 0, out var ninth));
Assert.False(board.TryPost(Pausing(), personKey: "", kind: "", out var ninth));
Assert.Equal(default, ninth);
Assert.Equal(8, board.Sticky.Count);
}
@@ -41,8 +41,8 @@ public class NoticeBoardTests
public void Dismiss_RemovesSticky_DoesNotClearTheBoardUntilTheLast()
{
var board = new NoticeBoard(maxSticky: 8);
Assert.True(board.TryPost(Pausing(), personId: 0, out var first));
Assert.True(board.TryPost(Pausing(), personId: 0, out var second));
Assert.True(board.TryPost(Pausing(), personKey: "", kind: "", out var first));
Assert.True(board.TryPost(Pausing(), personKey: "", kind: "", out var second));
Assert.True(board.TryDismiss(first.Id));
Assert.True(board.HasPausing);
@@ -71,6 +71,30 @@ public class NoticeBoardTests
Assert.Equal(NoticeSeverity.Error, sticky.Severity);
}
[Fact]
public void GenerateImage_WithoutPerson_StillPosts_WirePersonIdIsZero()
{
var board = new NoticeBoard(maxSticky: 8);
Assert.True(board.TryPost(Pausing(), personKey: "", kind: "full", out var message));
Assert.Equal(0u, message.PersonId);
Assert.Equal(EventActions.GenerateImage, message.Action);
Assert.Equal("", Assert.Single(board.Sticky).PersonKey);
}
[Fact]
public void GenerateImage_WithPerson_StoresKeyAndKind()
{
var board = new NoticeBoard(maxSticky: 8);
Assert.True(board.TryPost(Pausing(), personKey: "a0.p0", kind: "avatar", out var message));
Assert.Equal(1u, message.PersonId);
Assert.Equal(EventActions.GenerateImage, message.Action);
var sticky = Assert.Single(board.Sticky);
Assert.Equal("a0.p0", sticky.PersonKey);
Assert.Equal("avatar", sticky.Kind);
}
private static EventDef Info() => new()
{
DefName = "DayStarted",
@@ -88,6 +112,6 @@ public class NoticeBoardTests
Pause = true,
TtlMs = 0,
Trigger = EventTriggers.GenerationFailed,
Action = EventActions.None,
Action = EventActions.GenerateImage,
};
}