A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: a badge on the Cabinet disc while a post is vacant that the player can fill (refs #1109) (#1110)
Beri7a88910729e8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3cf695948..ae5a5cfd3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB## [Unreleased]### Added+- The Cabinet disc in the side menu shows a small gold badge while a post is vacant that the player can fill this turn,+ and its tip says so in English and Hebrew. The sim's `Cabinet.Vacancies` decides it (a vacant seat, someone may be+ appointed, no appointment to it queued, the game not over, and enough Attention left after this turn's queued orders,+ priced by the sim's new `AttentionSystem.Price`/`Left`, which `SimBridge` now uses too); the UI only reads it (refs #1109).- Unit cards show the sourced Hebrew unit name in the Hebrew UI, with an English fallback. INS Haganah gains itssourced Hebrew name, still flagged for a native speaker's review (#902).### Fixeddiff --git a/sim/Statecraft.Sim.Tests/CabinetTests.cs b/sim/Statecraft.Sim.Tests/CabinetTests.csindex e4ff5a472..e13cef9e4 100644--- a/sim/Statecraft.Sim.Tests/CabinetTests.cs+++ b/sim/Statecraft.Sim.Tests/CabinetTests.cs@@ -347,4 +347,44 @@ public class CabinetTestss.Date = new DateTime(1951, 6, 1);Assert.Equal("David Remez died on 19 May 1951", Cabinet.Check(c, s, "transportation_minister", "remez"));}++ /// <summary>#1109: the side menu's Cabinet badge reads Cabinet.Vacancies, the playable seats with no holder that someone+ /// may be appointed to now and that no order in this turn's queue fills. Education is vacant from Remez's death (19 May+ /// 1951) to Dinur (8 October 1951); the presidency, vacant in December 1952, is the Knesset's to fill, not the player's.</summary>+ [Fact]+ public void VacanciesAreTheSeatsThePlayerCanFill()+ {+ var c = ContentLoader.Load(RealContentTests.ContentRoot());+ var none = new Command[0];+ // Attention 4 = a full turn (rules.yaml attention_per_turn): an appointment (2) is affordable unless a case says otherwise.+ Assert.Empty(Cabinet.Vacancies(c, new GameState { Date = new DateTime(1948, 6, 12), Attention = 4 }, none)); // #217: none in 1948+ var s = new GameState { Date = new DateTime(1951, 5, 19), Attention = 4 };+ // Minority Affairs has had no holder in people.yaml since 10 March 1949, and offices.yaml gives it no end date.+ Assert.Equal(new[] { "minority_affairs_minister", "education_minister" }, Cabinet.Vacancies(c, s, none).Select(o => o.Id).ToArray());+ var fill = Cabinet.Candidates(c, s, "education_minister").First(x => x.reason == null).person.Id;+ Assert.Equal(new[] { "minority_affairs_minister" }, // a queued appointment fills its seat, and only that one+ Cabinet.Vacancies(c, s, new Command[] { new Appoint("education_minister", fill) }).Select(o => o.Id).ToArray());+ Assert.Contains(Cabinet.Vacancies(c, s, new Command[] { new Appoint("finance_minister", fill) }), o => o.Id == "education_minister");+ var president = new GameState { Date = new DateTime(1952, 12, 15), Attention = 4 };+ Assert.Contains(Cabinet.Lineup(c, president), seat => seat.Office.Id == "president" && seat.Holder == null);+ Assert.DoesNotContain(Cabinet.Vacancies(c, president, none), o => o.Id == "president");+ }++ /// <summary>#1110 review: the badge promises only an appointment SimBridge.Queue would take this turn. On 19 May 1951 two+ /// seats are vacant (above), yet none is offered with no Attention left, with the game over, or with this turn's other+ /// orders (allocate_budget 2 + set_mobilization 1 of 4) leaving less than an appointment costs (2).</summary>+ [Theory]+ [InlineData("attention_zero")]+ [InlineData("game_over")]+ [InlineData("attention_queued")]+ public void VacanciesAreEmptyWhenNoAppointmentCanBeQueued(string probe)+ {+ var c = ContentLoader.Load(RealContentTests.ContentRoot());+ var s = new GameState { Date = new DateTime(1951, 5, 19), Attention = probe == "attention_zero" ? 0 : 4 };+ if (probe == "game_over") s.GameOver = GameOverCodes.CoalitionCollapse;+ var pending = probe == "attention_queued"+ ? new Command[] { new AllocateBudget(new Dictionary<string, double>()), new SetMobilization(0.5) }+ : new Command[0];+ Assert.Empty(Cabinet.Vacancies(c, s, pending));+ }}diff --git a/sim/Statecraft.Sim/AttentionSystem.cs b/sim/Statecraft.Sim/AttentionSystem.csindex 554422b3a..b96143913 100644--- a/sim/Statecraft.Sim/AttentionSystem.cs+++ b/sim/Statecraft.Sim/AttentionSystem.cs@@ -1,5 +1,6 @@using System.Collections.Generic;using System.Globalization;+using System.Linq;namespace Statecraft.Sim{@@ -28,6 +29,14 @@ namespace Statecraft.Simreturn r.AttentionCost[kind] * (1 + r.RungAttentionStep * ((rung ?? s.Rung) - 1));}+ /// <summary>The order's Attention price at this turn's prices (0 for a kind Attention does not price): what the UI's+ /// queue charges for it.</summary>+ public static double Price(Content c, GameState s, Command cmd) => IsCommandKind(cmd.Kind) ? Cost(c, s, cmd.Kind) : 0;++ /// <summary>Attention left after paying for <paramref name="pending"/> (this turn's queue) at this turn's prices: what+ /// the UI's queue still has to spend (#1110: the Cabinet badge and SimBridge.Queue read the same number).</summary>+ public static double Left(Content c, GameState s, IEnumerable<Command> pending) => s.Attention - pending.Sum(x => Price(c, s, x));+/// <summary>Returns null and deducts on success, or the reason it could not be afforded./// <paramref name="rung"/> prices the command at that security level (the turn's starting rung).</summary>public static string? TrySpend(Content c, GameState s, string kind, int? rung = null)diff --git a/sim/Statecraft.Sim/Cabinet.cs b/sim/Statecraft.Sim/Cabinet.csindex 37bb1ae7d..3f1910130 100644--- a/sim/Statecraft.Sim/Cabinet.cs+++ b/sim/Statecraft.Sim/Cabinet.cs@@ -133,6 +133,22 @@ namespace Statecraft.Simpublic static IReadOnlyList<(Person person, CabinetReason? reason)> Candidates(Content c, GameState s, string officeId) =>c.People.Select(p => (p, CheckReason(c, s, officeId, p.Id))).ToList();+ /// <summary>#1109: the playable offices that are vacant now (<see cref="Lineup"/>, no holder), that someone may be+ /// appointed to (<see cref="CheckReason"/>), and that no Appoint in <paramref name="pending"/> (this turn's queue)+ /// fills. Empty when no appointment can be queued this turn, for SimBridge.Queue's reasons: the game is over, or the+ /// Attention left after <paramref name="pending"/> does not pay for one (#1110 review). A query only: the side menu's+ /// Cabinet badge reads it.</summary>+ public static IReadOnlyList<Office> Vacancies(Content c, GameState s, IEnumerable<Command> pending)+ {+ var queued = pending.ToList();+ if (s.GameOver != null || AttentionSystem.Cost(c, s, "appoint") > AttentionSystem.Left(c, s, queued) + 1e-9)+ return new Office[0];+ var filled = queued.OfType<Appoint>().Select(a => a.Office).ToList();+ return Lineup(c, s)+ .Where(x => x.Holders.Count == 0 && !filled.Contains(x.Office.Id) && c.People.Any(p => CheckReason(c, s, x.Office.Id, p.Id) == null))+ .Select(x => x.Office).ToList();+ }+/// <summary>Returns null and appoints, or the reason (state untouched). Replacing a minister costs coalition/// stability: rules appoint_stability_cost_other_party when the seat leaves the displaced minister's party (a/// non-party appointee counts as another party), appoint_stability_cost_same_party otherwise. A vacant seat costsdiff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.csindex f602e987c..9639ac6c7 100644--- a/unity/Assets/Scripts/UI/HudPresenter.cs+++ b/unity/Assets/Scripts/UI/HudPresenter.cs@@ -104,6 +104,9 @@ namespace Statecraft.Game.UI/// <summary>The left icon column (promo 03): the screens' buttons (ScreenNav.Screens).</summary>public const string RailName = "left-column";+ /// <summary>#1109: the class on a side-menu button whose screen has something the player can do this turn+ /// (Statecraft.uss shows the button's BadgeClass dot). Only Cabinet has one: a vacant seat to fill (SimBridge.Vacancies).</summary>+ public const string ActionClass = "nav-action", BadgeClass = "nav-badge";readonly HoverTip? railTips, barTips;/// <summary>The meters' explanations under the bar (#1037): their words and the turn's causes.</summary>readonly MeterTip? meterTip;@@ -421,6 +424,10 @@ namespace Statecraft.Game.UISet("cohesion", m.Cohesion);said["cohesion"].element.style.display = m.ShowsCohesion ? DisplayStyle.Flex : DisplayStyle.None;root.Q<Button>("end-turn").SetEnabled(bridge.State.GameOver == null);+ // #1109: a vacant seat the player can fill lights the Cabinet disc's badge, and its tip says why.+ var cabinet = root.Q<Button>("nav-cabinet"); bool vacant = bridge.Vacancies.Count > 0;+ cabinet.EnableInClassList(ActionClass, vacant);+ cabinet.tooltip = vacant ? text["hud.nav.cabinet_vacant"] : cabinet.text;meterTip?.Refresh(); // an open tip follows the new words}}diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.csindex acd0e1463..fb02936c1 100644--- a/unity/Assets/Scripts/UI/SimBridge.cs+++ b/unity/Assets/Scripts/UI/SimBridge.cs@@ -65,7 +65,7 @@ namespace Statecraft.Game.UI};/// <summary>The order's Attention price at this turn's prices: what <see cref="Queue"/> charges and the card shows.</summary>- public double Price(Command c) => AttentionSystem.IsCommandKind(c.Kind) ? AttentionSystem.Cost(Content, State, c.Kind) : 0;+ public double Price(Command c) => AttentionSystem.Price(Content, State, c);/// <summary>Whether the Attention left pays for the order (a queued order with its key is refunded first): the one/// check <see cref="Queue"/> refuses on, so the event card (#1034) and a refusal can never disagree.</summary>@@ -77,8 +77,12 @@ namespace Statecraft.Game.UI/// cabinet: an appointment queued this turn is in office by then (#1034).</summary>public Person? DelegatedTo(GameEvent e) => Simulation.DelegatedTo(Content, State, queue, e.Id);+ /// <summary>The vacant seats the player can fill, less those an appointment queued now fills (Cabinet.Vacancies): the+ /// side menu's Cabinet badge (#1109).</summary>+ public IReadOnlyList<Office> Vacancies => Cabinet.Vacancies(Content, State, queue);+/// <summary>Attention left after paying for the queued orders at this turn's prices.</summary>- public double AttentionLeft => State.Attention - queue.Sum(Price);+ public double AttentionLeft => AttentionSystem.Left(Content, State, queue);/// <summary>The queued order with this key, or null.</summary>public Command? QueuedLike(Command c) => queue.FirstOrDefault(q => Key(q) == Key(c));diff --git a/unity/Assets/Tests/EditMode/LeftColumnTests.cs b/unity/Assets/Tests/EditMode/LeftColumnTests.csindex 9a970b30c..b99d2aca7 100644--- a/unity/Assets/Tests/EditMode/LeftColumnTests.cs+++ b/unity/Assets/Tests/EditMode/LeftColumnTests.cs@@ -308,4 +308,50 @@ public class LeftColumnTests});Assert.IsEmpty(problems, string.Join("\n", problems));}++ /// <summary>#1109: the Cabinet disc wears a small gold badge, and its tip says why, while the sim has a vacant seat the+ /// player can fill this turn (SimBridge.Vacancies, Cabinet.Vacancies); queuing an appointment to every such seat takes+ /// it off. No other disc has a badge. Education is vacant from 19 May 1951 (as Minority Affairs, which has no holder+ /// after 10 March 1949).</summary>+ [UnityTest]+ public IEnumerator TheCabinetDiscShowsABadgeWhileASeatIsVacant()+ {+ foreach (var hebrew in new[] { false, true })+ {+ var text = hebrew ? He : En;+ using var ui = new UiTestKit();+ ui.Root.Q("root").RemoveFromClassList("loading");+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ var bridge = new SimBridge(g, text);+ using var hud = new HudPresenter(ui.Root, bridge, text);+ var cabinet = ui.Q<Button>("nav-cabinet");+ var badge = cabinet.Q(className: HudPresenter.BadgeClass);+ Assert.IsNotNull(badge, "the Cabinet disc carries a badge element");+ for (int i = 0; i < 3; i++) yield return null;+ Assert.IsFalse(cabinet.ClassListContains(HudPresenter.ActionClass), "1948: no seat is vacant");+ Assert.AreEqual(DisplayStyle.None, badge.resolvedStyle.display, "1948: the badge is hidden");+ Assert.AreEqual(text["hud.nav.cabinet"], cabinet.tooltip, "1948: the tip is the disc's name");++ g.State.Date = new System.DateTime(1951, 5, 19);+ g.State.Attention = 10;+ hud.Render(); // a turn would (bridge.Changed)+ for (int i = 0; i < 3; i++) yield return null;+ Assert.IsTrue(cabinet.ClassListContains(HudPresenter.ActionClass), "May 1951: a seat to fill");+ Assert.AreEqual(DisplayStyle.Flex, badge.resolvedStyle.display, "May 1951: the badge shows");+ Assert.AreEqual(text["hud.nav.cabinet_vacant"], cabinet.tooltip, "May 1951: the tip says why");+ Assert.AreEqual(text["hud.nav.cabinet"], cabinet.text, "the name stays the text (the event log records it)");+ var disc = cabinet.Q(className: "nav-disc").worldBound; var dot = badge.worldBound;+ Assert.IsTrue(dot.width > 0 && dot.center.x > disc.center.x && dot.center.y < disc.center.y && disc.Overlaps(dot),+ $"the badge sits on the disc's upper right ({dot} on {disc})");+ foreach (var other in ScreenNav.Screens.Where(x => x != "cabinet"))+ Assert.IsNull(ui.Q<Button>("nav-" + other).Q(className: HudPresenter.BadgeClass), other + ": no badge");++ foreach (var office in Cabinet.Vacancies(C, g.State, new Command[0]))+ Assert.IsNull(bridge.Queue(new Appoint(office.Id, Cabinet.Candidates(C, g.State, office.Id).First(x => x.reason == null).person.Id)), office.Id);+ for (int i = 0; i < 3; i++) yield return null;+ Assert.IsFalse(cabinet.ClassListContains(HudPresenter.ActionClass), "every vacant seat has a queued appointment");+ Assert.AreEqual(DisplayStyle.None, badge.resolvedStyle.display, "the badge goes");+ Assert.AreEqual(text["hud.nav.cabinet"], cabinet.tooltip, "the tip is the name again");+ }+ }}diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex de5b23ad5..91e939d38 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -13,7 +13,7 @@the column in the tree, so the column's buttons stay above it and usable. --><ui:VisualElement name="event-gutter" class="event-gutter" /><ui:VisualElement name="left-column" class="left-column" picking-mode="Ignore">- <ui:Button name="nav-cabinet" text="Cabinet" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="columns" class="nav-disc" /></ui:Button>+ <ui:Button name="nav-cabinet" text="Cabinet" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="columns" class="nav-disc" /><ui:VisualElement class="nav-badge" picking-mode="Ignore" /></ui:Button><ui:Button name="nav-budget" text="Budget" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="ledger" class="nav-disc" /></ui:Button><ui:Button name="nav-defence" text="Defence" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="helmet" class="nav-disc" /></ui:Button><ui:Button name="nav-why" text="Why?" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="question" class="nav-disc" /></ui:Button>diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex f53f82cb3..882f20e34 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -226,6 +226,13 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);above the info panel's top (456 px) in a short, wide window (InfoPanelLayoutTests); the column keeps its 56 px width,so the backdrop, the screens and the toast keep their places. */.left-column .rail-button .nav-disc { top: 0; left: 0; width: 50px; height: 50px; padding: 11px; border-radius: 25px; }+/* A screen with something to do this turn (#1109, HudPresenter.ActionClass): a small gold dot on the disc's upper right,+ ringed in the column's navy so it reads against the rim; the gold-light of End Turn's waiting highlight (#1034). */+.nav-badge {+ display: none; position: absolute; top: 1px; right: 1px; width: 14px; height: 14px;+ border-radius: 7px; border-width: 2px; border-color: var(--navy-deep); background-color: var(--gold-light);+}+.nav-action .nav-badge { display: flex; }/* On a phone held upright the panel's scale falls to about 0.41 (375x667), where a 56 px disc is 22.8 px on screen: thecolumn's discs are 60 px there, at least 24 on screen (LeftColumnTests), and the backdrop's strip and the backdropfollow the wider column. */diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 8643c9555..41e04015c 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -35,6 +35,8 @@ hud.caption.cohesion: "Social cohesion"# the UXML's own text (HebrewUiTests.EachEnglishStaticTextIsTheUxmlsOwnText), so English shows what it always showed.# The top bar (HudPresenter):hud.nav.cabinet: "Cabinet"+# The Cabinet disc's tip while a seat is vacant that the player can fill (#1109).+hud.nav.cabinet_vacant: "Cabinet: a post is vacant. You can appoint someone to it."hud.nav.budget: "Budget"hud.nav.defence: "Defence"hud.nav.why: "Why?"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex c4a6bc4a5..805518344 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -28,6 +28,8 @@ hud.caption.fx: "מטבע חוץ"# hud.caption.cohesion: Social cohesion; the GDD's Hebrew, kept by the owner (Q-HUD-3, 15 October 2026, #375; #380).hud.caption.cohesion: "לכידות חברתית"hud.nav.cabinet: "ממשלה"+# The Cabinet disc's tip while a seat is vacant that the player can fill (#1109). For the native reviewer (#564).+hud.nav.cabinet_vacant: "ממשלה: יש תפקיד פנוי. אפשר למנות אליו מישהו."hud.nav.budget: "תקציב"hud.nav.defence: "ביטחון"hud.nav.why: "למה?"