Files
h-school/src/HSchool.Simulation/SchoolNames.cs
T
Leonid Pershin 5eabc90d53
ci / server (push) Failing after 3m43s
ci / client (push) Successful in 15s
Enhance school day structure and decision-making for lunch breaks
- Updated `ai.md` to clarify the mechanics of hunger restoration and the importance of lunch breaks in the school schedule.
- Revised `schedule.md` to detail the new lunch break structure, allowing for separate sittings for different grade levels.
- Enhanced `Decision.cs` and `DecisionPlanner.cs` to incorporate logic for lunch breaks, ensuring that students only leave lessons during their designated lunch windows.
- Updated `DayFrameDef` and related classes to support multiple lunch breaks and validate their configurations.
- Adjusted tests to validate the new decision-making logic regarding lunch breaks and hunger management, ensuring robust functionality.
- Improved localization strings to reflect changes in the school day structure and lunch functionalities.
2026-08-19 23:17:16 +03:00

29 lines
809 B
C#

namespace HSchool.Simulation;
/// <summary>
/// The rules a school name has to pass. A name arrives from a browser, so it is trimmed and
/// stripped before anything stores it.
/// </summary>
public static class SchoolNames
{
/// <summary>Trims, strips control characters and enforces the length limit.</summary>
public static bool TryNormalize(string? name, out string normalized)
{
normalized = string.Empty;
if (string.IsNullOrWhiteSpace(name))
{
return false;
}
var cleaned = new string(name.Where(character => !char.IsControl(character)).ToArray()).Trim();
if (cleaned.Length == 0 || cleaned.Length > School.MaxNameLength)
{
return false;
}
normalized = cleaned;
return true;
}
}