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:
Leonid Pershin
2026-08-20 02:55:13 +03:00
co-authored by Cursor
parent 450495f666
commit 1b66c89cd7
58 changed files with 902 additions and 477 deletions
+9 -9
View File
@@ -15,12 +15,12 @@ public sealed record ApplicantPool(int Week, int NextIndex, IReadOnlyList<Applic
DefCatalog catalog,
Roster roster,
int schoolSeed,
string nameSetId,
string countryId,
DateTime asOf,
string? nativeLanguage = null)
{
var week = ApplicantWeeks.Id(asOf);
return Fill(catalog, roster, schoolSeed, nameSetId, asOf, new ApplicantPool(week, 0, []), nativeLanguage: nativeLanguage);
return Fill(catalog, roster, schoolSeed, countryId, asOf, new ApplicantPool(week, 0, []), nativeLanguage: nativeLanguage);
}
/// <summary>
@@ -31,7 +31,7 @@ public sealed record ApplicantPool(int Week, int NextIndex, IReadOnlyList<Applic
DefCatalog catalog,
Roster roster,
int schoolSeed,
string nameSetId,
string countryId,
DateTime asOf,
string? nativeLanguage = null)
{
@@ -44,7 +44,7 @@ public sealed record ApplicantPool(int Week, int NextIndex, IReadOnlyList<Applic
var pool = this;
for (var week = Week + 1; week <= target; week++)
{
pool = Step(pool, catalog, roster, schoolSeed, nameSetId, asOf, week, nativeLanguage);
pool = Step(pool, catalog, roster, schoolSeed, countryId, asOf, week, nativeLanguage);
}
return pool;
@@ -93,7 +93,7 @@ public sealed record ApplicantPool(int Week, int NextIndex, IReadOnlyList<Applic
DefCatalog catalog,
Roster roster,
int schoolSeed,
string nameSetId,
string countryId,
DateTime asOf,
int week,
string? nativeLanguage)
@@ -113,7 +113,7 @@ public sealed record ApplicantPool(int Week, int NextIndex, IReadOnlyList<Applic
catalog,
roster,
schoolSeed,
nameSetId,
countryId,
asOf,
new ApplicantPool(week, current.NextIndex, staying),
rng,
@@ -124,16 +124,16 @@ public sealed record ApplicantPool(int Week, int NextIndex, IReadOnlyList<Applic
DefCatalog catalog,
Roster roster,
int schoolSeed,
string nameSetId,
string countryId,
DateTime asOf,
ApplicantPool current,
Random? rng = null,
string? nativeLanguage = null)
{
var rules = RequireRules(catalog);
if (!catalog.NameSets.TryGetValue(nameSetId, out var names))
if (!catalog.TryGetCountryNames(countryId, out var names))
{
throw new ArgumentException($"Unknown name set '{nameSetId}'.", nameof(nameSetId));
throw new ArgumentException($"Unknown country '{countryId}'.", nameof(countryId));
}
var native = NativeLanguages.Pick(names, schoolSeed, nativeLanguage, rollIfOmitted: false);
+26
View File
@@ -0,0 +1,26 @@
namespace HSchool.People;
/// <summary>
/// A country lists climate presets; the school rolls one at birth from the school seed.
/// Reloads without a stored pick take the first listed preset so old saves stay put.
/// </summary>
public static class CountryClimate
{
public static string? Pick(CountryDef country, int schoolSeed, bool rollIfOmitted)
{
ArgumentNullException.ThrowIfNull(country);
var presets = country.ClimatePresets;
if (presets.Count == 0)
{
return null;
}
if (!rollIfOmitted || presets.Count == 1)
{
return presets[0];
}
var rng = new Random(Seed.ForSchool(schoolSeed, Seed.ClimatePresetSalt));
return presets[rng.Next(presets.Count)];
}
}
+4 -4
View File
@@ -15,17 +15,17 @@ public static class RosterGenerator
DefCatalog catalog,
MapLayout map,
int schoolSeed,
string nameSetId,
string countryId,
DateTime? asOf = null,
string? nativeLanguage = null)
{
ArgumentNullException.ThrowIfNull(catalog);
ArgumentNullException.ThrowIfNull(map);
ArgumentException.ThrowIfNullOrWhiteSpace(nameSetId);
ArgumentException.ThrowIfNullOrWhiteSpace(countryId);
if (!catalog.NameSets.TryGetValue(nameSetId, out var names))
if (!catalog.TryGetCountryNames(countryId, out var names))
{
throw new ArgumentException($"Unknown name set '{nameSetId}'.", nameof(nameSetId));
throw new ArgumentException($"Unknown country '{countryId}'.", nameof(countryId));
}
var native = NativeLanguages.Pick(names, schoolSeed, nativeLanguage, rollIfOmitted: true);
+1
View File
@@ -15,6 +15,7 @@ public static class Seed
public const int CommuteSalt = 7;
public const int SkillGrantSalt = 8;
public const int NativeLanguageSalt = 9;
public const int ClimatePresetSalt = 10;
/// <summary>A stream that belongs to the school rather than to one family.</summary>
public static int ForSchool(int schoolSeed, int salt) => Mix(schoolSeed, familyIndex: -1, salt);
+4 -4
View File
@@ -38,17 +38,17 @@ public static class YearlyIntake
DefCatalog catalog,
Roster roster,
int schoolSeed,
string nameSetId,
string countryId,
DateTime asOf,
string? nativeLanguage = null)
{
ArgumentNullException.ThrowIfNull(catalog);
ArgumentNullException.ThrowIfNull(roster);
ArgumentException.ThrowIfNullOrWhiteSpace(nameSetId);
ArgumentException.ThrowIfNullOrWhiteSpace(countryId);
if (!catalog.NameSets.TryGetValue(nameSetId, out var names))
if (!catalog.TryGetCountryNames(countryId, out var names))
{
throw new ArgumentException($"Unknown name set '{nameSetId}'.", nameof(nameSetId));
throw new ArgumentException($"Unknown country '{countryId}'.", nameof(countryId));
}
var native = NativeLanguages.Pick(names, schoolSeed, nativeLanguage, rollIfOmitted: false);