33 lines
991 B
C#
33 lines
991 B
C#
namespace HSchool.Server.Game;
|
|
|
|
/// <summary>
|
|
/// Swarm failures raise <c>GenerationFailed</c> on the school's board. Success does not, and a
|
|
/// missing person id never posts.
|
|
/// </summary>
|
|
internal static class GenerationFailedPoster
|
|
{
|
|
public const string DefName = "GenerationFailed";
|
|
|
|
public static bool ShouldPost(PortraitGenerationOutcome outcome) =>
|
|
outcome is PortraitGenerationOutcome.Unavailable or PortraitGenerationOutcome.TimedOut;
|
|
|
|
public static void TryEnqueue(
|
|
GameCommandQueue commands,
|
|
int schoolId,
|
|
string personId,
|
|
PortraitKind kind)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(personId))
|
|
{
|
|
return;
|
|
}
|
|
|
|
commands.Enqueue(new GameCommand.PostSchoolNotice(
|
|
schoolId,
|
|
DefName,
|
|
personId,
|
|
PortraitKindParser.ToApiValue(kind),
|
|
new TaskCompletionSource<PostedNotice?>(TaskCreationOptions.RunContinuationsAsynchronously)));
|
|
}
|
|
}
|