A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Dollar panel and unit-card Reinforce follow End turn's queue (Refs #2740) (#2744)
Eyal Golan54d62e8016f6
diff --git a/changelog.d/2740-panel-preview.md b/changelog.d/2740-panel-preview.mdnew file mode 100644index 000000000..f05d64441--- /dev/null+++ b/changelog.d/2740-panel-preview.md@@ -0,0 +1,5 @@+### Fixed++- The dollar conversion panel and the unit card's Reinforce now check what End turn will do with this turn's queued+ orders, so an earlier order that spends foreign currency or the last civilian without work no longer leaves a+ conversion or reinforcement offered that End turn then refuses (Refs #2740).diff --git a/unity/Assets/Scripts/UI/DollarConversionPresenter.cs b/unity/Assets/Scripts/UI/DollarConversionPresenter.csindex a61d667e2..f8e6c68ef 100644--- a/unity/Assets/Scripts/UI/DollarConversionPresenter.cs+++ b/unity/Assets/Scripts/UI/DollarConversionPresenter.cs@@ -1,5 +1,6 @@#nullable enableusing System;+using System.Linq;using Statecraft.Sim;using UnityEngine.UIElements;@@ -36,7 +37,7 @@ namespace Statecraft.Game.UI{// An amount the sim already refuses is never queued: the panel keeps showing why (Render).if (bridge.Content.IsGdd && bridge.State.GameOver == null- && EconomySystem.DollarsRefusal(bridge.Content, bridge.State, amount.value) != null) { Render(); return; }+ && Refusal(new ConvertDollars(amount.value)) != null) { Render(); return; }var reason = bridge.Queue(new ConvertDollars(amount.value));Render();if (reason != null) panel.Q<Label>("dollars-refusal").text = reason;@@ -59,8 +60,9 @@ namespace Statecraft.Game.UIif (bridge.Content.IsGdd && bridge.State.GameOver == null&& bridge.QueuedLike(new ConvertDollars(1)) is ConvertDollars queued && queued.Amount != amount.value){- if (EconomySystem.DollarsRefusal(bridge.Content, bridge.State, amount.value) != null) bridge.Withdraw(queued);- else if ((reason = bridge.Queue(new ConvertDollars(amount.value))) != null) bridge.Withdraw(queued);+ var replacement = new ConvertDollars(amount.value);+ if (Refusal(replacement) != null) bridge.Withdraw(queued);+ else if ((reason = bridge.Queue(replacement)) != null) bridge.Withdraw(queued);}Render();if (reason != null) panel.Q<Label>("dollars-refusal").text = reason;@@ -73,6 +75,16 @@ namespace Statecraft.Game.UIRender();}+ string? Refusal(ConvertDollars candidate)+ {+ var queue = bridge.Queued.ToList();+ var old = bridge.QueuedLike(candidate);+ var slot = old == null ? -1 : queue.IndexOf(old);+ if (slot >= 0) queue[slot] = candidate; else queue.Add(candidate);+ var preview = Simulation.Preview(bridge.Content, bridge.TurnStart, bridge.Session.Committed.Concat(queue).ToList());+ return preview.Rejected.FirstOrDefault(x => ReferenceEquals(x.Command, candidate))?.Reason;+ }+public void Render(){var c = bridge.Content; var s = bridge.State;@@ -96,8 +108,8 @@ namespace Statecraft.Game.UIpanel.Q<Label>("dollars-queued").text = queued == null ? "" : text.Format("dollars.queued", PlayerText.Money(c, "fx_reserves", queued.Amount));convert.SetEnabled(s.GameOver == null && amount.value > 0);withdraw.SetEnabled(s.GameOver == null && queued != null);- // The sim's own check (EconomySystem.DollarsRefusal) on the state as it is now: End turn refuses the same amount.- var refused = s.GameOver != null ? null : EconomySystem.DollarsRefusal(c, s, amount.value);+ // Ask the sim about the exact queue a press would leave, including every earlier order End turn will run.+ var refused = s.GameOver != null ? null : Refusal(order);panel.Q<Label>("dollars-refusal").text = s.GameOver != null ? text["order.game_over"]: !war ? text["dollars.wartime_only"]: refused != null ? SimBridge.ReasonText(text, refused, c)diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.csindex 8e8276a55..61727d2e3 100644--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs@@ -862,17 +862,24 @@ namespace Statecraft.Game.UIsendHomeButton.style.display = orderUnit != null && sendHomeWhy == null ? DisplayStyle.Flex : DisplayStyle.None;skipButton.style.display = own == true && orderUnit != null && bridge.NeedsOrders.Contains(orderUnit.Value) ? DisplayStyle.Flex : DisplayStyle.None;// Reinforce (#1510, R-TRAIN-004): offered for a unit of Israel's that has lost strength and stands in a city, for- // the missing strength up to the city's free civilians; the sim's own Reinforce, run on a copy, decides, and its- // refusal shows as the other orders' do. None while one is queued for the unit.+ // the missing strength up to the city's free civilians; a preview of the exact queue a press would leave decides,+ // and its refusal shows as the other orders' do. None while one is queued for the unit.reinforce = null;var reinforceQueued = shownUnit is int rq && bridge.QueuedLike(new Reinforce(rq, "", 0)) != null;if (orderUnit is int ru && own && !reinforceQueued && s.Units.TryGetValue(ru, out var formation) && Training.Room(s, formation) > 0&& c.SettlementHexes.FirstOrDefault(h => h.Q == formation.Q && h.R == formation.R && s.Cities.ContainsKey(h.Id)) is { } home){+ // At least one group, so a city with no free civilians still shows the sim's refusal; the preview decides.var n = System.Math.Max(1, System.Math.Min(Training.Room(s, formation), Training.Available(s, home.Id, bridge.Queued)));- var why = Training.Reinforce(c, s.Clone(), ru, home.Id, n, new List<Cause>());- if (why == null) reinforce = new Reinforce(ru, home.Id, n);- else if (SimBridge.ReasonText(text, why, c, townNamesHe) is var said && !refusals.Contains(said)) refusals.Add(said);+ var press = new Reinforce(ru, home.Id, n);+ var queue = bridge.Queued.ToList();+ var old = bridge.QueuedLike(press);+ var slot = old == null ? -1 : queue.IndexOf(old);+ if (slot >= 0) queue[slot] = press; else queue.Add(press);+ var preview = Simulation.Preview(c, bridge.TurnStart, bridge.Session.Committed.Concat(queue).ToList());+ var rejected = preview.Rejected.FirstOrDefault(x => ReferenceEquals(x.Command, press));+ if (rejected == null) reinforce = press;+ else if (SimBridge.ReasonText(text, rejected.Reason, c, townNamesHe) is var said && !refusals.Contains(said)) refusals.Add(said);}reinforceButton.style.display = reinforce != null ? DisplayStyle.Flex : DisplayStyle.None;if (reinforce is Reinforce offer) reinforceButton.text = text.Format("unit.order.reinforce", offer.Count);diff --git a/unity/Assets/Tests/EditMode/DollarConversionTests.cs b/unity/Assets/Tests/EditMode/DollarConversionTests.csindex 532de61e7..0aa899d43 100644--- a/unity/Assets/Tests/EditMode/DollarConversionTests.cs+++ b/unity/Assets/Tests/EditMode/DollarConversionTests.cs@@ -124,6 +124,33 @@ public class DollarConversionTestsAssert.IsFalse(ui.Q<Button>("convert-dollars").enabledSelf);}+ // Red-first prediction at ae4bfdaab: Render and Convert inspect reserves 10 before the queued choice spends 8,+ // so the refusal is blank and the conversion is queued even though End turn rejects it for reserves.+ [Test]+ public void AQueuedChoiceThatSpendsReservesRefusesConversionBeforeItIsQueued()+ {+ var b = Bridge(false, false); var t = En; var c = b.Content;+ b.State.Rung = EconomySystem.WarRung;+ b.State.FxReserves = 10;+ b.State.PendingEvents.Clear();+ b.State.PendingEvents.Add("austerity_1949");+ Assert.IsNull(b.Queue(new ChooseEventOption("austerity_1949", "decline")), "the reserve-spending choice is queued first");+ var candidate = new ConvertDollars(4);+ var preview = Simulation.Preview(c, b.TurnStart, b.Session.Committed.Concat(b.Queued).Append(candidate).ToList());+ var rejected = preview.Rejected.Single(x => ReferenceEquals(x.Command, candidate));+ Assert.AreEqual(EconomySystem.RefusedDollarsReserves, rejected.Reason, "precondition: the exact End-turn preview refuses reserves");++ using var ui = new UiTestKit();+ using var defence = new DefencePresenter(ui.Root, b, t);+ var refusal = ui.Q<Label>("dollars-refusal");+ Assert.AreEqual(SimBridge.ReasonText(t, rejected.Reason, c), refusal.text);+ ui.Press("convert-dollars");+ Assert.AreEqual(1, b.Queued.Count);+ Assert.IsInstanceOf<ChooseEventOption>(b.Queued.Single());+ Assert.IsFalse(b.Queued.OfType<ConvertDollars>().Any(), "the refused conversion is not queued");+ Assert.AreEqual(SimBridge.ReasonText(t, rejected.Reason, c), refusal.text, "the preview's refusal stays shown");+ }+// R-MONEY-004 (owner, 2 November 2026: "Box shows queued order (Recommended)"): with a conversion queued, a new number// in the box replaces it at once, so the box, the Money line and what End turn converts agree; the reserve and the total// converted keep the turn's start until End turn. An amount the sim refuses clears the queue and shows the refusal.diff --git a/unity/Assets/Tests/EditMode/PanelPreviewShots.cs b/unity/Assets/Tests/EditMode/PanelPreviewShots.csnew file mode 100644index 000000000..3df6b0f8d--- /dev/null+++ b/unity/Assets/Tests/EditMode/PanelPreviewShots.cs@@ -0,0 +1,230 @@+#nullable enable+using System;+using System.Collections;+using System.IO;+using System.Linq;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.Map;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEditor.SceneManagement;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++/// <summary>Writes the before and after stills for #2744 (refs #2740), in English and Hebrew, to+/// `.superpowers/shots-2744/<tag>/` (local, not committed): Assets/Map.unity, its UI drawn through a copy of its+/// PanelSettings into a transparent 1280x720 texture and laid over the main camera's own 1280x720 frame, as CivMovementShots+/// does, so the map shows under the UI. Each state is the one the PR's own tests build, on a golden-seed+/// game the root goes on with (GameRoot.Begin keep:), so the shot is the real screen over the real map.+///+/// Shots (`{lang}` is `en` or `he`):+/// - `dollars-refused-{lang}`: the Defence screen's dollar panel at the war rung with reserves 10 and nothing converted yet,+/// after the queued `austerity_1949` "decline" (fx_reserves -8), with the box at 4+/// (DollarConversionTests.AQueuedChoiceThatSpendsReserves...). The golden game is played by HistoricalAI to the first turn+/// on or after 10 March 1949, the day the card's office, rationing_minister, first has a holder (content/people.yaml,+/// Dov Yosef from 1949-03-10; content/offices.yaml, the office from 1949-03-10): the card cannot be drawn on 15 May 1948.+/// The war rung (EconomySystem.WarRung) is set, as the test sets it, in case the run has left it by then.+/// After: the reserves refusal line under Convert. Before: no refusal line, as the panel read the state without the queue.+/// - `dollars-refused-pressed-{lang}`: the same panel after the player presses Convert. After: nothing more queued, the refusal+/// still shown. Before: the conversion shows as queued, which End turn then refuses.+/// - `reinforce-after-reassign-{lang}`: Golani's unit card, one strength short, in Tel Aviv, whose only idle civilian a queued+/// ReassignCraftsmen takes (UnitOrdersTests.AQueuedCraftsmanReassignmentHidesReinforce...). After: no Reinforce button, the+/// sim's refusal ("0 civilians without work") in the card's reason line (info-reason). Before: Reinforce is offered and+/// enabled. On 15 May 1948; the pending events (the opening idf_founding card) are cleared before the root draws the game,+/// so no event card covers the map, and the button or the reason line is scrolled into the info panel's view. The SHOT+/// line logs their world bounds and whether each lies inside the 1280x720 texture.+///+/// Run (Unity closed on the project; the same file, unchanged, on both trees, at the same resolution):+/// AFTER, with the PR head checked out:+/// SHOTS_TAG=after <Unity> -batchmode -projectPath unity -runTests -testPlatform EditMode -testFilter PanelPreviewShots -testResults /tmp/shots-2744-after.xml+/// BEFORE, with this file and its .meta copied onto main:+/// SHOTS_TAG=before <Unity> -batchmode -projectPath unity -runTests -testPlatform EditMode -testFilter PanelPreviewShots -testResults /tmp/shots-2744-before.xml+/// Uses only APIs that exist on main as well (checked against origin/main when written). Explicit, so CI never runs it.</summary>+[Explicit("writes stills for a pull request, not a check")]+public class PanelPreviewShots+{+ const int Width = 1280, Height = 720;+ string saveDir = "";+ string shotDir = "";+ RenderTexture? rt; PanelSettings? ps;+ VisualElement ui = null!;+ GameRoot root = null!;++ [SetUp]+ public void TempSaves()+ {+ saveDir = Path.Combine(Path.GetTempPath(), "statecraft-shots-" + Guid.NewGuid().ToString("N"));+ var tag = Environment.GetEnvironmentVariable("SHOTS_TAG");+ shotDir = Path.Combine(Directory.GetCurrentDirectory(), ".superpowers", "shots-2744", string.IsNullOrEmpty(tag) ? "untagged" : tag);+ Directory.CreateDirectory(shotDir);+ }++ [TearDown]+ public void DiscardScene()+ {+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ if (ps != null) Object.DestroyImmediate(ps);+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);+ }++ SimBridge Bridge => root.Bridge!;+ static Content C => MapFocusTests.Inputs.Content;+ static UiText Text(bool he) => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(he ? UiPaths.StringsHebrew : UiPaths.Strings).text);++ IEnumerator Frames(int n) { for (int i = 0; i < n; i++) yield return null; }++ /// <summary>A golden-seed historical game, shaped by <paramref name="shape"/> before the root draws it.</summary>+ IEnumerator Boot(bool hebrew, Action<GameSession> shape)+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ var doc = Object.FindFirstObjectByType<UIDocument>();+ // The UI goes into a transparent texture and Shot puts it over the map camera's frame, as CivMovementShots does.+ rt = new RenderTexture(Width, Height, 24, RenderTextureFormat.ARGB32);+ ps = Object.Instantiate(doc.panelSettings);+ ps.targetTexture = rt; ps.clearColor = true; ps.colorClearValue = Color.clear;+ doc.panelSettings = ps;+ Object.FindFirstObjectByType<MapScene>().Build(MapFocusTests.Inputs.Map);+ root = Object.FindFirstObjectByType<GameRoot>();+ root.Store = new SaveStore(saveDir);+ if (hebrew) root.Language = UiLanguage.Hebrew;+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ shape(g);+ root.Begin(MapFocusTests.Inputs, 0, keep: new SimBridge(g, Text(hebrew)));+ ui = doc.rootVisualElement;+ for (int i = 0; i < 30 && !(ui.Q("top-bar").worldBound.height > 0); i++) yield return null;+ yield return Frames(5);+ }++ /// <summary>Puts any open event card away, as its Hide button does, and closes the advisor, so the screen under it can be seen.</summary>+ IEnumerator PutCardsAway()+ {+ var hide = ui.Q<Button>("event-hide");+ if (hide != null && hide.resolvedStyle.display != DisplayStyle.None && hide.enabledInHierarchy) UiTestKit.Press(hide);+ root.Card?.Collapse(takeFocus: false);+ if (root.Advisor != null && root.Advisor.IsOpen) UiTestKit.Press(ui.Q<Button>("advisor-close")); // as CivMovementShots.Boot+ yield return Frames(3);+ }++ static void IntoView(VisualElement? e)+ {+ if (e == null) return;+ e.GetFirstAncestorOfType<ScrollView>()?.ScrollTo(e);+ }++ /// <summary>An element's world bound and whether it lies inside the panel, which the 1280x720 texture shows whole.</summary>+ string Bound(VisualElement? e)+ {+ if (e == null) return "(missing)";+ var b = e.worldBound; var all = ui.worldBound;+ var inside = b.width > 0 && b.height > 0 && b.xMin >= all.xMin && b.yMin >= all.yMin && b.xMax <= all.xMax && b.yMax <= all.yMax;+ return $"at {b} inside={inside} (panel {all})";+ }++ static Color[] Read(RenderTexture from)+ {+ var prev = RenderTexture.active;+ RenderTexture.active = from;+ var tex = new Texture2D(from.width, from.height, TextureFormat.RGBA32, false);+ tex.ReadPixels(new Rect(0, 0, from.width, from.height), 0, 0);+ tex.Apply();+ RenderTexture.active = prev;+ var px = tex.GetPixels();+ Object.DestroyImmediate(tex);+ return px;+ }++ /// <summary>The map camera's frame with the UI texture over it (the UI's pixels are premultiplied by their alpha), copied+ /// from CivMovementShots.Shot, which writes to its own folder.</summary>+ void Shot(string name)+ {+ var cam = Camera.main;+ var frame = new RenderTexture(Width, Height, 24, RenderTextureFormat.ARGB32);+ var before = cam.targetTexture;+ cam.targetTexture = frame; cam.Render(); cam.targetTexture = before;+ var map = Read(frame); var over = Read(rt!);+ frame.Release(); Object.DestroyImmediate(frame);+ var outPx = new Color[map.Length];+ for (int i = 0; i < map.Length; i++)+ {+ var u = over[i]; var m = map[i];+ outPx[i] = new Color(u.r + m.r * (1f - u.a), u.g + m.g * (1f - u.a), u.b + m.b * (1f - u.a), 1f);+ }+ var tex = new Texture2D(Width, Height, TextureFormat.RGB24, false);+ tex.SetPixels(outPx); tex.Apply();+ File.WriteAllBytes(Path.Combine(shotDir, name + ".png"), tex.EncodeToPNG());+ Object.DestroyImmediate(tex);+ Debug.Log($"SHOT {name} -> {shotDir}");+ }++ IEnumerator DollarPanel(bool hebrew)+ {+ var lang = hebrew ? "he" : "en";+ yield return Boot(hebrew, g =>+ {+ // The first turn with a holder of rationing_minister (from 10 March 1949), as CabinetScreenTests.In1950 plays to 1950.+ while (g.State.Date < new DateTime(1949, 3, 10)) g.Step(HistoricalAI.Commands(C, g.State));+ Debug.Log($"SHOT dollars: game on {g.State.Date:yyyy-MM-dd}, rung {g.State.Rung}, reserves {g.State.FxReserves}, converted {g.State.DollarsConverted}");+ g.State.Rung = EconomySystem.WarRung;+ g.State.FxReserves = 10;+ g.State.DollarsConverted = 0;+ g.State.PendingEvents.Clear();+ g.State.PendingEvents.Add("austerity_1949");+ });+ Debug.Log($"SHOT dollars: queue decline -> {Bridge.Queue(new ChooseEventOption("austerity_1949", "decline")) ?? "queued"}");+ yield return PutCardsAway();+ UiTestKit.Press(ui.Q<Button>("nav-defence"));+ yield return Frames(5);+ var amount = ui.Q<IntegerField>("dollars-amount");+ amount.value = 4;+ IntoView(ui.Q("defence-dollars"));+ yield return Frames(5);+ Debug.Log($"SHOT dollars-refused-{lang}: refusal \"{ui.Q<Label>("dollars-refusal")?.text}\" {Bound(ui.Q("dollars-refusal"))}; convert {Bound(ui.Q("convert-dollars"))}");+ Shot($"dollars-refused-{lang}");++ UiTestKit.Press(ui.Q<Button>("convert-dollars"));+ yield return Frames(5);+ Debug.Log($"SHOT dollars-refused-pressed-{lang}: queued [{string.Join(", ", Bridge.Queued.Select(x => x.GetType().Name))}]");+ Shot($"dollars-refused-pressed-{lang}");+ }++ IEnumerator ReinforceCard(bool hebrew)+ {+ var lang = hebrew ? "he" : "en";+ var id = C.StartingForces.ToList().FindIndex(f => f.Row == "golani");+ Assert.GreaterOrEqual(id, 0, "Golani is a starting force");+ var city = C.SettlementHexes.Single(h => h.Id == "tel_aviv");+ yield return Boot(hebrew, g =>+ {+ var u = g.State.Units[id];+ g.State.Units[id] = new Unit(u.Id, u.Type, city.Q, city.R, u.Service, u.Side, u.Strength - 1, u.Order, u.OrderTarget, u.HomeCity, u.Strength);+ var telAviv = g.State.Cities[city.Id];+ g.State.Cities[city.Id] = telAviv.WithCounts(1, 0, 0).WithCraftsmen(0).WithQualified(new Qualified(1, 0, Array.Empty<int>()));+ g.State.Arms = 100;+ // The opening decision (idf_founding) and any other waiting card would cover the map and the unit card.+ g.State.PendingEvents.Clear();+ });+ yield return PutCardsAway();+ Debug.Log($"SHOT reinforce: queue reassign -> {Bridge.Queue(new ReassignCraftsmen(city.Id, 1)) ?? "queued"}");+ yield return Frames(3);+ root.FocusUnit("golani");+ yield return Frames(8);+ var button = ui.Q<Button>("info-reinforce");+ var reason = ui.Q<Label>("info-reason");+ var offered = button != null && button.style.display.value != DisplayStyle.None;+ IntoView(offered ? button : reason);+ yield return Frames(5);+ Debug.Log($"SHOT reinforce-after-reassign-{lang}: Reinforce {(button == null ? "missing" : button.style.display.value.ToString())}"+ + $" enabled={button?.enabledInHierarchy} {Bound(button)}; reason \"{reason?.text}\" {Bound(reason)}");+ Shot($"reinforce-after-reassign-{lang}");+ }++ [UnityTest] public IEnumerator DollarsEnglish() { yield return DollarPanel(false); }+ [UnityTest] public IEnumerator DollarsHebrew() { yield return DollarPanel(true); }+ [UnityTest] public IEnumerator ReinforceEnglish() { yield return ReinforceCard(false); }+ [UnityTest] public IEnumerator ReinforceHebrew() { yield return ReinforceCard(true); }+}diff --git a/unity/Assets/Tests/EditMode/PanelPreviewShots.cs.meta b/unity/Assets/Tests/EditMode/PanelPreviewShots.cs.metanew file mode 100644index 000000000..c2b76aeb2--- /dev/null+++ b/unity/Assets/Tests/EditMode/PanelPreviewShots.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: a9b1f9872c64bf8f24957b59a255a0c5\ No newline at end of filediff --git a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs b/unity/Assets/Tests/EditMode/UnitOrdersTests.csindex 971311697..3fb794d95 100644--- a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs+++ b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs@@ -430,6 +430,35 @@ public class UnitOrdersTests}}+ // Red-first prediction at ae4bfdaab: the card runs the sim's Reinforce on a copy of the displayed state, without the queue,+ // so it offers Reinforce even though the earlier craftsman reassignment leaves End turn no idle civilian for it.+ [Test]+ public void AQueuedCraftsmanReassignmentHidesReinforceThatEndTurnWouldRefuse()+ {+ using var ui = new UiTestKit();+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ var bridge = new SimBridge(g, Text);+ var token = UnitRoster.FromState(Units, C, g.State, _ => true, (row, a, q, r) => a).Single(x => x.Unit.Id == "golani");+ var id = UnitCard.SimUnit(C, g.State, token.Unit)!.Value;+ var u = g.State.Units[id];+ var city = C.SettlementHexes.Single(h => h.Id == "tel_aviv");+ g.State.Units[id] = new Unit(u.Id, u.Type, city.Q, city.R, u.Service, u.Side, u.Strength - 1, u.Order, u.OrderTarget, u.HomeCity, u.Strength);+ var telAviv = g.State.Cities[city.Id];+ g.State.Cities[city.Id] = telAviv.WithCounts(1, 0, 0).WithCraftsmen(0).WithQualified(new Qualified(1, 0, System.Array.Empty<int>()));+ g.State.Arms = 100;+ Assert.IsNull(bridge.Queue(new ReassignCraftsmen(city.Id, 1)));+ Assert.AreEqual(0, Training.Available(g.State, city.Id, bridge.Queued), "the queued reassignment reserves the only idle civilian");+ var candidate = new Reinforce(id, city.Id, 1);+ var preview = Simulation.Preview(C, bridge.TurnStart, bridge.Session.Committed.Concat(bridge.Queued).Append(candidate).ToList());+ var rejected = preview.Rejected.Single(x => ReferenceEquals(x.Command, candidate));+ StringAssert.Contains("0 civilians without work", rejected.Reason, "precondition: the exact End-turn preview refuses Reinforce");++ PlacedToken? selected = new PlacedToken(token, new AnchorSpot(0, 0, 0, 0, false));+ using var info = new InfoPanelPresenter(ui.Root, bridge, Text, new Dictionary<string, string>(), selectedUnit: () => selected);+ info.ShowUnit();+ Assert.AreEqual(DisplayStyle.None, ui.Q<Button>("info-reinforce").style.display.value);+ }+/// <summary>#2072, owner review item 1: a Reinforce the sim refuses for Arms ("Tel Aviv: not enough Arms for basic training/// (need ..)") reaches the player through SimBridge, in Hebrew whole: the town and the course in Hebrew too, no Latin/// letter. The bridge queues it (a Reinforce waits for End turn) and End turn raises the sim's refusal, which the toast