Enhance school simulation management by introducing a new SchoolWeekDays option, allowing configuration of the number of working days in a week. Update the API to include school week days in responses and enhance documentation to reflect these changes. Revise UI components to support the new management features, ensuring a seamless user experience when hiring and assigning staff. Update localization strings for improved clarity and consistency across the application.
This commit is contained in:
@@ -88,6 +88,8 @@ internal sealed record CatalogResponse(
|
||||
IReadOnlyList<DefInfoResponse> Things,
|
||||
IReadOnlyList<DefInfoResponse> NameSets,
|
||||
IReadOnlyList<SubjectInfoResponse> Subjects,
|
||||
DayFrameResponse? DayFrame,
|
||||
IReadOnlyList<HolidayInfoResponse> Holidays,
|
||||
MapLayout DefaultMap)
|
||||
{
|
||||
public static CatalogResponse From(DefCatalog catalog, MapLayout map, string locale) =>
|
||||
@@ -99,6 +101,8 @@ internal sealed record CatalogResponse(
|
||||
PlaceableThings(catalog, locale),
|
||||
Placeable(catalog.NameSets.Values, catalog, locale),
|
||||
PlaceableSubjects(catalog, locale),
|
||||
MapDayFrame(catalog, locale),
|
||||
PlaceableHolidays(catalog, locale),
|
||||
map);
|
||||
|
||||
private static IReadOnlyList<DefInfoResponse> Placeable<T>(IEnumerable<T> defs, DefCatalog catalog, string locale)
|
||||
@@ -140,7 +144,35 @@ internal sealed record CatalogResponse(
|
||||
def.Grades.Min,
|
||||
def.Grades.Max,
|
||||
def.HoursPerWeek,
|
||||
def.Skills.Select(share => new SubjectSkillInfo(share.Skill, share.Share)).ToArray()))
|
||||
def.Skills.Select(share => new SubjectSkillInfo(share.Skill, share.Share)).ToArray(),
|
||||
def.Room))
|
||||
.ToArray();
|
||||
|
||||
private static DayFrameResponse? MapDayFrame(DefCatalog catalog, string locale)
|
||||
{
|
||||
var frame = catalog.DayFrame;
|
||||
return frame is null
|
||||
? null
|
||||
: new DayFrameResponse(
|
||||
frame.DefName,
|
||||
catalog.Label(locale, frame),
|
||||
frame.FirstLesson,
|
||||
frame.LessonCount,
|
||||
frame.LessonMinutes,
|
||||
frame.BreakMinutes,
|
||||
frame.LongBreakAfter,
|
||||
frame.LongBreakMinutes);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<HolidayInfoResponse> PlaceableHolidays(DefCatalog catalog, string locale) =>
|
||||
catalog.Holidays.Values
|
||||
.Where(def => !def.Abstract)
|
||||
.OrderBy(def => def.DefName, StringComparer.Ordinal)
|
||||
.Select(def => new HolidayInfoResponse(
|
||||
def.DefName,
|
||||
catalog.Label(locale, def),
|
||||
def.Start,
|
||||
def.End))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
@@ -165,4 +197,17 @@ internal sealed record SubjectInfoResponse(
|
||||
int GradeMin,
|
||||
int GradeMax,
|
||||
int HoursPerWeek,
|
||||
IReadOnlyList<SubjectSkillInfo> Skills);
|
||||
IReadOnlyList<SubjectSkillInfo> Skills,
|
||||
string? Room);
|
||||
|
||||
internal sealed record DayFrameResponse(
|
||||
string DefName,
|
||||
string Label,
|
||||
string FirstLesson,
|
||||
int LessonCount,
|
||||
int LessonMinutes,
|
||||
int BreakMinutes,
|
||||
int LongBreakAfter,
|
||||
int LongBreakMinutes);
|
||||
|
||||
internal sealed record HolidayInfoResponse(string DefName, string Label, MonthDay Start, MonthDay End);
|
||||
|
||||
@@ -180,7 +180,9 @@ internal sealed record StaffingResponse(
|
||||
float Remaining,
|
||||
IReadOnlyList<UncoveredSubjectResponse> Uncovered,
|
||||
IReadOnlyList<ApplicantResponse> Applicants,
|
||||
IReadOnlyList<StaffMemberResponse> Staff);
|
||||
IReadOnlyList<StaffMemberResponse> Staff,
|
||||
IReadOnlyList<DefLabelResponse> Positions,
|
||||
IReadOnlyList<UncoveredSubjectResponse> Subjects);
|
||||
|
||||
internal sealed record UncoveredSubjectResponse(
|
||||
string DefName,
|
||||
@@ -196,7 +198,8 @@ internal sealed record ApplicantResponse(
|
||||
int Age,
|
||||
bool IsParent,
|
||||
float HourlyWageAsk,
|
||||
float MonthlyBase);
|
||||
float MonthlyBase,
|
||||
IReadOnlyList<LabeledStatResponse> Skills);
|
||||
|
||||
internal sealed record StaffMemberResponse(
|
||||
string Id,
|
||||
@@ -245,7 +248,8 @@ internal static class StaffingMapper
|
||||
applicant.Person.AgeOn(asOf),
|
||||
applicant.Person.IsParent,
|
||||
applicant.HourlyWageAsk,
|
||||
rules is null ? 0f : Staffing.MonthlyBase(rules, applicant.HourlyWageAsk)))
|
||||
rules is null ? 0f : Staffing.MonthlyBase(rules, applicant.HourlyWageAsk),
|
||||
StrongSkills(applicant.Person, catalog, locale)))
|
||||
.ToArray();
|
||||
|
||||
var staff = roster.People
|
||||
@@ -255,7 +259,42 @@ internal static class StaffingMapper
|
||||
.Select(person => Member(person, catalog, rules, locale, asOf))
|
||||
.ToArray();
|
||||
|
||||
return new StaffingResponse(allocated, payroll, remaining, uncovered, applicants, staff);
|
||||
var positions = catalog is null
|
||||
? Array.Empty<DefLabelResponse>()
|
||||
: catalog.Positions.Values
|
||||
.Where(def => !def.Abstract)
|
||||
.Select(def => new DefLabelResponse(def.DefName, catalog.Label(locale, def)))
|
||||
.OrderBy(row => row.Label, StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
|
||||
var subjects = catalog is null
|
||||
? Array.Empty<UncoveredSubjectResponse>()
|
||||
: catalog.Subjects.Values
|
||||
.Where(def => !def.Abstract)
|
||||
.Select(def => new UncoveredSubjectResponse(
|
||||
def.DefName,
|
||||
catalog.Label(locale, def),
|
||||
def.Grades.Min,
|
||||
def.Grades.Max,
|
||||
def.HoursPerWeek))
|
||||
.ToArray();
|
||||
|
||||
return new StaffingResponse(allocated, payroll, remaining, uncovered, applicants, staff, positions, subjects);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<LabeledStatResponse> StrongSkills(Person person, DefCatalog? catalog, string locale)
|
||||
{
|
||||
return person.Skills
|
||||
.OrderByDescending(pair => pair.Value)
|
||||
.ThenBy(pair => pair.Key, StringComparer.Ordinal)
|
||||
.Take(3)
|
||||
.Select(pair => new LabeledStatResponse(
|
||||
pair.Key,
|
||||
catalog is not null && catalog.Skills.TryGetValue(pair.Key, out var def)
|
||||
? catalog.Label(locale, def)
|
||||
: pair.Key,
|
||||
pair.Value.ToString()))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static StaffMemberResponse Member(
|
||||
|
||||
@@ -27,6 +27,7 @@ internal static class SchoolEndpoints
|
||||
state.MaxSchools,
|
||||
options.DefaultStartDate,
|
||||
options.GameMinutesPerRealSecond,
|
||||
options.SchoolWeekDays,
|
||||
[.. state.Schools.Select(SchoolResponse.From)]);
|
||||
})
|
||||
.WithName("GetSchools");
|
||||
@@ -474,6 +475,7 @@ internal sealed record SchoolsResponse(
|
||||
int MaxSchools,
|
||||
DateTime DefaultStartDate,
|
||||
double GameMinutesPerRealSecond,
|
||||
int SchoolWeekDays,
|
||||
IReadOnlyList<SchoolResponse> Schools);
|
||||
|
||||
internal sealed record RandomNameResponse(string Name);
|
||||
|
||||
Reference in New Issue
Block a user