Replace selectable name sets with a country that owns names and climate presets.
Create picks a country; climate is rolled from the school seed and stored. Old Slavic saves lift as Russia. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -25,9 +25,9 @@ internal static class PeopleDefValidator
|
||||
ValidateNeed(need);
|
||||
}
|
||||
|
||||
foreach (var names in catalog.NameSets.Values)
|
||||
foreach (var country in catalog.Countries.Values)
|
||||
{
|
||||
ValidateNameSet(names, catalog);
|
||||
ValidateCountry(country, catalog);
|
||||
}
|
||||
|
||||
foreach (var subject in catalog.Subjects.Values)
|
||||
@@ -547,61 +547,90 @@ internal static class PeopleDefValidator
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateNameSet(NameSetDef names, DefCatalog catalog)
|
||||
private static void ValidateCountry(CountryDef country, DefCatalog catalog)
|
||||
{
|
||||
if (country.Abstract)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (country.ClimatePresets.Count == 0)
|
||||
{
|
||||
throw new ContentLoadException($"CountryDef '{country.DefName}' needs at least one climate preset.");
|
||||
}
|
||||
|
||||
var seen = new HashSet<string>(StringComparer.Ordinal);
|
||||
foreach (var presetId in country.ClimatePresets)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(presetId) || !seen.Add(presetId))
|
||||
{
|
||||
throw new ContentLoadException($"CountryDef '{country.DefName}' has a missing or duplicate climate preset.");
|
||||
}
|
||||
|
||||
if (!catalog.ClimatePresets.TryGetValue(presetId, out var preset) || preset.Abstract)
|
||||
{
|
||||
throw new ContentLoadException($"CountryDef '{country.DefName}' references unknown ClimatePresetDef '{presetId}'.");
|
||||
}
|
||||
}
|
||||
|
||||
ValidateNameSet(country.Names ?? new NameSetDef(), catalog, country.DefName);
|
||||
}
|
||||
|
||||
private static void ValidateNameSet(NameSetDef names, DefCatalog catalog, string countryDefName)
|
||||
{
|
||||
if (!NameGrammar.IsKnownPatronymic(names.PatronymicRule))
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' has unknown patronymicRule '{names.PatronymicRule}'.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' has unknown patronymicRule '{names.PatronymicRule}'.");
|
||||
}
|
||||
|
||||
foreach (var native in names.Spoken)
|
||||
{
|
||||
if (!catalog.Skills.TryGetValue(native, out var language) || language.Abstract)
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' native language '{native}' is not a SkillDef.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' native language '{native}' is not a SkillDef.");
|
||||
}
|
||||
}
|
||||
|
||||
if (names.RelatedLanguageChance is < 0 or > 1)
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' relatedLanguageChance must be 0–1.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' relatedLanguageChance must be 0–1.");
|
||||
}
|
||||
|
||||
if (names.RelatedLanguageStdDev < 0)
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' relatedLanguageStdDev must not be negative.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' relatedLanguageStdDev must not be negative.");
|
||||
}
|
||||
|
||||
if (names.RelatedLanguageMean < 0)
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' relatedLanguageMean must not be negative.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' relatedLanguageMean must not be negative.");
|
||||
}
|
||||
|
||||
if (names.RelatedLanguageMax < 0)
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' relatedLanguageMax must not be negative.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' relatedLanguageMax must not be negative.");
|
||||
}
|
||||
|
||||
if (!NameGrammar.IsKnownGiven(names.DefaultGivenDeclension))
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' has unknown defaultGivenDeclension.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' has unknown defaultGivenDeclension.");
|
||||
}
|
||||
|
||||
if (!NameGrammar.IsKnownSurname(names.DefaultSurnameDeclension))
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' has unknown defaultSurnameDeclension.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' has unknown defaultSurnameDeclension.");
|
||||
}
|
||||
|
||||
if (names.MaleGiven.Count == 0 || names.FemaleGiven.Count == 0 || names.Surnames.Count == 0)
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' needs male names, female names and surnames.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' needs male names, female names and surnames.");
|
||||
}
|
||||
|
||||
foreach (var given in names.MaleGiven.Concat(names.FemaleGiven))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(given.Form))
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' has an empty given name.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' has an empty given name.");
|
||||
}
|
||||
|
||||
if (given.Cases is null)
|
||||
@@ -611,7 +640,7 @@ internal static class PeopleDefValidator
|
||||
: given.Declension;
|
||||
if (!NameGrammar.IsKnownGiven(model))
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' given '{given.Form}' has unknown declension '{model}'.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' given '{given.Form}' has unknown declension '{model}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -620,7 +649,7 @@ internal static class PeopleDefValidator
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(surname.Male) || string.IsNullOrWhiteSpace(surname.Female))
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' has a surname missing a gendered form.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' has a surname missing a gendered form.");
|
||||
}
|
||||
|
||||
if (surname.MaleCases is null && surname.FemaleCases is null)
|
||||
@@ -630,7 +659,7 @@ internal static class PeopleDefValidator
|
||||
: surname.Declension;
|
||||
if (!NameGrammar.IsKnownSurname(model))
|
||||
{
|
||||
throw new ContentLoadException($"NameSetDef '{names.DefName}' surname '{surname.Male}' has unknown declension '{model}'.");
|
||||
throw new ContentLoadException($"CountryDef '{countryDefName}' surname '{surname.Male}' has unknown declension '{model}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user