Enhance staffing management in school simulation by introducing API endpoints for hiring staff and assigning subjects. Implement payroll cap validation to ensure hiring and subject assignments do not exceed the allocated budget. Update the simulation options to include a monthly payroll cap and revise related classes to support new staffing functionalities. Enhance documentation to reflect these changes and update tests to validate the new features.

This commit is contained in:
Leonid Pershin
2026-08-19 00:19:09 +03:00
parent c189578680
commit 94842ab192
24 changed files with 1444 additions and 27 deletions
@@ -171,6 +171,27 @@ internal sealed class GameLoopService(
case GameCommand.GetPerson getPerson:
HandleGetPerson(getPerson);
break;
case GameCommand.HireStaff hire:
HandleStaffing(
hire.SchoolId,
new WorkerCommand.HireStaff(hire.PersonId, hire.Position, hire.Result),
hire.Result);
break;
case GameCommand.AssignSubject assign:
HandleStaffing(
assign.SchoolId,
new WorkerCommand.AssignSubject(assign.PersonId, assign.Subject, assign.Result),
assign.Result);
break;
case GameCommand.UnassignSubject unassign:
HandleStaffing(
unassign.SchoolId,
new WorkerCommand.UnassignSubject(unassign.PersonId, unassign.Subject, unassign.Result),
unassign.Result);
break;
}
}
@@ -183,6 +204,14 @@ internal sealed class GameLoopService(
}
}
private void HandleStaffing(int schoolId, WorkerCommand command, TaskCompletionSource<StaffingOutcome> result)
{
if (!_workers.TryGetValue(schoolId, out var worker) || !worker.Post(command))
{
result.TrySetResult(Staffing.UnknownSchool());
}
}
/// <summary>
/// A school's thread died. Drop it from the table so the menu stops drawing a card whose clock
/// never moves again, and tell anybody watching it to go back to the menu. The save file stays