add shel
This commit is contained in:
@@ -29,6 +29,11 @@ internal static class PeopleDefValidator
|
||||
ValidateNameSet(names);
|
||||
}
|
||||
|
||||
foreach (var subject in catalog.Subjects.Values)
|
||||
{
|
||||
ValidateSubject(subject, catalog);
|
||||
}
|
||||
|
||||
RequireBuildInputs(catalog);
|
||||
}
|
||||
|
||||
@@ -218,6 +223,43 @@ internal static class PeopleDefValidator
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateSubject(SubjectDef subject, DefCatalog catalog)
|
||||
{
|
||||
if (subject.HoursPerWeek < 0)
|
||||
{
|
||||
throw new ContentLoadException($"SubjectDef '{subject.DefName}' hoursPerWeek cannot be negative.");
|
||||
}
|
||||
|
||||
if (subject.Grades.Min < 1 || subject.Grades.Max > 11 || subject.Grades.Min > subject.Grades.Max)
|
||||
{
|
||||
throw new ContentLoadException($"SubjectDef '{subject.DefName}' grades must be 1–11 with min ≤ max.");
|
||||
}
|
||||
|
||||
if (subject.Skills.Count == 0)
|
||||
{
|
||||
throw new ContentLoadException($"SubjectDef '{subject.DefName}' needs at least one skill.");
|
||||
}
|
||||
|
||||
var seen = new HashSet<string>(StringComparer.Ordinal);
|
||||
foreach (var share in subject.Skills)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(share.Skill) || !seen.Add(share.Skill))
|
||||
{
|
||||
throw new ContentLoadException($"SubjectDef '{subject.DefName}' has a missing or duplicate skill.");
|
||||
}
|
||||
|
||||
if (!catalog.Skills.TryGetValue(share.Skill, out var skill) || skill.Abstract)
|
||||
{
|
||||
throw new ContentLoadException($"SubjectDef '{subject.DefName}' references unknown SkillDef '{share.Skill}'.");
|
||||
}
|
||||
|
||||
if (share.Share < 0)
|
||||
{
|
||||
throw new ContentLoadException($"SubjectDef '{subject.DefName}' skill '{share.Skill}' share cannot be negative.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateNameSet(NameSetDef names)
|
||||
{
|
||||
if (!NameGrammar.IsKnownPatronymic(names.PatronymicRule))
|
||||
|
||||
Reference in New Issue
Block a user