A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Show Food and Arms stocks in the turn report and Why, and queue Arms purchases from Defence (#1790)
Eyal Golan16f449d47983
diff --git a/changelog.d/731.md b/changelog.d/731.mdnew file mode 100644index 000000000..901e2c0bd--- /dev/null+++ b/changelog.d/731.md@@ -0,0 +1 @@+- Keep the top bar as main; show Arms in Defence and Food/Arms stocks, turn changes and existing causes in the report and Why. Preserve queued Arms purchases. Refs #731.diff --git a/sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csproj b/sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csprojindex e54c9c3bd..fdf4287ee 100644--- a/sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csproj+++ b/sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csproj@@ -13,6 +13,9 @@<ProjectReference Include="../Statecraft.Sim/Statecraft.Sim.csproj" /><ProjectReference Include="../Statecraft.Cli/Statecraft.Cli.csproj" /></ItemGroup>+ <ItemGroup>+ <Compile Include="../../unity/Assets/Scripts/UI/StockMeter.cs" Link="Presentation/StockMeter.cs" />+ </ItemGroup><ItemGroup><Using Include="Xunit" /></ItemGroup>diff --git a/sim/Statecraft.Sim.Tests/StockMeterTests.cs b/sim/Statecraft.Sim.Tests/StockMeterTests.csnew file mode 100644index 000000000..6d4d3504d--- /dev/null+++ b/sim/Statecraft.Sim.Tests/StockMeterTests.cs@@ -0,0 +1,33 @@+using System.Globalization;+using Statecraft.Game.UI;++public class StockMeterTests+{+ static string Format(string key, long n) => n.ToString(key == "hud.delta_stock" ? "+#,##0;-#,##0" : "N0", CultureInfo.InvariantCulture);++ [Fact]+ public void OpeningStockAndUnchangedStockHaveNoChange()+ {+ foreach (var before in new int?[] { null, 1200 })+ {+ var m = StockMeter.From(1200, before, Format);+ Assert.Equal("1,200", m.Value);+ Assert.Equal("1,200", m.SayValue);+ Assert.Equal("", m.Delta);+ Assert.Equal("", m.SayChange);+ Assert.Equal(0, m.Sign);+ }+ }++ [Theory]+ [InlineData(12, 10, "+2", 1, "2")]+ [InlineData(0, 12, "-12", -1, "12")]+ [InlineData(int.MaxValue, 0, "+2,147,483,647", 1, "2,147,483,647")]+ public void ChangesAreWholeStockUnits(int now, int before, string delta, int sign, string said)+ {+ var m = StockMeter.From(now, before, Format);+ Assert.Equal(delta, m.Delta);+ Assert.Equal(sign, m.Sign);+ Assert.Equal(said, m.SayChange);+ }+}diff --git a/tools/tests/test_population_hash_cleanup.py b/tools/tests/test_population_hash_cleanup.pyindex d28ebef6a..52ad86748 100644--- a/tools/tests/test_population_hash_cleanup.py+++ b/tools/tests/test_population_hash_cleanup.py@@ -24,6 +24,10 @@ def test_population_hash_check_cleans_its_copy_on_success_and_failure(tmp_path,repo = root / "repo"shutil.copytree(REPO / "sim", repo / "sim", ignore=shutil.ignore_patterns("bin", "obj", "TestResults"))shutil.copytree(REPO / "content", repo / "content")+ # The managed HUD tests compile the real Unity-free formatter via a linked source.+ formatter = Path("unity/Assets/Scripts/UI/StockMeter.cs")+ (repo / formatter).parent.mkdir(parents=True)+ shutil.copyfile(REPO / formatter, repo / formatter)source = repo / "sim/Statecraft.Sim.Tests/SaveGameTests.cs"text = source.read_text(encoding="utf-8")@@ -51,7 +55,7 @@ def test_population_hash_check_cleans_its_copy_on_success_and_failure(tmp_path,(sentinel / "keep.txt").write_text("another run's data", encoding="utf-8")results = root / "results"run = subprocess.run(- ["dotnet", "test", str(repo / "sim/Statecraft.sln"), "-c", "Release", "--nologo",+ ["dotnet", "test", str(repo / "sim/Statecraft.sln"), "-c", "Release", "--nologo", "-nodeReuse:false", "-p:UseSharedCompilation=false","--filter", f"FullyQualifiedName={TEST}", "--logger", "trx;LogFileName=population.trx","--results-directory", str(results)],cwd=repo, env={**os.environ, "TMPDIR": str(temporary), "TMP": str(temporary), "TEMP": str(temporary)},diff --git a/unity/Assets/Scripts/UI/ArmsPurchasePresenter.cs b/unity/Assets/Scripts/UI/ArmsPurchasePresenter.csnew file mode 100644index 000000000..ef7d03adc--- /dev/null+++ b/unity/Assets/Scripts/UI/ArmsPurchasePresenter.cs@@ -0,0 +1,81 @@+#nullable enable+using System;+using Statecraft.Sim;+using UnityEngine.UIElements;++namespace Statecraft.Game.UI+{+ /// <summary>One replaceable purchase at End turn. Stocks change only when the sim executes the order.</summary>+ public sealed class ArmsPurchasePresenter : IDisposable+ {+ readonly VisualElement panel;+ readonly SimBridge bridge;+ readonly UiText text;+ readonly IntegerField count;+ readonly Button buy, withdraw;+ readonly Action onBuy, onWithdraw;+ readonly EventCallback<ChangeEvent<int>> onCount;+ readonly PressSource presses;++ public ArmsPurchasePresenter(VisualElement root, SimBridge bridge, UiText text)+ {+ panel = root.Q("defence-arms"); this.bridge = bridge; this.text = text;+ count = panel.Q<IntegerField>("arms-count");+ buy = panel.Q<Button>("buy-arms"); withdraw = panel.Q<Button>("withdraw-arms");+ count.label = text["arms.count"];+ panel.Q<Label>("arms-title").text = text["hud.caption.arms"];+ buy.text = text["arms.buy"]; withdraw.text = text["arms.withdraw"];+ onBuy = () =>+ {+ var reason = bridge.Queue(new BuyArms(count.value));+ Render();+ panel.Q<Label>("arms-refusal").text = reason ?? "";+ };+ presses = new PressSource(panel);+ onWithdraw = () =>+ {+ var queued = bridge.QueuedLike(new BuyArms(1));+ if (queued == null) return;+ var keyboard = presses.ByKeyboard;+ bridge.Withdraw(queued);+ // Render has just disabled Withdraw, which had the focus. Keep the keyboard in the panel: Buy, else the amount.+ if (keyboard) FocusReturn.ToOrWithin(buy, null, panel);+ };+ onCount = _ => Render();+ buy.clicked += onBuy; withdraw.clicked += onWithdraw; count.RegisterValueChangedCallback(onCount);+ bridge.Changed += Render;+ if (bridge.QueuedLike(new BuyArms(1)) is BuyArms old) count.SetValueWithoutNotify(old.Count);+ Render();+ }++ public void Render()+ {+ var c = bridge.Content; var s = bridge.State;+ panel.style.display = c.IsGdd ? DisplayStyle.Flex : DisplayStyle.None;+ if (!c.IsGdd) return;+ var order = new BuyArms(count.value);+ var queued = bridge.QueuedLike(order) as BuyArms;+ panel.Q<Label>("arms-stock").text = text.Format("arms.stock", s.Arms);+ // Use the active era's price, just as Pools.BuyArms does. No training or combat-use assumption.+ var cost = count.value * c.RulesAt(s.Date).Mvp!.ArmsPrice!.Value;+ panel.Q<Label>("arms-money").text = text.Format("arms.money", PlayerText.Money(c, "treasury", cost));+ var attention = panel.Q<Label>("arms-attention");+ attention.style.display = c.UsesAttention ? DisplayStyle.Flex : DisplayStyle.None;+ attention.text = c.UsesAttention ? text.Format("arms.attention", bridge.Price(order)!.Value, bridge.AttentionLeft!.Value) : "";+ attention.pickingMode = c.UsesAttention ? PickingMode.Position : PickingMode.Ignore;+ panel.Q<Label>("arms-queued").text = queued == null ? "" : text.Format("arms.queued", queued.Count);+ // Attention refusal uses Queue's own check and wording. Keep the button available to explain it.+ buy.SetEnabled(s.GameOver == null && count.value > 0);+ withdraw.SetEnabled(s.GameOver == null && queued != null);+ panel.Q<Label>("arms-refusal").text = s.GameOver != null ? text["order.game_over"]+ : count.value < 1 ? text["arms.minimum"]+ : !bridge.CanPay(order) ? text["arms.no_attention"] : "";+ }++ public void Dispose()+ {+ bridge.Changed -= Render; presses.Dispose();+ buy.clicked -= onBuy; withdraw.clicked -= onWithdraw; count.UnregisterValueChangedCallback(onCount);+ }+ }+}diff --git a/unity/Assets/Scripts/UI/ArmsPurchasePresenter.cs.meta b/unity/Assets/Scripts/UI/ArmsPurchasePresenter.cs.metanew file mode 100644index 000000000..bb30a1f7b--- /dev/null+++ b/unity/Assets/Scripts/UI/ArmsPurchasePresenter.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: e8b63a16d03c4a73872163676480746bdiff --git a/unity/Assets/Scripts/UI/DefencePresenter.cs b/unity/Assets/Scripts/UI/DefencePresenter.csindex f03bf0f43..2dda109e0 100644--- a/unity/Assets/Scripts/UI/DefencePresenter.cs+++ b/unity/Assets/Scripts/UI/DefencePresenter.cs@@ -22,6 +22,7 @@ namespace Statecraft.Game.UIpublic const string BudgetLine = "defense_minister";/// <summary>The leadership portrait box in logical pixels (Statecraft.uss .leader .card-portrait).</summary>public static readonly UnityEngine.Vector2 LeaderPortrait = new UnityEngine.Vector2(190f, 200f);+ readonly ArmsPurchasePresenter arms;readonly VisualElement screen; readonly SimBridge bridge; readonly UiText text; readonly PortraitCatalog? portraits;readonly Button escalate, deEscalate, mobUp, mobDown; readonly Action onEscalate, onDeEscalate, onMobUp, onMobDown;@@ -37,6 +38,7 @@ namespace Statecraft.Game.UIscreen.Q<Label>("defence-screen-title").text = text["defence.title"];screen.Q<Label>("defence-title-prisoners").text = text["defence.section_prisoners"].ToUpperInvariant(); // #755, as SectionsdeEscalate.text = text["defence.lower"]; escalate.text = text["defence.raise"];+ arms = new ArmsPurchasePresenter(screen, bridge, text);bridge.Changed += OnChanged;ScreenNav.OnOpened(screen, () => { if (dirty) Render(); });Render();@@ -59,6 +61,7 @@ namespace Statecraft.Game.UI/// <summary>Unsubscribes from the bridge and the buttons and empties the leadership cards (the owner calls this when disabled).</summary>public void Dispose(){+ arms.Dispose();bridge.Changed -= OnChanged;if (screen.userData is System.Action) screen.userData = null;escalate.clicked -= onEscalate; deEscalate.clicked -= onDeEscalate; mobUp.clicked -= onMobUp; mobDown.clicked -= onMobDown;diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.csindex d8a9838a0..63505d196 100644--- a/unity/Assets/Scripts/UI/SimBridge.cs+++ b/unity/Assets/Scripts/UI/SimBridge.cs@@ -67,6 +67,7 @@ namespace Statecraft.Game.UI/// SimBridgeGuardTests, which checks that every command type is listed here or is one per turn by design.</summary>internal static string Key(Command c) => c switch{+ BuyArms _ => Pools.BuyArmsKind,ChooseEventOption e => "event:" + e.EventId,SetPolicy p => "policy:" + p.Policy,Appoint a => "appoint:" + a.Office,diff --git a/unity/Assets/Scripts/UI/StockMeter.cs b/unity/Assets/Scripts/UI/StockMeter.csnew file mode 100644index 000000000..8c6a9ff7c--- /dev/null+++ b/unity/Assets/Scripts/UI/StockMeter.cs@@ -0,0 +1,28 @@+#nullable enable+using System;++namespace Statecraft.Game.UI+{+ /// <summary>One stock reading: its value and the change since the last turn (empty when there is none), and the+ /// two again in words: SayValue, and SayChange without its sign (empty when there is no change).</summary>+ public readonly struct StockReading+ {+ public readonly string Value, Delta, SayValue, SayChange;+ /// <summary>+1 up, -1 down, 0 unchanged or unknown.</summary>+ public readonly int Sign;+ public StockReading(string value, string delta, int sign, string sayValue, string sayChange)+ { Value = value; Delta = delta; Sign = sign; SayValue = sayValue; SayChange = sayChange; }+ }++ /// <summary>Whole stock units, with no indicator or population conversion. Shared by Food and Arms.</summary>+ public static class StockMeter+ {+ public static StockReading From(int now, int? before, Func<string, long, string> format)+ {+ var value = format("hud.stock", now);+ long change = before.HasValue ? (long)now - before.Value : 0;+ return change == 0 ? new StockReading(value, "", 0, value, "")+ : new StockReading(value, format("hud.delta_stock", change), Math.Sign(change), value, format("hud.stock", Math.Abs(change)));+ }+ }+}diff --git a/unity/Assets/Scripts/UI/StockMeter.cs.meta b/unity/Assets/Scripts/UI/StockMeter.cs.metanew file mode 100644index 000000000..f9ec84c46--- /dev/null+++ b/unity/Assets/Scripts/UI/StockMeter.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 3e0ddee898944746846bf802f131592adiff --git a/unity/Assets/Scripts/UI/TurnReportPresenter.cs b/unity/Assets/Scripts/UI/TurnReportPresenter.csindex d802594e9..e74f20ecc 100644--- a/unity/Assets/Scripts/UI/TurnReportPresenter.cs+++ b/unity/Assets/Scripts/UI/TurnReportPresenter.cs@@ -94,7 +94,7 @@ namespace Statecraft.Game.UI}/// <summary>The report's lines for the session's last turn: each top-bar meter whose shown change is not empty, in- /// the bar's order (the meters have different units, so no order by size is given without a rule); then, under+ /// the bar's order (the meters have different units, so no order by size is given without a rule); then national stocks; under/// <see cref="EnemyRow"/>, the enemy's orders (#1293).</summary>public static IReadOnlyList<Line> Lines(SimBridge bridge, UiText text, IReadOnlyList<UnitEntry>? units = null,IReadOnlyDictionary<string, string>? townNamesHe = null)@@ -108,11 +108,41 @@ namespace Statecraft.Game.UIlines.Add(new Line(id, text.Format("report.line", text["hud.caption." + id], meter.Delta), HudModel.Causes(bridge.Session.Last, id,w => CauseText.Line(w, bridge.Content, units ?? Array.Empty<UnitEntry>(), text, townNamesHe))));}+ lines.AddRange(StockLines(bridge, text, units, townNamesHe));var enemy = EnemyOrders(bridge, text, units);if (enemy.Count > 0) lines.Add(new Line(EnemyRow, text["report.enemy"], enemy));return lines;}+ /// <summary>National stocks, independently of the top bar. Include unchanged stocks; never invent causes+ /// for consumption/imports that the sim did not report. Legacy has no national pools.</summary>+ public static IReadOnlyList<Line> StockLines(SimBridge bridge, UiText text,+ IReadOnlyList<UnitEntry>? units = null, IReadOnlyDictionary<string, string>? townNamesHe = null)+ {+ var lines = new List<Line>();+ if (!bridge.Content.IsGdd) return lines;+ foreach (var id in new[] { Pools.FoodTarget, Pools.ArmsTarget })+ {+ var s = bridge.State; var prev = bridge.Session.Previous;+ var stock = StockMeter.From(id == Pools.FoodTarget ? s.Food : s.Arms,+ prev == null ? (int?)null : id == Pools.FoodTarget ? prev.Food : prev.Arms,+ (key, n) => text.Format(key, n));+ var heading = stock.Delta.Length == 0+ ? text.Format("report.stock_line", text["hud.caption." + id], stock.Value)+ : text.Format("report.stock_change", text["hud.caption." + id], stock.Value, stock.Delta);+ lines.Add(new Line(id, heading, StockCauses(bridge.Session.Last, id,+ w => CauseText.Line(w, bridge.Content, units ?? Array.Empty<UnitEntry>(), text, townNamesHe))));+ }+ return lines;+ }++ /// <summary>The same largest-two and stable tie order as the report's indicators, matched to stock targets.</summary>+ public static IReadOnlyList<string> StockCauses(StepResult? turn, string target, Func<Cause, string> line) =>+ turn == null ? Array.Empty<string>() : turn.Why.Select((w, i) => (w, i))+ .Where(x => x.w.Target == target && x.w.Delta != 0)+ .OrderByDescending(x => Math.Abs(x.w.Delta)).ThenBy(x => x.i)+ .Take(HudModel.MaxCauses).Select(x => line(x.w)).ToList();+/// <summary>#1293: every order the enemy AI gave in the last turn, and every attack its units made, a standing one too/// (#1297), as the sim names it on its cause (Cause.EnemyOrder, R-ENEMY-001), in the sim's order, in the player's/// language: Message is English only. The unit is named by its rowdiff --git a/unity/Assets/Scripts/UI/WhyPresenter.cs b/unity/Assets/Scripts/UI/WhyPresenter.csindex 82ba8b344..072a2726b 100644--- a/unity/Assets/Scripts/UI/WhyPresenter.cs+++ b/unity/Assets/Scripts/UI/WhyPresenter.cs@@ -39,6 +39,7 @@ namespace Statecraft.Game.UIpublic void Dispose() { bridge.Changed -= Render; }GameSession? shownSession; StepResult? shown;+ int shownFood, shownArms;/// <summary>Shows the session's last turn. Does nothing when that same result is already on screen.</summary>public void Render() => Show(bridge.Session.Last);@@ -47,13 +48,21 @@ namespace Statecraft.Game.UI/// as last time are not rebuilt; a new turn, a new game or a loaded save are.</summary>internal void Show(StepResult? last){- if (shownSession == bridge.Session && shown == last && screen.Q<ScrollView>("why-rows").childCount > 0) return;+ if (shownSession == bridge.Session && shown == last && shownFood == bridge.State.Food && shownArms == bridge.State.Arms && screen.Q<ScrollView>("why-rows").childCount > 0) return;shownSession = bridge.Session; shown = last;+ shownFood = bridge.State.Food; shownArms = bridge.State.Arms;var rows = screen.Q<ScrollView>("why-rows");rows.Clear();var prev = bridge.Session.Previous;screen.Q<Label>("why-turn").text = last == null || prev == null ? "" : text.Format("why.turn",Statecraft.Game.Map.Control1948.DateText(prev.Date, k => text[k]), Statecraft.Game.Map.Control1948.DateText(bridge.State.Date, k => text[k])); // PlayerText.Date is always English (#701)+ // Stocks are separate from cause lines: the full system-grouped ledger below remains intact.+ foreach (var stock in TurnReportPresenter.StockLines(bridge, text))+ {+ var label = new Label(stock.Heading) { name = "why-stock-" + stock.Meter };+ label.AddToClassList("why-stock");+ rows.Add(label);+ }if (last == null) { rows.Add(new Label(text["why.empty"]) { name = "why-empty" }); return; }if (last.Why.Count == 0) { rows.Add(new Label(text["why.nothing"]) { name = "why-nothing" }); return; }int i = 0;diff --git a/unity/Assets/Tests/EditMode/FoodArmsCaptureTests.cs b/unity/Assets/Tests/EditMode/FoodArmsCaptureTests.csnew file mode 100644index 000000000..4bd839221--- /dev/null+++ b/unity/Assets/Tests/EditMode/FoodArmsCaptureTests.cs@@ -0,0 +1,72 @@+#nullable enable+using System;+using System.Collections;+using System.IO;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object=UnityEngine.Object;++// Review-only capture seam: opt-in environment path, no game behaviour or test expectations depend on screenshots.+public class FoodArmsCaptureTests+{+ [UnityTest]+ public IEnumerator SameOpeningStateHudDefenceReportAndWhyFrames()+ {+ var dir=Environment.GetEnvironmentVariable("FOOD_ARMS_CAPTURE_DIR");+ if(!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir);+ foreach(bool he in new[]{false,true})+ foreach(var size in new[]{(1920,1080),(1280,720),(375,667)})+ {+ var rt=new RenderTexture(size.Item1,size.Item2,0); rt.Create();+ var ps=Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel)); ps.targetTexture=rt; ps.clearColor = true; ps.colorClearValue = Color.black;+ var go=new GameObject("FoodArmsMatchedCapture"); go.SetActive(false);+ var doc=go.AddComponent<UIDocument>(); doc.panelSettings=ps; doc.visualTreeAsset=AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml); go.SetActive(true);+ try+ {+ var root=doc.rootVisualElement;+ if(he) root.Q("root").AddToClassList(UiLanguage.HebrewClass);+ root.Q("root").RemoveFromClassList("loading");+ var t=UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(he?UiPaths.StringsHebrew:UiPaths.Strings).text);+ var b=new SimBridge(GameSession.New(ContentLoader.Load(Paths.Content),GoldenRun.Seed,Mode.Historical),t);+ using var hud=new HudPresenter(root,b,t); using var nav=new ScreenNav(root); using var defence=new DefencePresenter(root,b,t);+ for(int i=0;i<25;i++)yield return null;+ Assert.Greater(root.Q("top-bar").worldBound.width,0);+ var unchanged=b.State.Hash();+ Save("hud");+ nav.Open("defence"); for(int i=0;i<20;i++)yield return null;+ root.Q<ScrollView>("defence-body").ScrollTo(root.Q("defence-budget"));+ for(int i=0;i<20;i++)yield return null;+ Assert.IsTrue(ScreenNav.IsOpen(root.Q("screen-defence")));+ Assert.AreEqual(unchanged,b.State.Hash(),"opening and scrolling Defence changes no sim state");+ Save("defence");+ // The panel after the budget share: Arms on this branch, the prisoners panel on main.+ root.Q<ScrollView>("defence-body").ScrollTo(root.Q("defence-arms") ?? root.Q("defence-prisoners"));+ for(int i=0;i<20;i++)yield return null;+ Save("defence-lower");+ // The same turn on both trees: one End turn with no order, then the report it opens and Why.+ nav.Close(); for(int i=0;i<5;i++)yield return null;+ using var report=new TurnReportPresenter(root,b,t,nav); using var why=new WhyPresenter(root,b,t);+ b.EndTurn(); for(int i=0;i<25;i++)yield return null;+ Assert.IsTrue(report.IsOpen,"the turn report opens after End turn");+ Save("report");+ report.Close(); nav.Open("why"); for(int i=0;i<25;i++)yield return null;+ Assert.IsTrue(ScreenNav.IsOpen(root.Q("screen-why")));+ Save("why");+ void Save(string area)+ {+ if(string.IsNullOrEmpty(dir)) return;+ var old=RenderTexture.active; var tex=new Texture2D(rt.width,rt.height,TextureFormat.RGB24,false);+ try {RenderTexture.active=rt;tex.ReadPixels(new Rect(0,0,rt.width,rt.height),0,0);tex.Apply();File.WriteAllBytes(Path.Combine(dir,FormattableString.Invariant($"{(he?"he":"en")}-{size.Item1}x{size.Item2}-{area}.png")),tex.EncodeToPNG());}+ finally{RenderTexture.active=old;Object.DestroyImmediate(tex);}+ }+ }+ finally{Object.DestroyImmediate(go);Object.DestroyImmediate(ps);rt.Release();Object.DestroyImmediate(rt);}+ }+ }+}diff --git a/unity/Assets/Tests/EditMode/FoodArmsCaptureTests.cs.meta b/unity/Assets/Tests/EditMode/FoodArmsCaptureTests.cs.metanew file mode 100644index 000000000..72f4d2fb5--- /dev/null+++ b/unity/Assets/Tests/EditMode/FoodArmsCaptureTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 6e639e61b521463c81fb52203800e347diff --git a/unity/Assets/Tests/EditMode/FoodArmsHudTests.cs b/unity/Assets/Tests/EditMode/FoodArmsHudTests.csnew file mode 100644index 000000000..6086c6dba--- /dev/null+++ b/unity/Assets/Tests/EditMode/FoodArmsHudTests.cs@@ -0,0 +1,316 @@+#nullable enable+using System;+using System.Collections;+using System.Linq;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++public class FoodArmsHudTests+{+ static UiText Text(bool he) => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(he ? UiPaths.StringsHebrew : UiPaths.Strings).text);+ static SimBridge Bridge(bool modern, bool he)+ {+ var dir = Paths.Content;+ var c = ContentLoader.Load(rel =>+ {+ var path = System.IO.Path.Combine(dir, rel);+ if (!System.IO.File.Exists(path)) return null;+ var value = System.IO.File.ReadAllText(path);+ return modern && rel == "eras.yaml" ? value.Replace("loop: gdd", "loop: gdd, ruleset: gdd-0.3") : value;+ }, System.IO.Directory.GetFiles(System.IO.Path.Combine(dir, "events"), "*.yaml").Select(x => "events/" + System.IO.Path.GetFileName(x)));+ var b = new SimBridge(GameSession.New(c, GoldenRun.Seed, Mode.Historical), Text(he));+ if (modern)+ {+ foreach (var r in c.EraRules.Values.Append(c.Rules))+ { r.AttentionCost.Clear(); r.AttentionPerTurn = double.NaN; }+ b.State.Attention = double.NaN;+ }+ return b;+ }++ // The owner's ruling: Food and Arms stay off the main bar, Arms lives in Defence, and both stocks show in the turn report and Why.+ [TestCase(false)] [TestCase(true)]+ public void OwnerRulingKeepsTheMainBarMeterSet(bool he)+ {+ var b = Bridge(false, he); var t = Text(he);+ using var ui = new UiTestKit();+ using var hud = new HudPresenter(ui.Root, b, t);+ CollectionAssert.AreEqual(new[] { "treasury", "immigration", "security", "support", "cohesion", "standing", "fx" }, HudModel.MeterIds);+ Assert.IsNull(ui.Root.Q("meter-food"));+ Assert.IsNull(ui.Root.Q("meter-arms"));+ }++ [TestCase(false)] [TestCase(true)]+ public void ArmsStockLivesInDefenceWithoutABarDuplicate(bool he)+ {+ var b = Bridge(false, he); var t = Text(he);+ using var ui = new UiTestKit();+ using var defence = new DefencePresenter(ui.Root, b, t);+ var stock = ui.Q<Label>("arms-stock");+ Assert.IsTrue(ui.Q<VisualElement>("defence-arms").Contains(stock));+ Assert.AreEqual(t.Format("arms.stock", b.State.Arms), stock.text);+ ui.Q<IntegerField>("arms-count").value = 3;+ ui.Press("buy-arms");+ Assert.AreEqual(t.Format("arms.stock", b.State.Arms), stock.text, "queueing does not spend or deliver stock");+ b.EndTurn();+ Assert.AreEqual(t.Format("arms.stock", b.State.Arms), stock.text, "Defence refreshes after the sim delivers");+ Assert.IsNull(ui.Root.Q("meter-arms"), "the owner moved this stock off the bar");+ }++ [TestCase(false)] [TestCase(true)]+ [SetCulture("he-IL")]+ public void ReportIncludesBothCurrentStocksEvenWhenArmsDidNotChange(bool he)+ {+ var b = Bridge(false, he); var t = Text(he);+ using var ui = new UiTestKit();+ using var nav = new ScreenNav(ui.Root);+ using var report = new TurnReportPresenter(ui.Root, b, t, nav);+ b.EndTurn();+ Assert.AreEqual(b.Session.Previous!.Arms, b.State.Arms, "no purchase in this fixture");+ foreach (var id in new[] { "food", "arms" })+ {+ var row = TurnReportPresenter.Lines(b, t).Single(x => x.Meter == id);+ var now = id == "food" ? b.State.Food : b.State.Arms;+ var before = id == "food" ? b.Session.Previous!.Food : b.Session.Previous!.Arms;+ AssertStockDirection(he, t, now, (long)now - before, row.Heading);+ Assert.AreEqual(row.Heading, ui.Q<Label>("turn-report-heading-" + id).text);+ }+ }++ [TestCase(false)] [TestCase(true)]+ [SetCulture("he-IL")]+ public void WhyIncludesBothStocksAndKeepsEveryExistingCause(bool he)+ {+ var b = Bridge(false, he); var t = Text(he);+ using var ui = new UiTestKit();+ using var why = new WhyPresenter(ui.Root, b, t);+ Assert.IsNotNull(ui.Root.Q<Label>("why-stock-food"));+ Assert.IsNotNull(ui.Root.Q<Label>("why-stock-arms"));+ b.Queue(new BuyArms(3)); b.EndTurn();+ foreach (var id in new[] { "food", "arms" })+ {+ var now = id == "food" ? b.State.Food : b.State.Arms;+ var before = id == "food" ? b.Session.Previous!.Food : b.Session.Previous!.Arms;+ AssertStockDirection(he, t, now, (long)now - before, ui.Q<Label>("why-stock-" + id).text);+ }+ var actual = ui.Q<ScrollView>("why-rows").Query<Label>(className: "why-line").ToList().Select(l => l.text).ToArray();+ var expected = WhyPresenter.Order.SelectMany(sys => b.Session.Last!.Why.Where(w => w.System == sys))+ .Select(w => CauseText.Line(w, b.Content, Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), t)).ToArray();+ CollectionAssert.AreEqual(expected, actual);+ }++ // Literal expected output, independent of the translated summary patterns.+ [TestCase(false, 0, "")] [TestCase(true, 0, "")]+ [TestCase(false, -12, "-12")] [TestCase(true, -12, "-12")]+ [TestCase(false, 12, "+12")] [TestCase(true, 12, "+12")]+ [SetCulture("he-IL")]+ public void StockSummaryPatternsProtectHebrewNumbersAndLeaveEnglishUnchanged(bool he, int delta, string signed)+ {+ var t = Text(he);+ foreach (var id in new[] { "food", "arms" })+ {+ var caption = t["hud.caption." + id];+ var count = t.Format("hud.stock", 1200);+ var actual = delta == 0+ ? t.Format("report.stock_line", caption, count)+ : t.Format("report.stock_change", caption, count, t.Format("hud.delta_stock", delta));+ var expected = he ? caption + " במלאי: \u200e1,200\u200e" : caption + ": 1,200";+ if (delta != 0) expected += he ? " (שינוי של \u200e" + signed + "\u200e)" : " (" + signed + ")";+ Assert.AreEqual(expected, actual, id);+ }+ }++ // Ordinal on purpose: StringAssert compares by culture, which ignores U+200E, so it can neither see nor rule out the marks.+ static void AssertStockDirection(bool he, UiText t, int now, long delta, string heading)+ {+ var count = t.Format("hud.stock", now);+ var want = he ? "\u200e" + count + "\u200e" : count;+ Assert.IsTrue(heading.IndexOf(want, StringComparison.Ordinal) >= 0, $"'{want}' in '{heading}'");+ if (delta != 0)+ {+ var signed = t.Format("hud.delta_stock", delta);+ var wantSigned = he ? "\u200e" + signed + "\u200e" : signed;+ Assert.IsTrue(heading.IndexOf(wantSigned, StringComparison.Ordinal) >= 0, $"'{wantSigned}' in '{heading}'");+ }+ if (!he) Assert.AreEqual(-1, heading.IndexOf('\u200e'), "English headings carry no direction marks: " + heading);+ }++ [TestCase(false, false)] [TestCase(false, true)]+ [TestCase(true, false)] [TestCase(true, true)]+ public void StocksChangeOnlyAtEndTurnAndTheReportUsesSimCauses(bool modern, bool he)+ {+ var b = Bridge(modern, he); var t = Text(he);+ var start = b.State.Arms;+ using var ui = new UiTestKit();+ using var hud = new HudPresenter(ui.Root, b, t);+ using var defence = new DefencePresenter(ui.Root, b, t);+ Assert.IsNull(ui.Root.Q("meter-food"));+ Assert.IsNull(ui.Root.Q("meter-arms"));+ Assert.AreEqual(t.Format("arms.stock", start), ui.Q<Label>("arms-stock").text);+ ui.Q<IntegerField>("arms-count").value = 3;+ Assert.AreEqual(t.Format("arms.money", PlayerText.Money(b.Content, "treasury", 3 * b.Content.RulesAt(b.State.Date).Mvp!.ArmsPrice!.Value)),+ ui.Q<Label>("arms-money").text);+ ui.Press("buy-arms");+ Assert.AreEqual(start, b.State.Arms);+ Assert.AreEqual(3, ((BuyArms)b.Queued.Single()).Count);+ Assert.AreEqual(t.Format("arms.queued", 3), ui.Q<Label>("arms-queued").text);+ b.EndTurn();+ Assert.IsEmpty(b.Queued);+ Assert.AreEqual(start + 3, b.State.Arms);+ Assert.AreEqual(t.Format("arms.stock", start + 3), ui.Q<Label>("arms-stock").text);+ Assert.IsEmpty(ui.Q<Label>("arms-queued").text);+ var expected = b.Session.Last!.Why.Where(w => w.Target == Pools.ArmsTarget && w.Delta != 0)+ .OrderByDescending(w => Math.Abs(w.Delta)).Take(HudModel.MaxCauses).Select(w => w.Message).ToArray();+ CollectionAssert.AreEqual(expected, TurnReportPresenter.StockCauses(b.Session.Last, "arms", w => w.Message));+ Assert.IsNotEmpty(expected);+ Assert.IsTrue(TurnReportPresenter.Lines(b, t).Any(x => x.Meter == "arms"));+ StringAssert.Contains(t.Format("hud.stock", start + 3), TurnReportPresenter.Lines(b, t).Single(x => x.Meter == "arms").Heading);+ }++ [TestCase(false, false)] [TestCase(false, true)]+ [TestCase(true, false)] [TestCase(true, true)]+ public void ReplaceWithdrawAndRefuseWithoutChangingStocks(bool modern, bool he)+ {+ var b = Bridge(modern, he); var t = Text(he);+ using var ui = new UiTestKit();+ using var defence = new DefencePresenter(ui.Root, b, t);+ var before = b.State.Hash();+ var count = ui.Q<IntegerField>("arms-count");+ count.value = 2; ui.Press("buy-arms");+ count.value = 5; ui.Press("buy-arms");+ Assert.AreEqual(5, ((BuyArms)b.Queued.Single()).Count);+ Assert.AreEqual(before, b.State.Hash());+ if (!modern)+ Assert.AreEqual(b.TurnStart.Attention - b.Price(new BuyArms(5))!.Value, b.AttentionLeft!.Value, 1e-9);+ else+ {+ Assert.IsNull(b.Price(new BuyArms(5)));+ Assert.IsNull(b.AttentionLeft);+ Assert.AreEqual(DisplayStyle.None, ui.Q<Label>("arms-attention").style.display.value);+ Assert.IsEmpty(ui.Q<Label>("arms-attention").text);+ }+ ui.Press("withdraw-arms");+ Assert.IsEmpty(b.Queued);+ Assert.AreEqual(before, b.State.Hash());+ count.value = 0;+ Assert.IsFalse(ui.Q<Button>("buy-arms").enabledSelf);+ Assert.AreEqual(t["arms.minimum"], ui.Q<Label>("arms-refusal").text);+ count.value = 2;+ if (!modern)+ {+ b.State.Attention = 0;+ count.value = 3; // refresh the actual control+ string? refused = null; b.Refused += reason => refused = reason;+ Assert.IsTrue(ui.Q<Button>("buy-arms").enabledSelf, "a refusal remains explainable");+ ui.Press("buy-arms");+ Assert.IsNotNull(refused);+ Assert.AreEqual(refused, ui.Q<Label>("arms-refusal").text);+ Assert.IsEmpty(b.Queued);+ }+ b.State.GameOver = "finished";+ count.value = 4;+ Assert.IsFalse(ui.Q<Button>("buy-arms").enabledSelf);+ Assert.IsFalse(ui.Q<Button>("withdraw-arms").enabledSelf);+ Assert.AreEqual(t["order.game_over"], ui.Q<Label>("arms-refusal").text);+ }++ [Test]+ public void PoolCausesIgnoreTheSupplyIndicatorAndKeepTheSimTieOrder()+ {+ var b = Bridge(false, false);+ var turn = new StepResult(b.State, new[]+ {+ new Cause("economy", "food_supply", 1000, "indicator"),+ new Cause("economy", "food", -10, "food first"),+ new Cause("events", "food", 10, "food tied"),+ new Cause("economy", "food", 1, "food smaller"),+ new Cause("events", "arms", 3, "arms"),+ }, Array.Empty<Rejection>());+ CollectionAssert.AreEqual(new[] { "Food first", "Food tied" }, TurnReportPresenter.StockCauses(turn, "food", w => w.Message));+ CollectionAssert.AreEqual(new[] { "Arms" }, TurnReportPresenter.StockCauses(turn, "arms", w => w.Message));+ }++ [Test]+ public void LegacyLoopHidesThePoolsAndPurchasePanel()+ {+ var t = Text(false);+ var b = new SimBridge(GameSession.New(SimBridgeGddTests.LoadLegacy(), GoldenRun.Seed, Mode.Historical), t);+ using var ui = new UiTestKit();+ using var hud = new HudPresenter(ui.Root, b, t);+ using var defence = new DefencePresenter(ui.Root, b, t);+ Assert.IsNull(ui.Root.Q("meter-food"));+ Assert.IsNull(ui.Root.Q("meter-arms"));+ Assert.IsEmpty(TurnReportPresenter.StockLines(b, t));+ Assert.AreEqual(DisplayStyle.None, ui.Q<VisualElement>("defence-arms").style.display.value);+ }++ [TestCase(false)] [TestCase(true)]+ public void RebuildingTheScreenKeepsTheQueuedAmountAndDisposalRemovesHandlers(bool he)+ {+ var b = Bridge(false, he); var t = Text(he);+ Assert.IsNull(b.Queue(new BuyArms(9)));+ using var ui = new UiTestKit();+ var presenter = new ArmsPurchasePresenter(ui.Root, b, t);+ Assert.AreEqual(9, ui.Q<IntegerField>("arms-count").value);+ presenter.Dispose();+ ui.Press("withdraw-arms");+ Assert.AreEqual(9, ((BuyArms)b.Queued.Single()).Count);+ using var next = new ArmsPurchasePresenter(ui.Root, b, t);+ ui.Press("withdraw-arms");+ Assert.IsEmpty(b.Queued);+ }++ // Real panels at desktop, laptop and phone sizes; EN and mirrored HE. No screenshot is claimed by this test draft.+ [UnityTest]+ public IEnumerator RestoredBarFitsInEnglishAndHebrew()+ {+ foreach (var he in new[] { false, true })+ foreach (var size in new[] { new Vector2Int(1920, 1080), new Vector2Int(1280, 720), new Vector2Int(375, 667) })+ {+ var rt = new RenderTexture(size.x, size.y, 0);+ var settings = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));+ settings.targetTexture = rt;+ var go = new GameObject("FoodArmsLayout"); go.SetActive(false);+ var doc = go.AddComponent<UIDocument>(); doc.panelSettings = settings;+ doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);+ go.SetActive(true);+ var root = doc.rootVisualElement;+ HudPresenter? hud = null;+ try+ {+ if (he) root.Q("root").AddToClassList(UiLanguage.HebrewClass);+ for (int i = 0; i < 20; i++) yield return null;+ root.Q("root").RemoveFromClassList("loading");+ var b = Bridge(false, he); var t = Text(he);+ b.EndTurn();+ b.State.Food = 123456; b.State.Arms = 12345;+ hud = new HudPresenter(root, b, t);+ for (int i = 0; i < 20; i++) yield return null;+ var bar = root.Q("top-bar").worldBound;+ Assert.IsNull(root.Q("meter-food"));+ Assert.IsNull(root.Q("meter-arms"));+ var visible = root.Q("meters").Children().Where(x => x.resolvedStyle.display != DisplayStyle.None).ToList();+ for (int i = 0; i < visible.Count; i++)+ for (int j = i + 1; j < visible.Count; j++)+ {+ // As TopBarTests: shared snapped edges may differ by a subpixel, ink must stay disjoint.+ static Rect In(Rect r) => new Rect(r.x + .5f, r.y + .5f, r.width - 1, r.height - 1);+ Assert.IsFalse(In(visible[i].worldBound).Overlaps(In(visible[j].worldBound)),+ FormattableString.Invariant($"{size.x}x{size.y} he={he}: {visible[i].name} {visible[i].worldBound} overlaps {visible[j].name} {visible[j].worldBound}"));+ }+ }+ finally+ {+ hud?.Dispose(); Object.DestroyImmediate(go); Object.DestroyImmediate(settings);+ rt.Release(); Object.DestroyImmediate(rt);+ }+ }+ }+}diff --git a/unity/Assets/Tests/EditMode/FoodArmsHudTests.cs.meta b/unity/Assets/Tests/EditMode/FoodArmsHudTests.cs.metanew file mode 100644index 000000000..ae4a68708--- /dev/null+++ b/unity/Assets/Tests/EditMode/FoodArmsHudTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 4e5d8ccdf25e472ab789e9d220c22aaadiff --git a/unity/Assets/Tests/EditMode/FoodArmsReviewTests.cs b/unity/Assets/Tests/EditMode/FoodArmsReviewTests.csnew file mode 100644index 000000000..c4e929da1--- /dev/null+++ b/unity/Assets/Tests/EditMode/FoodArmsReviewTests.cs@@ -0,0 +1,251 @@+#nullable enable+using System;+using System.Collections;+using System.Globalization;+using System.IO;+using System.Linq;+using System.Reflection;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++public class FoodArmsReviewTests+{+ static UiText Text(bool he) => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(he ? UiPaths.StringsHebrew : UiPaths.Strings).text);+ static SimBridge Bridge(bool he, bool modern = false, bool legacy = false)+ {+ Content c;+ if (legacy) c = SimBridgeGddTests.LoadLegacy();+ else if (!modern) c = ContentLoader.Load(Paths.Content);+ else+ {+ c = ContentLoader.Load(rel =>+ {+ var path = Path.Combine(Paths.Content, rel);+ return !File.Exists(path) ? null : rel == "eras.yaml"+ ? File.ReadAllText(path).Replace("loop: gdd", "loop: gdd, ruleset: gdd-0.3") : File.ReadAllText(path);+ }, Directory.GetFiles(Path.Combine(Paths.Content, "events"), "*.yaml").Select(x => "events/" + Path.GetFileName(x)));+ }+ return new SimBridge(GameSession.New(c, GoldenRun.Seed, Mode.Historical), Text(he));+ }++ // S2: mutate only the PRE-turn fixture, never manufacture a delta after the sim has run.+ [TestCase(false, false)] [TestCase(true, false)]+ [TestCase(false, true)] [TestCase(true, true)]+ public void RealFoodChangeExplainsTheActualStockInReportAndWhy(bool he, bool crisis)+ {+ var b = Bridge(he); var t = Text(he);+ if (crisis) { b.State.ActiveSituations.Add(EconomySystem.FxCrisis); b.State.FxReserves = -100; }+ else b.State.Food += 7; // cover plus seven: normal consumption/top-up, no unmet-need cause; delta is real.+ int before = b.State.Food;+ using var ui = new UiTestKit();+ using var hud = new HudPresenter(ui.Root, b, t);+ using var nav = new ScreenNav(ui.Root);+ using var report = new TurnReportPresenter(ui.Root, b, t, nav);+ b.EndTurn();+ Assert.IsNotNull(b.Session.Last);+ Assert.AreNotEqual(before, b.State.Food, "a real consumption/import delta is required");+ long delta = (long)b.State.Food - before;+ var expected = b.Session.Last!.Why.Where(w => w.Target == Pools.FoodTarget && w.Delta != 0)+ .OrderByDescending(w => Math.Abs(w.Delta)).Take(HudModel.MaxCauses)+ .Select(w => CauseText.Line(w, b.Content, Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), t)).ToArray();+ if (crisis) { Assert.IsNotEmpty(expected); StringAssert.Contains("No Food imported", b.Session.Last.Why.Single(w => w.Target == Pools.FoodTarget && w.Message.Contains("No Food imported")).Message); }+ else Assert.IsEmpty(expected, "do not invent causes for normal automatic imports");+ using var why = new WhyPresenter(ui.Root, b, t);+ StringAssert.Contains(t.Format("hud.stock", b.State.Food), ui.Q<Label>("why-stock-food").text);+ var row = TurnReportPresenter.Lines(b, t).Single(x => x.Meter == "food");+ CollectionAssert.AreEqual(expected, row.Causes);+ Assert.AreEqual(t.Format("report.stock_change", t["hud.caption.food"], t.Format("hud.stock", b.State.Food), t.Format("hud.delta_stock", delta)), row.Heading);+ Assert.AreEqual(row.Heading, ui.Q<Label>("turn-report-heading-food").text);+ CollectionAssert.AreEqual(expected, ui.Q<VisualElement>("turn-report-food").Query<Label>(className: "turn-report-cause").ToList().Select(x => x.text));+ }++ static IEnumerator Frames(int n = 15) { for (int i = 0; i < n; i++) yield return null; }+ static string Inv(FormattableString value) => FormattableString.Invariant(value);+ static void Snapshot(RenderTexture rt, string name)+ {+ var dir = Environment.GetEnvironmentVariable("FOOD_ARMS_CAPTURE_DIR");+ if (string.IsNullOrEmpty(dir)) return;+ Directory.CreateDirectory(dir);+ var prior = RenderTexture.active;+ var image = new Texture2D(rt.width, rt.height, TextureFormat.RGB24, false);+ try { RenderTexture.active = rt; image.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0); image.Apply(); File.WriteAllBytes(Path.Combine(dir, name + ".png"), image.EncodeToPNG()); }+ finally { RenderTexture.active = prior; Object.DestroyImmediate(image); }+ }+ static IEnumerator Panel(int width, int height, bool he, Func<VisualElement, RenderTexture, IEnumerator> check)+ {+ var rt = new RenderTexture(width, height, 0); rt.Create();+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel)); ps.targetTexture = rt; ps.clearColor = true; ps.colorClearValue = Color.black;+ var go = new GameObject("FoodArmsReview"); go.SetActive(false);+ var doc = go.AddComponent<UIDocument>(); doc.panelSettings = ps;+ doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml); go.SetActive(true);+ try+ {+ var root = doc.rootVisualElement;+ if (he) root.Q("root").AddToClassList(UiLanguage.HebrewClass);+ root.Q("root").RemoveFromClassList("loading");+ yield return Frames(); yield return check(root, rt);+ }+ finally { Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt); }+ }++ // S1: original arithmetic, including hidden cohesion, copied from the task's fresh main FloorGrowth.+ // No general hidden-caption filter is allowed.+ [UnityTest]+ public IEnumerator LegacyRaisedFontKeepsTheOriginalGrowthAndTierBoundaries()+ {+ foreach (bool he in new[] { false, true })+ foreach (var size in new[] { (1024,768), (960,600), (800,600), (1280,720), (375,667) })+ yield return Panel(size.Item1, size.Item2, he, Check);+ IEnumerator Check(VisualElement root, RenderTexture rt)+ {+ var b = Bridge(root.Q("root").ClassListContains(UiLanguage.HebrewClass), legacy:true);+ var t = Text(root.Q("root").ClassListContains(UiLanguage.HebrewClass));+ using var hud = new HudPresenter(root,b,t);+ yield return Frames(25);+ var flags = BindingFlags.Instance | BindingFlags.NonPublic;+ float small = (float)typeof(HudPresenter).GetField("smallTextSize", flags)!.GetValue(hud)!;+ Assert.Greater(small, HudPresenter.SmallTextPx, "fixture must exercise raised-font arithmetic");+ float turnWidth = (float)typeof(HudPresenter).GetProperty("TurnBoxWidth", flags)!.GetValue(hud)!;+ float plateWidth = (float)typeof(HudPresenter).GetMethod("RaisedPlateWidth", flags)!.Invoke(hud,null)!;+ float expected = turnWidth - 150f + plateWidth - 230f;+ var captions = (System.Collections.Generic.List<Label>)typeof(HudPresenter).GetField("smallText", flags)!.GetValue(hud)!;+ var cohesion = captions.Single(x => root.Q("meter-cohesion").Contains(x));+ Assert.Greater(cohesion.resolvedStyle.fontSize,0,"exercise original hidden-cohesion measurement");+ foreach (var l in captions)+ {+ if (l.name == "attention" || string.IsNullOrEmpty(l.text)) continue;+ var current = l.resolvedStyle.fontSize; if (!(current>0)) continue;+ var oneLine = l.MeasureTextSize(l.text,0,VisualElement.MeasureMode.Undefined,0,VisualElement.MeasureMode.Undefined).x;+ expected += oneLine * small/current - Mathf.Min(oneLine*15f/current,120f);+ }+ expected = Mathf.Max(0,expected);+ float actual = (float)typeof(HudPresenter).GetMethod("FloorGrowth",flags)!.Invoke(hud,null)!;+ Assert.AreEqual(expected,actual,.01f,"legacy must retain the exact original hidden-cohesion growth term");+ var bar=root.Q("top-bar"); var frame=root.Q("root"); float width=bar.layout.width;+ Assert.AreEqual(width-expected<HudPresenter.CompactBelowPx,bar.ClassListContains(HudPresenter.CompactClass));+ Assert.AreEqual(width-expected<HudPresenter.NarrowBelowPx || b.Content.UsesAttention && small>HudPresenter.OneRowSmallMaxPx,frame.ClassListContains(HudPresenter.NarrowClass));+ Snapshot(rt,Inv($"legacy-{(t.Has("arms.count")?"candidate":"base")}-{(UiDirection.HasRightToLeft(t["hud.caption.treasury"])?"he":"en")}-{rt.width}x{rt.height}"));+ }+ }++ static void Reach(VisualElement root, ScrollView scroll, VisualElement e)+ {+ var viewport=scroll.contentViewport.worldBound; var bounds=e.worldBound;+ Assert.Greater(bounds.width,4,e.name); Assert.Greater(bounds.height,4,e.name);+ Assert.GreaterOrEqual(bounds.xMin,viewport.xMin-1,e.name); Assert.LessOrEqual(bounds.xMax,viewport.xMax+1,e.name);+ Assert.GreaterOrEqual(bounds.yMin,viewport.yMin-1,e.name); Assert.LessOrEqual(bounds.yMax,viewport.yMax+1,e.name);+ Assert.IsTrue(e.enabledInHierarchy,e.name);+ if (e is Button || e is IntegerField)+ {+ var picked = root.panel.Pick(bounds.center);+ Assert.IsTrue(picked == e || e.Contains(picked), e.name + " must receive a pointer at its visible centre");+ }+ }++ [UnityTest]+ public IEnumerator PurchaseControlsAreReachableWithKeyboardInEnglishAndHebrew()+ {+ foreach(bool he in new[]{false,true})+ foreach(var size in new[]{(1920,1080),(1280,720),(375,667)})+ yield return Panel(size.Item1,size.Item2,he,Check);+ IEnumerator Check(VisualElement root,RenderTexture rt)+ {+ bool he=root.Q("root").ClassListContains(UiLanguage.HebrewClass);+ // Modern and gdd-0.1 run separately, without changing production rules or Attention helpers.+ foreach(bool modern in new[]{false,true})+ {+ var b=Bridge(he,modern); var t=Text(he);+ using var hud=new HudPresenter(root,b,t); using var nav=new ScreenNav(root); using var defence=new DefencePresenter(root,b,t);+ UiTestKit.Press(root.Q<Button>("nav-defence")); yield return Frames();+ Assert.IsTrue(ScreenNav.IsOpen(root.Q("screen-defence")));+ var scroll=root.Q<ScrollView>("defence-body"); var count=root.Q<IntegerField>("arms-count");+ var buy=root.Q<Button>("buy-arms"); var withdraw=root.Q<Button>("withdraw-arms");+ var input = count.Q(className: "unity-base-field__input");+ Assert.IsNotNull(input);+ var ink = input.resolvedStyle.color; var paper = input.resolvedStyle.backgroundColor;+ Assert.Greater(Mathf.Abs(ink.grayscale - paper.grayscale), .5f, "amount text must contrast with its input background");+ foreach(var amount in new[]{2,5})+ {+ scroll.ScrollTo(count); yield return Frames(4); Reach(root,scroll,count);+ count.Focus(); yield return null;+ Assert.IsTrue(count.Contains(root.panel.focusController.focusedElement as VisualElement) || root.panel.focusController.focusedElement==count);+ count.value=amount;+ scroll.ScrollTo(buy); yield return Frames(4); Reach(root,scroll,buy);+ buy.Focus(); yield return null; Assert.AreEqual(buy,root.panel.focusController.focusedElement);+ UiTestKit.Press(buy); Assert.AreEqual(amount,((BuyArms)b.Queued.Single()).Count);+ Assert.AreEqual(t.Format("arms.queued",amount),root.Q<Label>("arms-queued").text);+ }+ scroll.ScrollTo(withdraw); yield return Frames(4); Reach(root,scroll,withdraw);+ withdraw.Focus(); yield return null; Assert.AreEqual(withdraw,root.panel.focusController.focusedElement);+ UiTestKit.Press(withdraw); Assert.IsEmpty(b.Queued);+ if(!modern)+ {+ b.State.Attention=0; count.value=3; scroll.ScrollTo(buy); yield return Frames(4);+ UiTestKit.Press(buy); Assert.IsEmpty(b.Queued); Assert.IsNotEmpty(root.Q<Label>("arms-refusal").text);+ }+ else { Assert.AreEqual(DisplayStyle.None,root.Q("arms-attention").resolvedStyle.display); Assert.IsEmpty(root.Q<Label>("arms-attention").text); }+ foreach(var name in new[]{"arms-money","arms-queued","arms-refusal"})+ {+ var l=root.Q<Label>(name); if(string.IsNullOrEmpty(l.text))continue;+ scroll.ScrollTo(l); yield return Frames(4); Reach(root,scroll,l);+ var needed=l.MeasureTextSize(l.text,l.contentRect.width,VisualElement.MeasureMode.Exactly,0,VisualElement.MeasureMode.Undefined);+ Assert.LessOrEqual(needed.y,l.contentRect.height+1,name+" must wrap without clipping");+ }+ Snapshot(rt,Inv($"purchase-{(he?"he":"en")}-{(modern?"gdd03":"gdd01")}-{rt.width}x{rt.height}"));+ nav.Open(null); yield return Frames(3);+ }+ }+ }++ // REV2 S1: Withdraw disables itself once the order is gone. Pressed from the keyboard, the focus must move to an+ // enabled purchase control, not be left nowhere, so Tab and Shift+Tab carry on from the purchase panel.+ [UnityTest]+ public IEnumerator KeyboardWithdrawKeepsTheFocusInThePurchasePanel()+ {+ foreach(bool he in new[]{false,true})+ yield return Panel(1280,720,he,Check);+ IEnumerator Check(VisualElement root,RenderTexture rt)+ {+ bool he=root.Q("root").ClassListContains(UiLanguage.HebrewClass);+ var b=Bridge(he); var t=Text(he);+ using var hud=new HudPresenter(root,b,t); using var nav=new ScreenNav(root); using var defence=new DefencePresenter(root,b,t);+ nav.Open("defence"); yield return Frames();+ var fc=root.panel.focusController; var arms=root.Q("defence-arms");+ var count=root.Q<IntegerField>("arms-count"); var buy=root.Q<Button>("buy-arms"); var withdraw=root.Q<Button>("withdraw-arms");+ count.value=2; UiTestKit.Press(buy); Assert.AreEqual(2,((BuyArms)b.Queued.Single()).Count, "precondition: one order queued");+ yield return null; Assert.IsTrue(withdraw.enabledSelf, "precondition: Withdraw is enabled while an order is queued");+ withdraw.Focus(); yield return null; Assert.AreEqual(withdraw,fc.focusedElement, "precondition: Withdraw has the focus");+ using (var k=KeyDownEvent.GetPooled('\n',KeyCode.Return,EventModifiers.None)) { k.target=withdraw; withdraw.SendEvent(k); }+ using (var s=NavigationSubmitEvent.GetPooled()) { s.target=withdraw; withdraw.SendEvent(s); }+ yield return Frames(3);+ Assert.IsEmpty(b.Queued); Assert.IsFalse(withdraw.enabledSelf, "Withdraw disables itself with nothing queued");+ var at=fc.focusedElement as VisualElement;+ Assert.IsNotNull(at, "the keyboard focus must not be dropped");+ Assert.AreEqual(buy,at, "the focus moves to Buy, the enabled control beside Withdraw");+ Assert.IsTrue(at!.enabledInHierarchy && arms.Contains(at));+ using (var e=NavigationMoveEvent.GetPooled(NavigationMoveEvent.Direction.Previous)) { e.target=at; at.SendEvent(e); }+ yield return null;+ var back=fc.focusedElement as VisualElement;+ Assert.IsTrue(back!=null && (back==count || count.Contains(back)), "Shift+Tab from Buy goes back to the amount: " + back?.name);+ using (var e=NavigationMoveEvent.GetPooled(NavigationMoveEvent.Direction.Next)) { e.target=back; back!.SendEvent(e); }+ yield return null;+ Assert.AreEqual(buy,fc.focusedElement, "Tab from the amount comes back to Buy");+ using (var e=NavigationMoveEvent.GetPooled(NavigationMoveEvent.Direction.Next)) { e.target=buy; buy.SendEvent(e); }+ yield return null;+ var next=fc.focusedElement as VisualElement;+ Assert.IsTrue(next!=null && next!=withdraw && next.enabledInHierarchy, "Tab from Buy skips the disabled Withdraw: " + next?.name);+ // A pointer press moves no focus (PressSource / PointerBlur policy), so a mouse Withdraw hands none out.+ UiTestKit.Press(buy); Assert.IsNotEmpty(b.Queued); yield return null;+ DecisionCardTests.PressWithPointer(withdraw); yield return Frames(3);+ Assert.IsEmpty(b.Queued); Assert.AreNotEqual(buy, fc.focusedElement, "a pointer Withdraw hands Buy no focus");+ nav.Open(null); yield return Frames(3);+ }+ }+}diff --git a/unity/Assets/Tests/EditMode/FoodArmsReviewTests.cs.meta b/unity/Assets/Tests/EditMode/FoodArmsReviewTests.cs.metanew file mode 100644index 000000000..12e2d0241--- /dev/null+++ b/unity/Assets/Tests/EditMode/FoodArmsReviewTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 8c78285bf58d47dd8ad4bce43d120e2ddiff --git a/unity/Assets/Tests/EditMode/PromoScreensTests.cs b/unity/Assets/Tests/EditMode/PromoScreensTests.csindex 234cbd555..8e3409a8a 100644--- a/unity/Assets/Tests/EditMode/PromoScreensTests.cs+++ b/unity/Assets/Tests/EditMode/PromoScreensTests.cs@@ -472,13 +472,34 @@ public class PromoScreensTeststexts["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";+ // #731: the Arms panel (GDD loop only): the sim's stock, and the price of the amount field's opening 1 at the+ // era's arms price (Pools.BuyArms), with its Attention cost and what is left when the era spends Attention.+ if (C.IsGdd)+ {+ var one = new BuyArms(1);+ texts["arms-stock"] = Text.Format("arms.stock", s.Arms);+ // The amount field opens at 1 (Game.uxml) unless a BuyArms is queued; these dates have none.+ Assert.IsNull(bridge.QueuedLike(one), $"{where}: precondition: no Arms purchase is queued");+ texts["arms-count"] = "1";+ texts["arms-money"] = Text.Format("arms.money", PlayerText.Money(C, "treasury", C.RulesAt(s.Date).Mvp!.ArmsPrice!.Value));+ texts["arms-attention"] = C.UsesAttention ? Text.Format("arms.attention", bridge.Price(one)!.Value, bridge.AttentionLeft!.Value) : "";+ // Require the named figures, even if a missing/blank control would evade the digit inventory.+ Assert.AreEqual(texts["arms-stock"], ui.Q<Label>("arms-stock").text);+ Assert.AreEqual(texts["arms-money"], ui.Q<Label>("arms-money").text);+ Assert.AreEqual(1, ui.Q<IntegerField>("arms-count").value);+ Assert.AreEqual(texts["arms-attention"], ui.Q<Label>("arms-attention").text);+ Assert.AreEqual(C.UsesAttention ? DisplayStyle.Flex : DisplayStyle.None,+ ui.Q<Label>("arms-attention").style.display.value);+ }bars["mob-bar"] = (float)callUp; bars["defence-budget-bar"] = (float)s.Budget[DefencePresenter.BudgetLine];foreach (var name in new[] { "screen-cabinet", "screen-defence" }){foreach (var t in ui.Q<VisualElement>(name).Query<TextElement>().ToList().Where(t => t.text.Any(char.IsDigit))){- Assert.IsTrue(texts.ContainsKey(t.name), $"{where}: '{t.text}' in {t.name} is a figure no test binds to the sim");- Assert.AreEqual(texts[t.name], t.text, $"{where}: {t.name}");+ // A text field's digits are drawn by an unnamed TextElement inside it: bind them by the field's own name.+ var key = t.name.Length == 0 && t.GetFirstAncestorOfType<IntegerField>() is IntegerField field ? field.name : t.name;+ Assert.IsTrue(texts.ContainsKey(key), $"{where}: '{t.text}' in {key} is a figure no test binds to the sim");+ Assert.AreEqual(texts[key], t.text, $"{where}: {key}");}foreach (var bar in ui.Q<VisualElement>(name).Query<UiBar>().ToList().Where(b => b.resolvedStyle.display != DisplayStyle.None && b.parent.style.display != DisplayStyle.None)){diff --git a/unity/Assets/Tests/EditMode/ScreenEntryTests.cs b/unity/Assets/Tests/EditMode/ScreenEntryTests.csindex 075b19a08..963070a4e 100644--- a/unity/Assets/Tests/EditMode/ScreenEntryTests.cs+++ b/unity/Assets/Tests/EditMode/ScreenEntryTests.cs@@ -92,6 +92,8 @@ public class ScreenEntryTests[UnityTest][TestCase("cabinet", "seat-prime_minister", ExpectedResult = null)][TestCase("budget", "budget-defense_minister-down", ExpectedResult = null)]+ // #731: Defence's Arms purchase gives it a control of its own at the opening turn, the amount to buy.+ [TestCase("defence", "arms-count", ExpectedResult = null)]public IEnumerator OpeningAScreenFromTheKeyboardPutsTheFocusOnItsFirstControl(string screen, string expected){yield return Boot();@@ -107,28 +109,27 @@ public class ScreenEntryTestsAssert.AreNotEqual("screen-close-" + screen, FocusedName, "not the close X");}- /// <summary>Defence is the other case: at the opening turn it has no control of its own that can take the focus- /// (its ladder and call-up buttons are in the tree but not usable yet, and its scroll bar is no use from the- /// keyboard, #41 K3), so the screen's own X takes it. That is still better than leaving the focus on the rail- /// outside the screen the player just opened. The precondition is checked rather than assumed, so if Defence later- /// gains a usable control (#755 adds the call-up) this test says so instead of quietly passing.</summary>+ /// <summary>The other case: a screen with no control of its own that can take the focus. Defence was this case until+ /// #731 gave it the Arms purchase (its amount field now takes the focus, the case above); Objectives is it at the+ /// opening turn (its objectives-rows hold no control), so the screen's own X takes the focus. That is still better than leaving the+ /// focus on the rail outside the screen the player just opened. The precondition is checked rather than assumed, so+ /// if Objectives later gains a usable control this test says so instead of quietly passing.</summary>[UnityTest]public IEnumerator AScreenWithNoUsableControlOfItsOwnTakesItsCloseButton(){yield return Boot();- yield return OpenFromTheRail("defence");+ yield return OpenFromTheRail("objectives");- var panel = ui.Q<VisualElement>("screen-defence");- var x = ui.Q<Button>("screen-close-defence");- // Measured at the opening turn: de-escalate, escalate, mob-down and mob-up are all display:none, and the- // defence-body scroll bar is no use from the keyboard, so nothing in the screen but the X can hold the focus.+ var panel = ui.Q<VisualElement>("screen-objectives");+ var x = ui.Q<Button>("screen-close-objectives");+ // A scroll bar is no use from the keyboard (#41 K3), so nothing in the screen but the X can hold the focus.var usable = panel.Query<VisualElement>().Build().Where(e => e != panel && e != x && FocusReturn.CanTakeFocus(e)&& !(e is Scroller) && e.GetFirstAncestorOfType<Scroller>() == null).ToList();- Assert.IsEmpty(usable, $"precondition: Defence has no control of its own that can take the focus at the opening turn");+ Assert.IsEmpty(usable, $"precondition: Objectives has no control of its own that can take the focus at the opening turn");Assert.IsTrue(panel.Contains(At), $"the focus should be inside the screen, but it is on {FocusedName}");- Assert.AreEqual("screen-close-defence", FocusedName, "and on its X, the only thing in it that can hold the focus");+ Assert.AreEqual("screen-close-objectives", FocusedName, "and on its X, the only thing in it that can hold the focus");}/// <summary>The pointer must not move the focus (PointerBlur's rule), as Close already respects.</summary>diff --git a/unity/Assets/Tests/EditMode/TurnReportTests.cs b/unity/Assets/Tests/EditMode/TurnReportTests.csindex 80f5f9adc..54df01ca4 100644--- a/unity/Assets/Tests/EditMode/TurnReportTests.cs+++ b/unity/Assets/Tests/EditMode/TurnReportTests.cs@@ -107,8 +107,8 @@ public class TurnReportTestsvar changed = HudModel.MeterIds.Where(id => m.For(id).Delta.Length > 0).ToArray();Assert.GreaterOrEqual(changed.Length, 3, "the opening turn moves at least three numbers in the bar");var rows = k.Ui.Q<ScrollView>("turn-report-rows").Children().ToList();- CollectionAssert.AreEqual(changed.Select(id => "turn-report-" + id).Append("turn-report-" + TurnReportPresenter.EnemyRow), rows.Select(r => r.name),- "every changed number, in the bar's order, and no other; then the enemy's orders (#1293)");+ CollectionAssert.AreEqual(changed.Select(id => "turn-report-" + id).Concat(new[] { "turn-report-food", "turn-report-arms" }).Append("turn-report-" + TurnReportPresenter.EnemyRow), rows.Select(r => r.name),+ "every changed bar number, then Food and Arms stocks, then enemy orders (#1293)");var messages = new HashSet<string>(turn.Why.Select(w => w.Message));foreach (var id in changed){diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex cd8ebfaa0..27b14f6c4 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -360,6 +360,20 @@<ui:Label name="defence-budget-share" class="budget-share" /><Statecraft.Game.UI.UiFrame shadow="false" /></ui:VisualElement>+ <ui:VisualElement name="defence-arms" class="defence-panel">+ <ui:Label name="arms-title" class="section-title" />+ <ui:Label name="arms-stock" class="wrap" />+ <ui:IntegerField name="arms-count" value="1" />+ <ui:Label name="arms-money" class="wrap" />+ <ui:Label name="arms-attention" class="wrap" />+ <ui:VisualElement class="row arms-actions">+ <ui:Button name="buy-arms" />+ <ui:Button name="withdraw-arms" />+ </ui:VisualElement>+ <ui:Label name="arms-queued" class="wrap" />+ <ui:Label name="arms-refusal" class="wrap" />+ <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" />diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex 82f114177..52404a5ad 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -1089,3 +1089,10 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas.info-primary-orders { flex-wrap: wrap; max-width: 100%; flex-shrink: 0; }/* Playtest B6: the city's name over its block on a hex that holds two cities (GddHexPanel.CityNameClass). */.city-part-name { -unity-font-style: bold; color: var(--gold-light); margin-top: 6px; }++/* #731: purchase controls remain inside Defence's scroll view; entered numbers must stay visible. */+.arms-actions { flex-wrap: wrap; }+#arms-count { min-width: 0; flex-shrink: 1; }+.lang-he #arms-count { flex-direction: row-reverse; }+#arms-count .unity-base-field__input { background-color: var(--navy-deep); color: var(--ink); border-width: 1px; border-color: var(--gold-dim); }+#arms-count:focus .unity-base-field__input { border-color: var(--gold); }diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 963d30cb0..46992f4bf 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -891,6 +891,24 @@ why.cause.objective_completed: "{0}: completed, {1} points"why.cause.prisoners_returned: "Prisoners exchanged: {0:N0} prisoners returned to {1}"why.cause.soldiers_returned: "Prisoners exchanged: {0:N0} of our soldiers came home from {1}"+hud.caption.food: "Food"+hud.caption.arms: "Arms"+hud.stock: "{0:N0}"+hud.delta_stock: "{0:+#,##0;-#,##0}"+arms.count: "Arms to buy"+arms.buy: "Buy Arms"+arms.withdraw: "Withdraw purchase"+arms.stock: "Arms in stock: {0:N0}"+arms.money: "Money cost: {0}"+arms.attention: "Attention cost: {0:0.0} · Left: {1:0.0}"+arms.queued: "Arms ordered: {0:N0}, at End turn"+arms.minimum: "Buy at least 1 Arms. Enter a larger amount."+arms.no_attention: "Not enough Attention for this purchase. Withdraw another order or wait until next turn."++# #731 stock summaries in the report and Why.+report.stock_line: "{0}: {1}"+report.stock_change: "{0}: {1} ({2})"+# #1708 artillery action status. Hebrew: native review pending (#564).unit.artillery_move_missing: "Artillery cannot move yet: its movement points have not been set"unit.fire_ready: "Fire available"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 44cae8049..2817ed559 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -990,6 +990,27 @@ why.cause.prisoners_returned: "חילופי שבויים: {0:N0} שבויים ה# C166: agent-drafted Hebrew; native review: owner, in chat on 25 Oct 2026 (approved as drafted, C155 HE-V031.md row 33).why.cause.soldiers_returned: "חילופי שבויים: {0:N0} מחיילינו חזרו הביתה מידי {1}"+# Agent-drafted Hebrew; native-review-pending (#564).+hud.caption.food: "מזון"+hud.caption.arms: "נשק"+hud.stock: "{0:N0}"+hud.delta_stock: "{0:+#,##0;-#,##0}"+arms.count: "כמות נשק לרכישה"+arms.buy: "רכישת נשק"+arms.withdraw: "ביטול הרכישה"+arms.stock: "נשק במלאי: {0:N0}"+arms.money: "עלות בכסף: {0}"+arms.attention: "עלות תשומת לב: {0:0.0} · נותר: {1:0.0}"+arms.queued: "נשק שהוזמן: {0:N0}, בסיום התור"+arms.minimum: "יש לרכוש לפחות יחידת נשק אחת. יש להזין כמות גדולה יותר."+arms.no_attention: "אין די תשומת לב לרכישה. יש לבטל הוראה אחרת או להמתין לתור הבא."++# #731 stock summaries in the report and Why.+# native-review-pending+report.stock_line: "{0} במלאי: {1}"+# native-review-pending+report.stock_change: "{0} במלאי: {1} (שינוי של {2})"+# #1708 artillery action status. Hebrew: native review pending (#564).unit.artillery_move_missing: "לא ניתן להזיז ארטילריה עדיין: נקודות התנועה שלה טרם נקבעו"unit.fire_ready: "ניתן לירות"