namespace HSchool.Server.Game;
///
/// Work item handed from a request or connection thread to the loop thread. Schools are
/// single-threaded, so every mutation and every read of live state arrives as one of these.
///
internal abstract record GameCommand
{
internal sealed record CreateSchool(
string Name,
DateTime StartDate,
TaskCompletionSource Result) : GameCommand;
internal sealed record DeleteSchool(int SchoolId, TaskCompletionSource Result) : GameCommand;
internal sealed record SuggestName(TaskCompletionSource Result) : GameCommand;
/// A connection starts watching a school; its calendar starts running.
internal sealed record OpenSchool(uint PlayerId, int SchoolId) : GameCommand;
///
/// Stops watching. The school id travels with the command because the connection may already
/// be gone from the registry by the time the loop thread gets here.
///
internal sealed record CloseSchool(uint PlayerId, int SchoolId) : GameCommand;
internal sealed record SetRunning(uint PlayerId, bool Running) : GameCommand;
internal sealed record SetSpeed(uint PlayerId, byte SpeedIndex) : GameCommand;
}