Add portrait settings support to school creation and update related API and UI components. Enhance error handling for invalid presets and ensure proper cloning of settings. Update tests to validate new functionality.
This commit is contained in:
@@ -48,6 +48,20 @@ internal static class SchoolEndpoints
|
||||
GameCommandQueue commands,
|
||||
CancellationToken cancellationToken) =>
|
||||
{
|
||||
SwarmUiConfigFile? portraitSettings = null;
|
||||
if (request.PortraitSettings is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
request.PortraitSettings.Validate();
|
||||
portraitSettings = SwarmUiConfigFile.Clone(request.PortraitSettings);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return Problem(StatusCodes.Status400BadRequest, "invalid-portrait-settings", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
var command = new GameCommand.CreateSchool(
|
||||
request.Name ?? string.Empty,
|
||||
DateTime.SpecifyKind(request.StartDate, DateTimeKind.Utc),
|
||||
@@ -56,6 +70,7 @@ internal static class SchoolEndpoints
|
||||
request.CountryId,
|
||||
request.NativeLanguage,
|
||||
request.Seed,
|
||||
portraitSettings,
|
||||
NewCompletion<SchoolCreationOutcome>());
|
||||
commands.Enqueue(command);
|
||||
|
||||
@@ -802,7 +817,8 @@ internal sealed record CreateSchoolRequest(
|
||||
MapLayout? Map,
|
||||
string? CountryId,
|
||||
string? NativeLanguage,
|
||||
int? Seed);
|
||||
int? Seed,
|
||||
SwarmUiConfigFile? PortraitSettings);
|
||||
|
||||
internal sealed record SchoolResponse(
|
||||
int Id,
|
||||
|
||||
Reference in New Issue
Block a user