A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(sim): fill late-resolved event text at the last in-window date
eyalgolan18988c0ecb19
diff --git a/sim/Statecraft.Sim.Tests/EventTests.cs b/sim/Statecraft.Sim.Tests/EventTests.csindex a43ab7daf..b68615eee 100644--- a/sim/Statecraft.Sim.Tests/EventTests.cs+++ b/sim/Statecraft.Sim.Tests/EventTests.cs@@ -172,6 +172,33 @@ options:Assert.Contains("1949-01-15", ex.Message);}+ // Window ends 1949-01-01; nobody holds defense from then until 1949-02-01.+ static readonly string LateEvent = Shortage.Replace("text: Ration food", "text: '{defense_minister} rations food'")+ .Replace("from: 1948-06-01", "from: 1948-06-01\nto: 1949-01-01");++ [Fact]+ public void ChoosingAfterWindowEndFillsAtLastInWindowDate()+ {+ var c = LoadWithGap(LateEvent);+ var s = State(c, new DateTime(1948, 12, 1)); var why = new List<Cause>();+ EventSystem.Trigger(c, s, why);+ s.Date = new DateTime(1949, 1, 15); // still pending after To, office unheld today+ Assert.Null(EventSystem.Choose(c, s, "shortage", "ration", why));+ Assert.Contains(why, w => w.Message == "chosen: Pm One rations food");+ }++ [Fact]+ public void DelegatingAfterWindowEndFillsAtLastInWindowDate()+ {+ var c = LoadWithGap(LateEvent);+ c.People.First(p => p.Id == "def_two").Competence = 10; // always the recommended option (ration)+ var s = State(c, new DateTime(1948, 12, 1)); var why = new List<Cause>();+ EventSystem.Trigger(c, s, why);+ s.Date = new DateTime(1949, 1, 1); // exactly To+ EventSystem.Delegate(c, s, why);+ Assert.Contains(why, w => w.Message.StartsWith("delegated") && w.Message.EndsWith("Pm One rations food"));+ }+[Fact]public void PlaceholderFullyCoveredWindowLoads(){diff --git a/sim/Statecraft.Sim/EventSystem.cs b/sim/Statecraft.Sim/EventSystem.csindex 10d22fbcb..6a04ff9a9 100644--- a/sim/Statecraft.Sim/EventSystem.cs+++ b/sim/Statecraft.Sim/EventSystem.cs@@ -39,7 +39,11 @@ namespace Statecraft.Simstatic void Resolve(Content c, GameState s, string eventId, EventOption o, string how, List<Cause> why){s.PendingEvents.Remove(eventId);- why.Add(new Cause("events", eventId, 0, $"{how}: {Offices.Fill(c, o.Text, s.Date)}"));+ // Resolved on or after the window end: name whoever held the office on the last in-window day+ // (load-time coverage guarantees a holder there); otherwise today's holder.+ var e = Get(c, eventId);+ var fillDate = e.To.HasValue && s.Date >= e.To.Value ? e.To.Value.AddDays(-1) : s.Date;+ why.Add(new Cause("events", eventId, 0, $"{how}: {Offices.Fill(c, o.Text, fillDate)}"));foreach (var fx in o.Effects){if (fx.Target == "treasury") s.Treasury += fx.Delta;