using HSchool.Content;
using HSchool.People;
using HSchool.Server.Api;
using HSchool.Server.Net;
using HSchool.Simulation;
namespace HSchool.Server.Game;
///
/// Work item for one school's worker. The supervisor never touches that school's World;
/// it only posts these.
///
internal abstract record WorkerCommand
{
internal sealed record Open(GameClient Client) : WorkerCommand;
internal sealed record Close(uint PlayerId) : WorkerCommand;
internal sealed record SetRunning(bool Running) : WorkerCommand;
internal sealed record SetSpeed(byte SpeedIndex) : WorkerCommand;
internal sealed record SkipEmpty : WorkerCommand;
internal sealed record DismissNotice(uint Id) : WorkerCommand;
internal sealed record DismissNoticeHttp(uint Id, TaskCompletionSource Result) : WorkerCommand;
/// Test/dev post onto the school board. Looks up an EventDef by name.
internal sealed record PostNotice(
string DefName,
string PersonKey,
string Kind,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record GetNoticePortraitTarget(
uint NoticeId,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record Dump(TaskCompletionSource Result) : WorkerCommand;
internal sealed record GetPerson(
string PersonId,
string Locale,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record GetPortraitBuildInput(
string PersonId,
string Locale,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record GetPersonLog(
string PersonId,
string Locale,
PersonLogQuery Query,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record HireStaff(
string PersonId,
string Position,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record AssignSubject(
string PersonId,
string Subject,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record UnassignSubject(
string PersonId,
string Subject,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record PinLesson(
string ClassId,
string Subject,
string RoomId,
int Day,
int Period,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record UnpinLesson(
string ClassId,
string Subject,
int Day,
int Period,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record GetDressRules(TaskCompletionSource Result) : WorkerCommand;
internal sealed record SetDressRules(
DressRulePair? PendingStudents,
DressRulePair? PendingStaff,
TaskCompletionSource Result) : WorkerCommand;
internal sealed record GetSpeechRules(TaskCompletionSource Result) : WorkerCommand;
internal sealed record SetSpeechRules(
string? PendingStudents,
string? PendingStaff,
TaskCompletionSource Result) : WorkerCommand;
}
internal sealed record PostedNotice(uint Id, string DefName, bool Pause);
internal enum NoticePortraitTargetError
{
None,
UnknownSchool,
UnknownNotice,
CannotGenerate,
}
internal sealed record NoticePortraitTarget(
NoticePortraitTargetError Error,
string PersonId,
PortraitKind Kind)
{
public static NoticePortraitTarget UnknownSchool { get; } =
new(NoticePortraitTargetError.UnknownSchool, "", PortraitKind.Full);
public static NoticePortraitTarget UnknownNotice { get; } =
new(NoticePortraitTargetError.UnknownNotice, "", PortraitKind.Full);
public static NoticePortraitTarget CannotGenerate { get; } =
new(NoticePortraitTargetError.CannotGenerate, "", PortraitKind.Full);
public static NoticePortraitTarget Ok(string personId, PortraitKind kind) =>
new(NoticePortraitTargetError.None, personId, kind);
}