Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Defence screen: war state, truce line and prisoners in the GDD loop (Fixes #755) (#1493)

Beri7ab4005006e8
diff --git a/changelog.d/defence-screen-war-state-prisoners-755.md b/changelog.d/defence-screen-war-state-prisoners-755.md
new file mode 100644
index 000000000..3526d2478
--- /dev/null
+++ b/changelog.d/defence-screen-war-state-prisoners-755.md
@@ -0,0 +1,3 @@
+- Defence screen (#755): in the GDD loop it hides the per-rung turn-length legend, names the war state, shows a truce line
+ while a truce the player accepted is in force, and has a Prisoners panel (enemy prisoners held, prisoners returned, our
+ soldiers held). The sim exposes `Combat.TruceUntil`, the end of the truce in force.
diff --git a/sim/Statecraft.Sim.Tests/TruceTests.cs b/sim/Statecraft.Sim.Tests/TruceTests.cs
index ff51accc6..5dc75cf3e 100644
--- a/sim/Statecraft.Sim.Tests/TruceTests.cs
+++ b/sim/Statecraft.Sim.Tests/TruceTests.cs
@@ -73,6 +73,19 @@ public class TruceTests
Assert.Empty(Step(c, s, new UnitOrder(1, Orders.Fortify)).Rejected);
}
+ // R-COMBAT-009: the Defence screen's truce line (#755) reads the end of the truce in force from the sim, the same
+ // window the attack check uses, so Unity holds no truce rule.
+ [Theory]
+ [InlineData("1948-06-15", "first_truce", "accept", "1948-07-08")]
+ [InlineData("1948-09-15", "second_truce", "comply", "1948-10-15")]
+ [InlineData("1948-07-15", "first_truce", "accept", null)] // over
+ [InlineData("1948-06-15", "first_truce", "refuse", null)] // a refused card binds nothing
+ public void TruceUntilNamesTheEndOfTheTruceInForce(string date, string ev, string option, string? until)
+ {
+ var s = State(Load(), DateTime.Parse(date), (ev, option));
+ Assert.Equal(until == null ? (DateTime?)null : DateTime.Parse(until), Combat.TruceUntil(s));
+ }
+
/// <summary>R-COMBAT-009: the player's accepted truce binds the player's orders only - an enemy attack order on
/// the same turn is untouched (R-ENEMY-006's own date-driven guard is the enemy side's).</summary>
[Fact]
diff --git a/sim/Statecraft.Sim/Combat.cs b/sim/Statecraft.Sim/Combat.cs
index c1c2314c4..c33c2e673 100644
--- a/sim/Statecraft.Sim/Combat.cs
+++ b/sim/Statecraft.Sim/Combat.cs
@@ -66,8 +66,13 @@ namespace Statecraft.Sim
/// <summary>R-COMBAT-009: whether a truce the player accepted is in force on <see cref="GameState.Date"/> (the
/// turn's first day, the date the HUD shows): until the turn that covers the window's end, so a complying
/// player attacks again from the 15 October 1948 turn (owner ruling 1, 22 October 2026, #750).</summary>
- internal static bool TruceInForce(GameState s) =>
- PlayerTruces.Any(t => s.Date < t.Until && s.ChosenOptions.TryGetValue(t.Event, out var o) && o == t.Option);
+ internal static bool TruceInForce(GameState s) => TruceUntil(s) != null;
+
+ /// <summary>R-COMBAT-009: the end of the window of the truce in force (<see cref="TruceInForce"/>), else null. The
+ /// Defence screen's truce line reads it (#755), so the UI holds no truce rule.</summary>
+ public static DateTime? TruceUntil(GameState s) =>
+ PlayerTruces.Where(t => s.Date < t.Until && s.ChosenOptions.TryGetValue(t.Event, out var o) && o == t.Option)
+ .Select(t => (DateTime?)t.Until).FirstOrDefault();
/// <summary>The enemy military units on (q, r), seen from <paramref name="attacker"/>'s team, in id order.</summary>
static List<Unit> Defenders(GameState s, Unit attacker, int q, int r) =>
diff --git a/unity/Assets/Scripts/UI/DefencePresenter.cs b/unity/Assets/Scripts/UI/DefencePresenter.cs
index 2a443906a..f03bf0f43 100644
--- a/unity/Assets/Scripts/UI/DefencePresenter.cs
+++ b/unity/Assets/Scripts/UI/DefencePresenter.cs
@@ -35,6 +35,7 @@ namespace Statecraft.Game.UI
escalate.clicked += onEscalate; deEscalate.clicked += onDeEscalate; mobUp.clicked += onMobUp; mobDown.clicked += onMobDown;
foreach (var (name, key) in Sections) screen.Q<Label>(name).text = text[key].ToUpperInvariant(); // the promo's capitals; a caseless script is unchanged
screen.Q<Label>("defence-screen-title").text = text["defence.title"];
+ screen.Q<Label>("defence-title-prisoners").text = text["defence.section_prisoners"].ToUpperInvariant(); // #755, as Sections
deEscalate.text = text["defence.lower"]; escalate.text = text["defence.raise"];
bridge.Changed += OnChanged;
ScreenNav.OnOpened(screen, () => { if (dirty) Render(); });
@@ -140,6 +141,7 @@ namespace Statecraft.Game.UI
screen.Q<Label>($"rung-{rung}-name").text = text[$"defence.rung{rung}"];
// The content's turn_lengths (R-TURN-001): every rung reads "month" in the GDD game.
screen.Q<Label>($"rung-{rung}-turn").text = text[TurnKey(SecuritySystem.TurnLengthFor(c, s.Date, rung))];
+ screen.Q<Label>($"rung-{rung}-turn").style.display = c.IsGdd ? DisplayStyle.None : DisplayStyle.Flex; // a legend with one value says nothing (#755)
var row = screen.Q<VisualElement>($"rung-{rung}");
row.EnableInClassList("rung-current", rung == s.Rung);
row.EnableInClassList("rung-target", rung == target && target != s.Rung); // the level an order will move to
@@ -174,6 +176,23 @@ namespace Statecraft.Game.UI
var lever = c.IsGdd ? DisplayStyle.None : DisplayStyle.Flex;
escalate.style.display = lever; deEscalate.style.display = lever; mobUp.style.display = lever; mobDown.style.display = lever;
screen.Q<Label>("order-pending").text = delta == 0 ? "" : text.Format("defence.order", s.Rung, target);
+ // #755: the GDD loop's war state (the rung the events set, R-WAR-002), the truce the player accepted while it is in
+ // force (the sim's R-COMBAT-009 window), and the prisoner counts in people (R-POW-001, R-POW-004, R-POW-005).
+ var warState = screen.Q<Label>("war-state");
+ warState.text = c.IsGdd ? text.Format("defence.war_state", s.Rung) : "";
+ warState.style.display = c.IsGdd ? DisplayStyle.Flex : DisplayStyle.None;
+ var truce = screen.Q<Label>("truce");
+ var until = c.IsGdd ? Combat.TruceUntil(s) : null;
+ truce.text = until is DateTime end ? text.Format("defence.truce", Statecraft.Game.Map.Control1948.DateText(end, k => text[k])) : "";
+ truce.style.display = truce.text == "" ? DisplayStyle.None : DisplayStyle.Flex;
+ screen.Q<VisualElement>("defence-prisoners").style.display = c.IsGdd ? DisplayStyle.Flex : DisplayStyle.None;
+ if (c.IsGdd)
+ {
+ var ppu = c.RulesAt(s.Date).Mvp!.PeoplePerUnit;
+ screen.Q<Label>("prisoners-held").text = text.Format("defence.prisoners_held", s.PrisonersHeld.Values.Sum() * ppu);
+ screen.Q<Label>("prisoners-returned").text = text.Format("defence.prisoners_returned", s.PrisonersReturned.Values.Sum() * ppu);
+ screen.Q<Label>("soldiers-held").text = text.Format("defence.soldiers_held", s.SoldiersHeld.Values.Sum() * ppu);
+ }
var floor = SecuritySystem.MinMobilization(c, s.Date, target);
var proposed = EffectiveAt(ProposedMobilization); // what the call-up will be: the sim raises a lower order to the minimum
screen.Q<Label>("mob-level").text = text.Format("defence.mob", PlayerText.Percent(proposed), target, PlayerText.Percent(floor));
diff --git a/unity/Assets/Tests/EditMode/DefenceScreenTests.cs b/unity/Assets/Tests/EditMode/DefenceScreenTests.cs
index 0c10c431d..fd8857963 100644
--- a/unity/Assets/Tests/EditMode/DefenceScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/DefenceScreenTests.cs
@@ -161,6 +161,113 @@ public class DefenceScreenTests
}
}
+ /// <summary>#755 (plan PR 16): every rung plays a month in the GDD loop (R-TURN-001), so the per-rung turn-length
+ /// legend says nothing there and is hidden. The legacy loop, whose rungs set the turn length, keeps it.</summary>
+ [Test]
+ public void TheGddLoopDropsTheTurnLengthLegend()
+ {
+ var (ui, _, _) = Open();
+ using (ui)
+ for (int rung = 1; rung <= 5; rung++)
+ Assert.AreEqual(DisplayStyle.None, ui.Q<Label>($"rung-{rung}-turn").style.display.value, $"rung {rung}");
+ var (legacy, _, _) = OpenLegacy();
+ using (legacy)
+ for (int rung = 1; rung <= 5; rung++)
+ Assert.AreEqual(DisplayStyle.Flex, legacy.Q<Label>($"rung-{rung}-turn").style.display.value, $"rung {rung}");
+ }
+
+ /// <summary>#755, Q-WAR-1: in the GDD loop the level is the war state the events set (R-WAR-002), and a line says so
+ /// with today's level. The legacy loop, where the player orders the level, has no such line.</summary>
+ [Test]
+ public void TheWarStateLineNamesTheLevelTheEventsSet()
+ {
+ var (ui, bridge, defence) = Open();
+ using (ui)
+ {
+ Assert.AreEqual("War state: level 5, set by the events of the war", ui.Q<Label>("war-state").text);
+ bridge.State.Rung = 3;
+ defence.Render();
+ Assert.AreEqual("War state: level 3, set by the events of the war", ui.Q<Label>("war-state").text);
+ Assert.AreEqual(DisplayStyle.Flex, ui.Q<Label>("war-state").style.display.value);
+ }
+ var (legacy, _, _) = OpenLegacy();
+ using (legacy) Assert.AreEqual(DisplayStyle.None, legacy.Q<Label>("war-state").style.display.value);
+ }
+
+ /// <summary>#218's case (11 June to 8 July 1948) under Q-WAR-2 as decided: the GDD loop has no UN ceasefire clock
+ /// (R-WAR-003), so the screen no longer promises a ceasefire "in 49 weeks" during the First Truce; while the truce the
+ /// player accepted is in force (R-COMBAT-009, read from the sim) a line says so and until when. It goes once the
+ /// window ends, and a refused card shows none.</summary>
+ [Test]
+ public void TheFirstTruceShowsTheTruceLineAndNoCeasefireClock()
+ {
+ var (ui, bridge, defence) = Open();
+ using (ui)
+ {
+ var truce = ui.Q<Label>("truce");
+ Assert.AreEqual(DisplayStyle.None, truce.style.display.value, "no truce at the start");
+ bridge.State.Date = new System.DateTime(1948, 6, 15);
+ bridge.State.ChosenOptions["first_truce"] = "accept";
+ defence.Render();
+ Assert.AreEqual(DisplayStyle.Flex, truce.style.display.value);
+ Assert.AreEqual("A truce is in force: our units cannot attack until 8 July 1948", truce.text);
+ Assert.AreEqual(DisplayStyle.None, ui.Q<Label>("ceasefire").style.display.value, "no ceasefire clock (R-WAR-003)");
+ bridge.State.Date = new System.DateTime(1948, 7, 15);
+ defence.Render();
+ Assert.AreEqual(DisplayStyle.None, truce.style.display.value, "the window has ended");
+ bridge.State.Date = new System.DateTime(1948, 6, 15);
+ bridge.State.ChosenOptions["first_truce"] = "refuse";
+ defence.Render();
+ Assert.AreEqual(DisplayStyle.None, truce.style.display.value, "a refused card binds nothing");
+ }
+ var (legacy, legacyBridge, legacyDefence) = OpenLegacy();
+ using (legacy)
+ {
+ legacyBridge.State.Date = new System.DateTime(1948, 6, 15);
+ legacyBridge.State.ChosenOptions["first_truce"] = "accept";
+ legacyDefence.Render();
+ Assert.AreEqual(DisplayStyle.None, legacy.Q<Label>("truce").style.display.value, "the legacy loop has no truce line");
+ }
+ }
+
+ /// <summary>#218's case in Hebrew: the truce line names its end date in the Hebrew calendar words.</summary>
+ [Test]
+ public void InHebrewTheTruceLineNamesItsEnd()
+ {
+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ using var ui = new UiTestKit();
+ ui.Q<VisualElement>("screen-defence").style.display = DisplayStyle.Flex;
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), he);
+ bridge.State.Date = new System.DateTime(1948, 6, 15);
+ bridge.State.ChosenOptions["first_truce"] = "accept";
+ using var defence = new DefencePresenter(ui.Root, bridge, he);
+ Assert.AreEqual("הפוגה בתוקף: היחידות שלנו אינן יכולות לתקוף עד 8 ביולי 1948", ui.Q<Label>("truce").text);
+ }
+
+ /// <summary>#755, Q-POW-4: the prisoner lines read GameState's counts (R-POW-001, R-POW-004, R-POW-005), summed over
+ /// the sides, in people (people_per_unit, 1,000). Plain counts: nothing celebrates a capture (impact plan section 4.3
+ /// item 4). The legacy loop takes no prisoners, so the panel is hidden there.</summary>
+ [Test]
+ public void ThePrisonerLinesReadTheirState()
+ {
+ var (ui, bridge, defence) = Open();
+ using (ui)
+ {
+ Assert.AreEqual(DisplayStyle.Flex, ui.Q<VisualElement>("defence-prisoners").style.display.value);
+ Assert.AreEqual("Enemy prisoners held: 0", ui.Q<Label>("prisoners-held").text);
+ var s = bridge.State;
+ s.PrisonersHeld["egypt"] = 2; s.PrisonersHeld["jordan"] = 1;
+ s.PrisonersReturned["lebanon"] = 4;
+ s.SoldiersHeld["egypt"] = 1;
+ defence.Render();
+ Assert.AreEqual("Enemy prisoners held: 3,000", ui.Q<Label>("prisoners-held").text);
+ Assert.AreEqual("Prisoners returned: 4,000", ui.Q<Label>("prisoners-returned").text);
+ Assert.AreEqual("Our soldiers held by the enemy: 1,000", ui.Q<Label>("soldiers-held").text);
+ }
+ var (legacy, _, _) = OpenLegacy();
+ using (legacy) Assert.AreEqual(DisplayStyle.None, legacy.Q<VisualElement>("defence-prisoners").style.display.value);
+ }
+
[Test]
public void ADisposedScreenHearsNothing()
{
diff --git a/unity/Assets/Tests/EditMode/PromoScreensTests.cs b/unity/Assets/Tests/EditMode/PromoScreensTests.cs
index af676b753..234cbd555 100644
--- a/unity/Assets/Tests/EditMode/PromoScreensTests.cs
+++ b/unity/Assets/Tests/EditMode/PromoScreensTests.cs
@@ -464,6 +464,13 @@ public class PromoScreensTests
texts["mob-down"] = "-5%"; texts["mob-up"] = "+5%"; // the step, DefencePresenter.MobilizationStep
Assert.AreEqual(0.05, DefencePresenter.MobilizationStep, 1e-12);
texts["ceasefire"] = s.Rung == 5 ? Text.Format("defence.ceasefire", s.CeasefireWeeksLeft) : "";
+ // #755: the war state, the truce in force (the sim's R-COMBAT-009 window) and the prisoner counts in people.
+ texts["war-state"] = Text.Format("defence.war_state", s.Rung);
+ texts["truce"] = Combat.TruceUntil(s) is DateTime until ? Text.Format("defence.truce", Statecraft.Game.Map.Control1948.DateText(until, k => Text[k])) : "";
+ var ppu = C.RulesAt(s.Date).Mvp!.PeoplePerUnit;
+ texts["prisoners-held"] = Text.Format("defence.prisoners_held", s.PrisonersHeld.Values.Sum() * ppu);
+ texts["prisoners-returned"] = Text.Format("defence.prisoners_returned", s.PrisonersReturned.Values.Sum() * ppu);
+ texts["soldiers-held"] = Text.Format("defence.soldiers_held", s.SoldiersHeld.Values.Sum() * ppu);
texts["defence-budget-share"] = $"{PlayerText.Percent(s.Budget[DefencePresenter.BudgetLine])} of budget spending";
bars["mob-bar"] = (float)callUp; bars["defence-budget-bar"] = (float)s.Budget[DefencePresenter.BudgetLine];
foreach (var name in new[] { "screen-cabinet", "screen-defence" })
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index e4f71743d..6ad476407 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -319,6 +319,9 @@
<ui:VisualElement name="rung-1" class="rung"><ui:Label name="rung-1-name" class="grow rung-name" /><ui:Label name="rung-1-turn" class="muted rung-turn" /></ui:VisualElement>
</ui:VisualElement>
<ui:Label name="ceasefire" class="muted wrap" />
+ <!-- #755: the GDD loop's war state and the truce in force (R-WAR-002, R-COMBAT-009). -->
+ <ui:Label name="war-state" class="wrap" />
+ <ui:Label name="truce" class="muted wrap" />
<ui:VisualElement class="row">
<ui:Button name="de-escalate" text="Lower the level" />
<ui:Button name="escalate" text="Raise the level" />
@@ -345,6 +348,14 @@
<ui:Label name="defence-budget-share" class="budget-share" />
<Statecraft.Game.UI.UiFrame shadow="false" />
</ui:VisualElement>
+ <!-- #755: the prisoners held and returned and our soldiers held (R-POW-001, R-POW-004, R-POW-005), GDD loop only. -->
+ <ui:VisualElement name="defence-prisoners" class="defence-panel">
+ <ui:Label name="defence-title-prisoners" class="section-title" />
+ <ui:Label name="prisoners-held" class="wrap" />
+ <ui:Label name="prisoners-returned" class="wrap" />
+ <ui:Label name="soldiers-held" class="wrap" />
+ <Statecraft.Game.UI.UiFrame shadow="false" />
+ </ui:VisualElement>
</ui:ScrollView>
<Statecraft.Game.UI.UiFrame />
</ui:VisualElement>
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 45c215653..d219f4c0c 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -234,6 +234,14 @@ defence.mob: "{0} of reserves called up (level {1} needs at least {2})"
defence.mob_cost: "Costs {0} a year in pay and lost work"
defence.ceasefire_stops: "The UN ceasefire clock stops if the level is lowered"
defence.ceasefire_starts: "UN ceasefire: {0} weeks once level 5 is reached"
+# The GDD Defence screen (#755): the war state, the truce in force and the prisoner counts. Plain counts, nothing
+# celebratory (impact plan section 4.3 item 4).
+defence.war_state: "War state: level {0}, set by the events of the war"
+defence.truce: "A truce is in force: our units cannot attack until {0}"
+defence.section_prisoners: "Prisoners"
+defence.prisoners_held: "Enemy prisoners held: {0:N0}"
+defence.prisoners_returned: "Prisoners returned: {0:N0}"
+defence.soldiers_held: "Our soldiers held by the enemy: {0:N0}"
budget.share: "{0}"
budget.office: "{0} ({1})"
budget.vacant: "vacant"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index b83074dfa..536baaa1f 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -246,6 +246,13 @@ defence.mob: "{0} מכוחות המילואים גויסו (דרגה {1} דור
defence.mob_cost: "עלות שנתית של {0} בשכר ובאובדן עבודה"
defence.ceasefire_stops: "הספירה להפסקת אש של האו״ם נעצרת אם מורידים את הדרגה"
defence.ceasefire_starts: "הפסקת אש של האו״ם: {0} שבועות מההגעה לדרגה 5"
+# The GDD Defence screen (#755). Approved by Beri, a native speaker, on #564 (23 Oct 2026). Plain counts, nothing celebratory.
+defence.war_state: "מצב המלחמה: דרגה {0}, נקבעת לפי אירועי המלחמה"
+defence.truce: "הפוגה בתוקף: היחידות שלנו אינן יכולות לתקוף עד {0}"
+defence.section_prisoners: "שבויים"
+defence.prisoners_held: "שבויי אויב בידינו: {0:N0}"
+defence.prisoners_returned: "שבויים שהוחזרו: {0:N0}"
+defence.soldiers_held: "חיילינו המוחזקים בידי האויב: {0:N0}"
defence.budget_share: "{0} מהוצאות התקציב"
defence.budget_none: "אין בתקציב סעיף ביטחון"
defence.section_leadership: "הנהגה"