Implement phase 35 dress appropriateness and school rules.

Adds outfit evaluation, morning home dressing, locker-room ChangeClothes with day-log events, PE/weather AI goals, dress-rules API, and tests.
This commit is contained in:
Leonid Pershin
2026-08-20 05:16:52 +03:00
parent 5b63c72806
commit 6a0d5a9886
32 changed files with 1894 additions and 25 deletions
+72
View File
@@ -312,6 +312,53 @@ internal static class SchoolEndpoints
})
.WithName("GenerateSchoolPersonPortrait");
schools.MapGet("/{id:int}/dress-rules", async (
int id,
GameCommandQueue commands,
CancellationToken cancellationToken) =>
{
var command = new GameCommand.GetDressRules(id, NewCompletion<DressRulesOutcome>());
commands.Enqueue(command);
var outcome = await command.Result.Task.WaitAsync(CommandTimeout, cancellationToken);
return DressRulesHttp(outcome);
})
.WithName("GetSchoolDressRules");
schools.MapPost("/{id:int}/dress-rules", async (
int id,
SetDressRulesRequest request,
GameCommandQueue commands,
CancellationToken cancellationToken) =>
{
DressRulePair? students = null;
if (request.Students is { } studentDto)
{
if (!DressRulesValidation.TryParse(studentDto, out var parsed, out var studentError))
{
return DressRulesBadRequest(studentError);
}
students = parsed;
}
DressRulePair? staff = null;
if (request.Staff is { } staffDto)
{
if (!DressRulesValidation.TryParse(staffDto, out var parsed, out var staffError))
{
return DressRulesBadRequest(staffError);
}
staff = parsed;
}
var command = new GameCommand.SetDressRules(id, students, staff, NewCompletion<DressRulesOutcome>());
commands.Enqueue(command);
var outcome = await command.Result.Task.WaitAsync(CommandTimeout, cancellationToken);
return DressRulesHttp(outcome);
})
.WithName("SetSchoolDressRules");
schools.MapGet("/{id:int}/staffing", (
int id,
string? lang,
@@ -678,6 +725,31 @@ internal static class SchoolEndpoints
return Results.Problem(detail: detail, statusCode: statusCode, title: code, extensions: extensions);
}
private static IResult DressRulesHttp(DressRulesOutcome outcome) =>
outcome.Error switch
{
DressRulesError.None => Results.Ok(outcome.Rules),
DressRulesError.UnknownSchool => Problem(
StatusCodes.Status404NotFound,
"unknown-school",
"That school does not exist."),
_ => DressRulesBadRequest(outcome.Error),
};
private static IResult DressRulesBadRequest(DressRulesError error) =>
error switch
{
DressRulesError.UnknownForm => Problem(
StatusCodes.Status400BadRequest,
"unknown-form",
"That form policy is not recognized."),
DressRulesError.UnknownColor => Problem(
StatusCodes.Status400BadRequest,
"unknown-color",
"That colour policy is not recognized."),
_ => Problem(StatusCodes.Status400BadRequest, "invalid-query", "The dress rules request is not valid."),
};
}
/// <summary>Body of <c>POST /api/schools</c>. The start date is a game calendar date, not a real one.</summary>