A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
sim: sourced birth dates and per-value biography sources for people, validated by the loader (#1) (#141)
agamrafaeli-instinctb8ef1cfa5e7e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6ee28cabc..eb7305151 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB## [Unreleased]### Added+- People can carry a birth date and a source for each biographical value (Hebrew name, birth and death dates) in+ `people.yaml`; the loader rejects unknown source keys, sources without a `url` or `checked` date, and impossible birth+ dates.- Browser-playable 1948–1951 (milestone M3): HUD, Cabinet with appointments, Budget, Events, Defence and "Why did thishappen?" screens over the 3D hex map; sourced content to 31 December 1951; saves; a calibrated economy; the goldenhash checked in WebGL and macOS players.diff --git a/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs b/sim/Statecraft.Sim.Tests/ContentLoaderTests.csindex 6dbdd4516..40402d9ff 100644--- a/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs+++ b/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs@@ -16,6 +16,64 @@ public class ContentLoaderTestsAssert.Equal(5, c.Rules.StartRung);}+ [Fact]+ public void PersonLifeMetadataHasSourcesPerFieldAndRemainsOptional()+ {+ var yaml = Fixture.Files["people.yaml"].Replace(" name: Pm One\n", @" name: Pm One+ name_he: דמות לדוגמה+ born: 1900-01-01+ biography_sources:+ name_he: [{ url: 'https://example.org/name', checked: 2026-10-11 }]+ born: [{ url: 'https://example.org/birth', checked: 2026-10-11 }]+");+ var c = ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["people.yaml"] = yaml }));+ var person = c.People[0];+ Assert.Equal("דמות לדוגמה", person.NameHe);+ Assert.Equal(new DateTime(1900, 1, 1), person.Born);+ Assert.Equal("https://example.org/name", person.BiographySources["name_he"][0].Url);+ Assert.Equal("https://example.org/birth", person.BiographySources["born"][0].Url);+ Assert.Null(c.People[1].Born);+ Assert.Empty(c.People[1].BiographySources);+ }++ static ContentException LoadPmOneWith(string lines) =>+ Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string>+ {+ ["people.yaml"] = Fixture.Files["people.yaml"].Replace(" name: Pm One\n", " name: Pm One\n" + lines),+ })));++ [Theory]+ [InlineData(" bron: [{ url: 'https://example.org/birth', checked: 2026-10-11 }]\n", "people[pm_one].biography_sources.bron")]+ [InlineData(" born:\n", "people[pm_one].biography_sources.born")]+ [InlineData(" born: [~]\n", "people[pm_one].biography_sources.born[0]")]+ [InlineData(" born: [{}]\n", "people[pm_one].biography_sources.born[0]")]+ [InlineData(" born: [{ checked: 2026-10-11 }]\n", "people[pm_one].biography_sources.born[0]")]+ [InlineData(" born: [{ url: 'https://example.org/birth', checked: 2026-10-11 }, { url: 'https://example.org/b2' }]\n", "people[pm_one].biography_sources.born[1]")]+ public void BadBiographySourceNamesFileAndField(string sources, string field)+ {+ var ex = LoadPmOneWith(" born: 1900-01-01\n biography_sources:\n" + sources);+ Assert.Equal("people.yaml", ex.File);+ Assert.Equal(field, ex.Field);+ }++ [Theory]+ [InlineData(" born: 1900-01-01\n died: 1900-01-01\n")]+ [InlineData(" born: 1948-05-15\n")]+ public void ImpossibleBirthDateIsAnError(string lines)+ {+ var ex = LoadPmOneWith(lines);+ Assert.Equal("people.yaml", ex.File);+ Assert.Equal("people[pm_one].born", ex.Field);+ }++ [Fact]+ public void BirthOnFirstTermStartLoads()+ {+ var yaml = Fixture.Files["people.yaml"].Replace(" name: Pm One\n", " name: Pm One\n born: 1948-05-14\n");+ var c = ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["people.yaml"] = yaml }));+ Assert.Equal(new DateTime(1948, 5, 14), c.People[0].Born);+ }+[Fact]public void UnknownPartyInSeatsNamesFileAndField(){diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.csindex 66abcef7a..1cc7c6295 100644--- a/sim/Statecraft.Sim/Content.cs+++ b/sim/Statecraft.Sim/Content.cs@@ -41,6 +41,10 @@ namespace Statecraft.Simpublic string Id { get; set; } = "";public string Name { get; set; } = "";public string NameHe { get; set; } = "";+ /// <summary>Biographical birth date; optional until the sourced person data is complete.</summary>+ public DateTime? Born { get; set; }+ /// <summary>Sources for each biography value (name_he, born, died), separate from dated office-term sources.</summary>+ public Dictionary<string, List<Source>> BiographySources { get; set; } = new Dictionary<string, List<Source>>();/// <summary>Required (null only when missing, which is a load error): a living person is excluded from release builds.</summary>public bool? Living { get; set; }/// <summary>Date of death, when it falls inside the content range: every term must end by then.</summary>diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex fa6bf06ee..a5a9ddc8a 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -341,6 +341,22 @@ namespace Statecraft.Simif (p.Competence < 0 || p.Competence > 10) throw new ContentException("people.yaml", $"people[{p.Id}].competence", "must be 0-10");if (p.Loyalty < 0 || p.Loyalty > 10) throw new ContentException("people.yaml", $"people[{p.Id}].loyalty", "must be 0-10");if (p.Party != "" && !parties.Contains(p.Party)) throw new ContentException("people.yaml", $"people[{p.Id}].party", $"unknown party '{p.Party}'");+ if (p.Born.HasValue && p.Died.HasValue && p.Born.Value >= p.Died.Value)+ throw new ContentException("people.yaml", $"people[{p.Id}].born", FormattableString.Invariant($"must be before {p.Died:yyyy-MM-dd}, the date of death"));+ var firstTerm = p.Offices.Count > 0 ? p.Offices.Min(t => t.From) : (DateTime?)null;+ if (p.Born.HasValue && firstTerm.HasValue && p.Born.Value > firstTerm.Value)+ throw new ContentException("people.yaml", $"people[{p.Id}].born", FormattableString.Invariant($"must be on or before {firstTerm:yyyy-MM-dd}, when the first office term starts"));+ // A map skips CheckNulls' list and entry checks, so a misspelt key or an empty source would load silently.+ foreach (var kv in p.BiographySources)+ {+ var field = $"people[{p.Id}].biography_sources.{kv.Key}";+ if (kv.Key != "name_he" && kv.Key != "born" && kv.Key != "died")+ throw new ContentException("people.yaml", field, "unknown field (must be name_he, born or died)");+ if (kv.Value == null) throw new ContentException("people.yaml", field, "must be a list");+ for (int i = 0; i < kv.Value.Count; i++)+ if (kv.Value[i] == null || string.IsNullOrWhiteSpace(kv.Value[i].Url) || kv.Value[i].Checked == default)+ throw new ContentException("people.yaml", FormattableString.Invariant($"{field}[{i}]"), "needs a url and a checked date");+ }foreach (var t in p.Offices){if (string.IsNullOrEmpty(t.Office)) throw new ContentException("people.yaml", $"people[{p.Id}].offices", "office term without an office");