Enhance school simulation and management by integrating roster functionality, allowing for the installation and persistence of student and staff data. Update the school architecture to include a roster alongside existing components, ensuring proper validation against map layouts. Revise room definitions to support homeroom designations and update related tests to validate new functionalities and ensure robustness in roster handling.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using Arch.Core;
|
||||
using HSchool.People;
|
||||
|
||||
namespace HSchool.Simulation;
|
||||
|
||||
/// <summary>Turns roster records into Arch entities. Parents have no map location — by design.</summary>
|
||||
public static class RosterSpawner
|
||||
{
|
||||
public static void Spawn(World world, Roster roster)
|
||||
{
|
||||
foreach (var schoolClass in roster.Classes)
|
||||
{
|
||||
world.Create(
|
||||
new ClassIdentity(
|
||||
schoolClass.Id,
|
||||
schoolClass.Year,
|
||||
schoolClass.Letter,
|
||||
schoolClass.RoomId,
|
||||
schoolClass.Capacity));
|
||||
}
|
||||
|
||||
foreach (var person in roster.People)
|
||||
{
|
||||
world.Create(
|
||||
new PersonIdentity(person.Id, person.FamilyId, person.Female, person.BirthDate, person.Name),
|
||||
new PersonBody(person.Numbers, person.Choices),
|
||||
new PersonSkills(person.Skills),
|
||||
new PersonTraits(person.Traits),
|
||||
new PersonNeeds(new Dictionary<string, float>(person.Needs, StringComparer.Ordinal)),
|
||||
new PersonRoles(
|
||||
person.IsStudent,
|
||||
person.IsStaff,
|
||||
person.IsParent,
|
||||
person.ClassId,
|
||||
person.Position,
|
||||
person.WorkplaceRoomId));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user