A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: fortify and hold orders on the unit card (GDD Phase 5 PR 15 slice 2, refs #754) (#1269)
Beri6d876dda5744
diff --git a/changelog.d/unity-gdd-unit-orders-fortify-754.md b/changelog.d/unity-gdd-unit-orders-fortify-754.mdnew file mode 100644index 000000000..6c013285d--- /dev/null+++ b/changelog.d/unity-gdd-unit-orders-fortify-754.md@@ -0,0 +1,5 @@+- GDD Phase 5 PR 15, slice 2: the unit card's Fortify and Hold orders (refs #754). In the GDD loop a unit's card shows+ Fortify and Hold (Q-UI-2's names, "Fortify" / "ביצור", "Hold" / "החזקה"), each only where the sim's new+ `Orders.Check` takes the order; where it does not, the card shows the sim's reason. A press queues the sim's+ `UnitOrder`, and the card says when the order takes effect. `Orders.Give` now runs `Orders.Check` first, so the card+ and the sim refuse the same orders for the same reasons.diff --git a/docs/units.md b/docs/units.mdindex ba0a288fb..ccb12834e 100644--- a/docs/units.md+++ b/docs/units.md@@ -408,7 +408,12 @@ checks every anchor and logs each spot and its distance.exactly those hexes (`MapScene.ShowReachable`, a band half the selection's width); a click on a lit hex queues thesim's `Move` through `SimBridge` and the card says the move waits for End turn; any other click, a second press, aturn or another selection ends the pick. The sim refuses a move that is no longer possible at End turn with its own- reason. Tests: `UnitOrdersTests`, `InfoPanelLayoutTests.TheUnitCardWithItsMoveOrderFitsEveryWindow`.+ reason. Slice 2 adds Fortify and Hold (Q-UI-2's "Fortify" / "ביצור", "Hold" / "החזקה"): each button shows only where+ the sim's `Orders.Check` takes the order, and where it does not, the card shows the sim's reason as the sim gives it+ (in English for now, as the End turn toast does). A press queues the sim's `UnitOrder` through `SimBridge` (one standing+ order per unit: Hold replaces a queued Fortify, and either replaces a queued attack) and the card says when it takes+ effect. Tests: `UnitOrdersTests`,+ `InfoPanelLayoutTests.TheUnitCardWithItsOrdersFitsEveryWindow`.**The Avia S-199** (`UnitModels.AviaS199`; type `avia-s199-101sqn-1948`):- The Bf 109G airframe, 8.94 m long with a 9.92 m span, with the Jumo 211F's wide three-blade paddle propeller and thediff --git a/sim/Statecraft.Sim.Tests/ArtilleryTests.cs b/sim/Statecraft.Sim.Tests/ArtilleryTests.csindex 7b44ce057..135d7c0c8 100644--- a/sim/Statecraft.Sim.Tests/ArtilleryTests.cs+++ b/sim/Statecraft.Sim.Tests/ArtilleryTests.cs@@ -125,6 +125,7 @@ public class ArtilleryTestsvar s = CombatTests.With(c, Of("gun", 1, 4, 0, 2));var refused = Step(c, s, new UnitOrder(1, Orders.Hold));Assert.Equal("Artillery does not hold ground", Assert.Single(refused.Rejected).Reason);+ Assert.Equal("Artillery does not hold ground", Orders.Check(c, s, 1, Orders.Hold)); // the unit card shows it (#754)Assert.Equal(Step(c, s).State.Hash(), refused.State.Hash());Assert.Empty(Step(c, s, new UnitOrder(1, Orders.Fortify)).Rejected);}diff --git a/sim/Statecraft.Sim.Tests/OrdersTests.cs b/sim/Statecraft.Sim.Tests/OrdersTests.csindex ef7c98fdc..25ac5cdf1 100644--- a/sim/Statecraft.Sim.Tests/OrdersTests.cs+++ b/sim/Statecraft.Sim.Tests/OrdersTests.cs@@ -118,11 +118,40 @@ public class OrdersTests{var c = Load();var s = With(c, Soldier(1, 2, 1), new Unit(2, "soldier", 3, 1, side: "israel", order: Orders.Hold), Enemy(3, 0, 1), new Unit(5, "halutz", 4, 1));+ var before = s.Describe();+ Assert.Equal(reason, Orders.Check(c, s, unit, order)); // the unit card asks before it offers the order (#754)+ Assert.Equal(before, s.Describe());var r = Simulation.Step(c, s, new Command[] { new UnitOrder(unit, order) });Assert.Equal(reason, Assert.Single(r.Rejected).Reason);Assert.Equal(Simulation.Step(c, s, new Command[0]).State.Describe(), r.State.Describe());}+ // R-ORDER-001: Check is null exactly where Give takes the order (the unit card offers it, #754), and changes nothing.+ [Fact]+ public void CheckIsNullForAnOrderGiveTakes()+ {+ var c = Load();+ var s = With(c, Soldier(1, 2, 1), new Unit(2, "soldier", 3, 1, side: "israel", order: Orders.Hold));+ var before = s.Describe();+ Assert.Null(Orders.Check(c, s, 1, Orders.Fortify));+ Assert.Null(Orders.Check(c, s, 1, Orders.Hold));+ Assert.Null(Orders.Check(c, s, 2, Orders.Fortify));+ Assert.Equal(before, s.Describe());+ Assert.Empty(Simulation.Step(c, s, new Command[] { new UnitOrder(1, Orders.Fortify), new UnitOrder(2, Orders.Fortify) }).Rejected);+ }++ // R-ENEMY-001: with enemy, Check runs the same checks with the sides swapped, as Give does for the enemy AI: the enemy's+ // unit is taken, the player's is not.+ [Fact]+ public void CheckForTheEnemySwapsTheSides()+ {+ var c = Load();+ var s = With(c, Soldier(1, 2, 1), Enemy(3, 0, 1));+ Assert.Null(Orders.Check(c, s, 3, Orders.Fortify, enemy: true));+ Assert.Equal("That unit is not yours", Orders.Check(c, s, 1, Orders.Fortify, enemy: true));+ Assert.Null(Orders.Give(c, s, 3, Orders.Fortify, new List<Cause>(), enemy: true));+ }+// R-ORDER-001: fortify again on the hex it is fortifying is refused; the legacy loop refuses the order before charging.[Fact]public void FortifyTwiceIsRefusedAndTheLegacyLoopRefusesTheOrder()diff --git a/sim/Statecraft.Sim/Orders.cs b/sim/Statecraft.Sim/Orders.csindex 430149745..8a683c0dd 100644--- a/sim/Statecraft.Sim/Orders.cs+++ b/sim/Statecraft.Sim/Orders.cs@@ -26,21 +26,31 @@ namespace Statecraft.Simstatic Unit With(Unit u, string order, string target) =>new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, order, target);- /// <summary>R-ORDER-001: gives the unit its standing order, replacing any other. Fortify names the unit's hex and starts- /// as Fortifying; hold names nothing, as it acts where the unit is. Refused, state untouched, for an unknown order or+ /// <summary>R-ORDER-001's refusals: null when <see cref="Give"/> takes the order, else the reason shown to the player.+ /// Changes nothing: the unit card asks it before it offers fortify or hold (#754). Refused for an unknown order or/// unit, a unit with no side (a halutz), an enemy unit, hold for artillery (R-COMBAT-007: it never holds ground,/// Q-ARTY-1), or the order it already has. With <paramref name="enemy"/> the enemy AI orders its own unit through the- /// same checks, the sides swapped (R-ENEMY-001).</summary>- internal static string? Give(Content c, GameState s, int unitId, string order, List<Cause> why, bool enemy = false)+ /// same checks, the sides swapped (R-ENEMY-001). The legacy loop's refusal is Simulation.Step's, before Give, so Check+ /// does not give it.</summary>+ public static string? Check(Content c, GameState s, int unitId, string order, bool enemy = false){if (order != Fortify && order != Hold) return "That order is not known";if (!s.Units.TryGetValue(unitId, out var u)) return "There is no such unit";if (u.Side == "") return "Only a military unit takes that order";if ((u.Side != PlayerSide) != enemy) return "That unit is not yours";if (order == Hold && c.UnitTypes.FirstOrDefault(t => t.Id == u.Type)?.Class == Combat.ArtilleryClass) return "Artillery does not hold ground";- var here = Hex(u);- var already = order == Hold ? u.Order == Hold : (u.Order == Fortify || u.Order == Fortifying) && u.OrderTarget == here;- if (already) return "That unit already has that order";+ var already = order == Hold ? u.Order == Hold : (u.Order == Fortify || u.Order == Fortifying) && u.OrderTarget == Hex(u);+ return already ? "That unit already has that order" : null;+ }++ /// <summary>R-ORDER-001: gives the unit its standing order, replacing any other. Fortify names the unit's hex and starts+ /// as Fortifying; hold names nothing, as it acts where the unit is. Refused, state untouched, with <see cref="Check"/>'s+ /// reason.</summary>+ internal static string? Give(Content c, GameState s, int unitId, string order, List<Cause> why, bool enemy = false)+ {+ var refused = Check(c, s, unitId, order, enemy);+ if (refused != null) return refused;+ var u = s.Units[unitId]; var here = Hex(u);s.Units[unitId] = order == Fortify ? With(u, Fortifying, here) : With(u, Hold, "");why.Add(new Cause("map", unitId.ToString(CultureInfo.InvariantCulture), 0, order == Fortify? $"Unit {unitId} is fortifying hex {here}; it is fortified from the end of the turn"diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.csindex 245852a8f..300ad88bb 100644--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs@@ -13,7 +13,7 @@ namespace Statecraft.Game.UI/// built there, and the two map actions (transit camp, housing project) with the reason when one is not possible/// (MapActions.Check). Tile yields are deliberately not shown (owner decision, M3 rulings 2). A selected unit/// (<see cref="ShowUnit"/>) shows its card instead (<see cref="UnitCard"/>), with a button to the Defence screen (owner- /// ruling, 2026-10-11) and, in the GDD loop, the Move order (GDD Phase 5 PR 15, #754).</summary>+ /// ruling, 2026-10-11) and, in the GDD loop, the Move, Fortify and Hold orders (GDD Phase 5 PR 15, #754).</summary>public sealed class InfoPanelPresenter : System.IDisposable{/// <summary>The class of a fact row (Game.uxml): a sign, then the fact's line; hidden while the line is empty.</summary>@@ -25,7 +25,8 @@ namespace Statecraft.Game.UIreadonly List<(VisualElement row, Label line)> rows = new List<(VisualElement, Label)>();readonly VisualElement panel; readonly SimBridge bridge; readonly UiText text;- readonly Button campButton, housingButton, defenceButton, moveButton; readonly System.Action onCamp, onHousing, onDefence, onMove;+ readonly Button campButton, housingButton, defenceButton, moveButton, fortifyButton, holdButton;+ readonly System.Action onCamp, onHousing, onDefence, onMove, onFortify, onHold;readonly System.Func<PlacedToken?> selectedUnit;bool unitMode;/// <summary>Lights the hexes the Move pick offers on the map (none: clears them); null: nothing is drawn.</summary>@@ -89,6 +90,10 @@ namespace Statecraft.Game.UIonMove = ToggleMovePick;moveButton.clicked += onMove;moveButton.text = text["unit.order.move"];+ fortifyButton = panel.Q<Button>("info-fortify"); holdButton = panel.Q<Button>("info-hold");+ onFortify = () => GiveOrder(Orders.Fortify); onHold = () => GiveOrder(Orders.Hold);+ fortifyButton.clicked += onFortify; holdButton.clicked += onHold;+ fortifyButton.text = text["unit.order.fortify"]; holdButton.text = text["unit.order.hold"];bridge.Changed += Render;panel.parent?.RegisterCallback<GeometryChangedEvent>(OnHudGeometry);Render();@@ -97,7 +102,7 @@ namespace Statecraft.Game.UIvoid OnHudGeometry(GeometryChangedEvent e) => panel.EnableInClassList(ShortClass, e.newRect.height < ShortBelowPx);/// <summary>Unsubscribes from the bridge and the buttons (the owner calls this when disabled).</summary>- public void Dispose() { bridge.Changed -= Render; panel.parent?.UnregisterCallback<GeometryChangedEvent>(OnHudGeometry); campButton.clicked -= onCamp; housingButton.clicked -= onHousing; defenceButton.clicked -= onDefence; moveButton.clicked -= onMove; EndPick(); }+ public void Dispose() { bridge.Changed -= Render; panel.parent?.UnregisterCallback<GeometryChangedEvent>(OnHudGeometry); campButton.clicked -= onCamp; housingButton.clicked -= onHousing; defenceButton.clicked -= onDefence; moveButton.clicked -= onMove; fortifyButton.clicked -= onFortify; holdButton.clicked -= onHold; EndPick(); }/// <summary>Below this window height (logical px; 1366x657 is about 998) the panel gets ShortClass, and the city's own/// hex folds its projects behind their toggle as on a stacked bar (GddHexPanel.ToggleName): there the full list ran into@@ -170,6 +175,23 @@ namespace Statecraft.Game.UIRender();}+ /// <summary>The shown unit's sim id, or null when it can take no order: no unit card, no sim unit for it, or the game+ /// is over (the bridge would refuse every order).</summary>+ int? OrderUnit()+ {+ var unit = unitMode ? selectedUnit() : null;+ return unit == null || bridge.State.GameOver != null ? null : UnitCard.SimUnit(bridge.Content, bridge.State, unit.Value.Token.Unit);+ }++ /// <summary>Fortify's or Hold's button: queues the sim's standing order for the shown unit (one per unit: the other is+ /// replaced). A refusal is raised by the bridge (Refused); the card redraws either way.</summary>+ void GiveOrder(string order)+ {+ if (!(OrderUnit() is int id)) return;+ bridge.Queue(new UnitOrder(id, order));+ Render();+ }+void EndPick(){if (pick == null) return;@@ -311,18 +333,32 @@ namespace Statecraft.Game.UIEndPick();var moves = MoveTargets();moveButton.style.display = moves != null ? DisplayStyle.Flex : DisplayStyle.None;+ // Fortify and Hold (#754): each offered only where the sim's Orders.Check takes it; else the sim's reason, as given,+ // on Israel's units only (an enemy's card would only repeat the sim's English "That unit is not yours").+ var orderUnit = OrderUnit();+ var own = unit?.Token.Unit.Side == UnitData.Israel;+ var refusals = new List<string>();+ foreach (var (order, button) in new[] { (Orders.Fortify, fortifyButton), (Orders.Hold, holdButton) })+ {+ var why = orderUnit is int ou ? Orders.Check(c, s, ou, order) : null;+ button.style.display = orderUnit != null && why == null ? DisplayStyle.Flex : DisplayStyle.None;+ if (why != null && own && !refusals.Contains(why)) refusals.Add(why);+ }panel.EnableInClassList(UnitClass, unit != null);if (unit != null){var card = UnitCard.For(unit.Value, s, text, c.IsGdd);panel.EnableInClassList("info-empty", false);- // The order's state under the card's lines: the pick asks for a hex; a queued Move waits for End turn.+ // The orders' state under the card's lines: the pick asks for a hex; a queued Move, Fortify or Hold waits for End turn.var order = pick != null ? text["unit.move_pick"]: moves is { } m && bridge.QueuedLike(new Move(m.unit, 0, 0)) != null ? text["unit.move_queued"] : "";- title.text = card.Title; subtitle.text = card.Subtitle; settlements.text = order == "" ? card.Body : card.Body + "\n" + order;+ var standing = orderUnit is int su && bridge.QueuedLike(new UnitOrder(su, Orders.Hold)) is UnitOrder given+ ? given.Order == Orders.Fortify ? text["unit.fortify_queued"] : given.Order == Orders.Hold ? text["unit.hold_queued"] : "" : "";+ var lines = new[] { card.Body, order, standing }.Where(x => x != "");+ title.text = card.Title; subtitle.text = card.Subtitle; settlements.text = string.Join("\n", lines);ShowLocalities("");region.text = ""; // a unit's card names no sub-district (the last hex's would stay under it)- placement.text = card.Footer; reason.text = card.Note;+ placement.text = card.Footer; reason.text = string.Join("\n", new[] { card.Note }.Where(x => x != "").Concat(refusals));camp.style.display = DisplayStyle.None; housing.style.display = DisplayStyle.None;ShowThumb(null);GddHexPanel.Hide(gdd); GddHexPanel.Hide(projects);diff --git a/unity/Assets/Scripts/UI/UnitCard.cs b/unity/Assets/Scripts/UI/UnitCard.csindex b731a9f41..16aecfa56 100644--- a/unity/Assets/Scripts/UI/UnitCard.cs+++ b/unity/Assets/Scripts/UI/UnitCard.cs@@ -7,7 +7,7 @@ using Statecraft.Sim;namespace Statecraft.Game.UI{- /// <summary>The info panel's text for a selected unit (its one order so far, Move, is the panel's: InfoPanelPresenter; the panel also links to the Defence screen):+ /// <summary>The info panel's text for a selected unit (its orders so far, Move, Fortify and Hold, are the panel's: InfoPanelPresenter; the panel also links to the Defence screen):/// its name, number and service; where it stands, and since when only from a sourced start (the anchor's `since`,/// never the game's first day: review I1); its formation and first commander where sourced; the sector in the/// source's words; on Israel's units, the national values its token reflects (legacy loop: the reserve call-up sets andiff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.csindex 0ab456b1a..e60b06cec 100644--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs@@ -196,30 +196,35 @@ public class InfoPanelLayoutTestsAssert.IsEmpty(problems, string.Join("\n", problems));}- /// <summary>GDD Phase 5 PR 15, slice 1 (#754): Golani's card at the start with its Move button, before and after the press- /// (the pick line under the card's lines), at every window size in English and Hebrew: the panel lies in the window, and- /// every shown label and button lies inside the panel with its text fitting its box.</summary>+ /// <summary>GDD Phase 5 PR 15, slices 1 and 2 (#754): Golani's card at the start with its Move, Fortify and Hold buttons,+ /// as it is, picking a Move's hex (the pick line under the card's lines), with Fortify queued (its line), and on the turn+ /// after a Hold (Hold refused, with the sim's reason), at every window size in English and Hebrew: the panel lies in the+ /// window, and every shown label and button lies inside the panel with its text fitting its box.</summary>[UnityTest]- public IEnumerator TheUnitCardWithItsMoveOrderFitsEveryWindow()+ public IEnumerator TheUnitCardWithItsOrdersFitsEveryWindow(){var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");var units = Statecraft.Game.Map.Units.UnitData.Parse(MapFile(Statecraft.Game.Map.Units.UnitData.DefaultFileName));var problems = new List<string>();foreach (var hebrew in new[] { false, true })foreach (var (w, h) in Windows)- foreach (var pressed in new[] { false, true })+ foreach (var state in new[] { "", "info-move", "info-fortify", "holding" }){var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);var token = Statecraft.Game.Map.Units.UnitRoster.FromState(units, C, g.State, null, (row, a, q, r) => a).Single(x => x.Unit.Id == "golani");+ if (state == "holding") g.Step(new Command[] { new UnitOrder(UnitCard.SimUnit(C, g.State, token.Unit)!.Value, Orders.Hold) });Statecraft.Game.Map.Units.PlacedToken? golani = new Statecraft.Game.Map.Units.PlacedToken(token, new Statecraft.Game.Map.Units.AnchorSpot(0, 0, 0, 0, false));- var at = $"{(hebrew ? "he" : "en")} {w}x{h}{(pressed ? " picking" : "")}";+ var pressed = state.StartsWith("info-");+ var at = $"{(hebrew ? "he" : "en")} {w}x{h} {state}";yield return Rendered(w, h, g, (root, info) => info.ShowUnit(), root =>{var panel = root.Q("info-panel"); var window = root.worldBound;var move = root.Q<Button>("info-move");if (!Shown(move)) { problems.Add($"{at}: precondition: the Move button shows"); return; }- var pick = (hebrew ? he : Text)["unit.move_pick"];- if (root.Q<Label>("info-settlements").text.Contains(pick) != pressed) problems.Add($"{at}: the pick line shows: {!pressed}");+ var lines = root.Q<Label>("info-settlements").text;+ foreach (var (key, when) in new[] { ("unit.move_pick", "info-move"), ("unit.fortify_queued", "info-fortify") })+ if (lines.Contains((hebrew ? he : Text)[key]) != (state == when)) problems.Add($"{at}: {key} shows: {state != when}");+ if (Shown(root.Q<Button>("info-hold")) == (state == "holding")) problems.Add($"{at}: precondition: Hold shows only while it is not held");if (!Inside(panel.worldBound, window)) problems.Add($"{at}: the panel {panel.worldBound} leaves the window {window}");foreach (var l in panel.Query<TextElement>().ToList().Where(l => !string.IsNullOrEmpty(l.text) && Shown(l))){@@ -231,7 +236,7 @@ public class InfoPanelLayoutTestsif (!pressed) return;var hide = root.Q<Button>("event-hide");if (hide != null && Shown(hide)) UiTestKit.Press(hide); // the turn's decision card disables the panel under it- UiTestKit.Press(root.Q<Button>("info-move"));+ UiTestKit.Press(root.Q<Button>(state));}, () => golani);}Assert.IsEmpty(problems, string.Join("\n", problems));diff --git a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs b/unity/Assets/Tests/EditMode/UnitOrdersTests.csindex c87257dfa..2b593bc28 100644--- a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs+++ b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs@@ -13,9 +13,10 @@ using UnityEditor.SceneManagement;using UnityEngine;using UnityEngine.UIElements;-/// <summary>GDD Phase 5 PR 15, slice 1 (#754): the unit card's Move order. The card offers Move only when the sim's+/// <summary>GDD Phase 5 PR 15 (#754): the unit card's orders. Slice 1, Move: the card offers Move only when the sim's/// Movement.Reachable has a hex for the unit; pressing it lights exactly those hexes on the map, a click on one queues the-/// sim's Move through SimBridge, and a click anywhere else ends the pick and selects as before.</summary>+/// sim's Move through SimBridge, and a click anywhere else ends the pick and selects as before. Slice 2, Fortify and Hold:+/// each shows only where the sim's Orders.Check takes it, else the sim's reason, and a press queues the sim's UnitOrder.</summary>public class UnitOrdersTests{static readonly Content C = ContentLoader.Load(Paths.Content);@@ -159,6 +160,80 @@ public class UnitOrdersTestsfinally { Object.DestroyImmediate(map.gameObject); }}+ /// <summary>Slice 2 (#754): for every unit with a sim unit, Israel's and the enemy's, the card shows Fortify and Hold each+ /// only where the sim's Orders.Check takes it, and where it does not, on Israel's units the sim's reason, whatever it is+ /// (so a refusal the sim adds later, such as artillery's hold, shows with no change here); an enemy's card gives no reason+ /// (the sim's "not yours" is in English and says nothing the card does not). A unit already holding has no Hold, with the+ /// sim's reason; once the game is over neither shows.</summary>+ [Test]+ public void TheCardOffersFortifyAndHoldOnlyWhereTheSimTakesThem()+ {+ using var ui = new UiTestKit();+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ var bridge = new SimBridge(g, Text);+ PlacedToken? shown = null;+ var info = new InfoPanelPresenter(ui.Root, bridge, Text, new Dictionary<string, string>(), selectedUnit: () => shown);+ var buttons = new[] { (Orders.Fortify, ui.Q<Button>("info-fortify")), (Orders.Hold, ui.Q<Button>("info-hold")) };+ var tokens = UnitRoster.FromState(Units, C, g.State, _ => true, (row, a, q, r) => a).Where(t => UnitCard.SimUnit(C, g.State, t.Unit) != null).ToList();+ Assert.IsTrue(tokens.Any(t => t.Unit.Side == UnitData.Israel) && tokens.Any(t => t.Unit.Side != UnitData.Israel), "precondition: both sides");+ void Expect(UnitToken token, string at)+ {+ shown = new PlacedToken(token, new AnchorSpot(0, 0, 0, 0, false));+ info.ShowUnit();+ var id = UnitCard.SimUnit(C, bridge.State, token.Unit)!.Value;+ foreach (var (order, button) in buttons)+ {+ var why = Orders.Check(C, bridge.State, id, order);+ Assert.AreEqual(why == null ? DisplayStyle.Flex : DisplayStyle.None, button.style.display.value, $"{at} {token.Unit.Id}: {order} ({why})");+ if (why == null) continue;+ if (token.Unit.Side == UnitData.Israel) StringAssert.Contains(why, ui.Q<Label>("info-reason").text, $"{at} {token.Unit.Id}: the sim's reason");+ else StringAssert.DoesNotContain(why, ui.Q<Label>("info-reason").text, $"{at} {token.Unit.Id}: no reason on an enemy's card");+ }+ }+ foreach (var token in tokens) Expect(token, "start");+ Assert.AreEqual(("Fortify", "Hold"), (buttons[0].Item2.text, buttons[1].Item2.text), "Q-UI-2's approved names");+ var golani = tokens.Single(t => t.Unit.Id == "golani");+ var id0 = UnitCard.SimUnit(C, g.State, golani.Unit)!.Value;+ Assert.IsNull(bridge.Queue(new UnitOrder(id0, Orders.Hold)));+ bridge.EndTurn();+ Assert.IsNotNull(Orders.Check(C, bridge.State, id0, Orders.Hold), "precondition: Golani holds");+ Expect(golani, "holding");+ Assert.IsTrue(Shown(buttons[0].Item2), "a holding unit can still fortify");+ bridge.State.GameOver = GameOverCodes.MvpEnded;+ info.ShowUnit();+ Assert.IsFalse(buttons.Any(b => Shown(b.Item2)), "no orders once the game is over");+ info.Dispose();+ }++ /// <summary>Fortify queues the sim's UnitOrder(unit, fortify) through SimBridge and the card says when it is set; Hold+ /// then replaces it (one standing order per unit) and the card says so instead.</summary>+ [Test]+ public void FortifyAndHoldQueueTheSimsOrder()+ {+ using var ui = new UiTestKit();+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ var bridge = new SimBridge(g, Text);+ var golani = UnitRoster.FromState(Units, C, g.State, _ => true, (row, a, q, r) => a).Single(t => t.Unit.Id == "golani");+ PlacedToken? shown = new PlacedToken(golani, new AnchorSpot(0, 0, 0, 0, false));+ var info = new InfoPanelPresenter(ui.Root, bridge, Text, new Dictionary<string, string>(), selectedUnit: () => shown);+ var id = UnitCard.SimUnit(C, g.State, golani.Unit)!.Value;+ info.ShowUnit();+ string Lines() => ui.Q<Label>("info-settlements").text;+ Assert.IsFalse(Lines().Contains(Text["unit.fortify_queued"]) || Lines().Contains(Text["unit.hold_queued"]), Lines());+ UiTestKit.Press(ui.Q<Button>("info-fortify"));+ var queued = bridge.Queued.OfType<UnitOrder>().Single();+ Assert.AreEqual((id, Orders.Fortify, (int?)null, (int?)null), (queued.Unit, queued.Order, queued.Q, queued.R));+ StringAssert.Contains(Text["unit.fortify_queued"], Lines());+ UiTestKit.Press(ui.Q<Button>("info-hold"));+ queued = bridge.Queued.OfType<UnitOrder>().Single();+ Assert.AreEqual((id, Orders.Hold), (queued.Unit, queued.Order));+ StringAssert.Contains(Text["unit.hold_queued"], Lines());+ Assert.IsFalse(Lines().Contains(Text["unit.fortify_queued"]), Lines());+ Assert.IsEmpty(bridge.EndTurn().Rejected, "the sim takes the order the card queued");+ Assert.AreEqual(Orders.Hold, bridge.State.Units[id].Order);+ info.Dispose();+ }+/// <summary>The overlay draws one band per hex given (two rings of MapBuilder.RingVertices each) and hides when given/// none, or only hexes off the map.</summary>[Test]diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex 73be36902..e64de1e55 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -150,6 +150,9 @@<ui:Button name="info-defence" /><!-- The unit card's Move order (GDD loop, #754): shown only when the sim has a hex the unit can reach. --><ui:Button name="info-move" />+ <!-- Fortify and Hold (#754): each shown only when the sim's Orders.Check takes it; else its reason shows. -->+ <ui:Button name="info-fortify" />+ <ui:Button name="info-hold" /></ui:VisualElement><ui:Label name="info-reason" class="reason" /><!-- The hex's city projects (GddHexPanel, #1122): here, not in the GDD column, which a city's own hex fills. -->diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 4dd1a45b0..c6c1fc126 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -417,6 +417,11 @@ unit.defence: "Open the Defence screen"unit.order.move: "Move"unit.move_pick: "Choose a lit hex to move to"unit.move_queued: "Move ordered: the unit moves when you end the turn"+# Fortify and Hold (#754): the names are Q-UI-2's, approved by the owner (#375). Fortify is set at the end of the turn (R-ORDER-002).+unit.order.fortify: "Fortify"+unit.order.hold: "Hold"+unit.fortify_queued: "Fortify ordered: the unit is fortified from the end of the turn"+unit.hold_queued: "Hold ordered: the unit holds its hex when you end the turn"newgame.confirm: "Press New game again to abandon this game and start over."newgame.delete_failed: "The old saved game could not be removed; it will be replaced after your next turn."save.unreadable: "Your saved game could not be loaded ({0}). A new game has started."diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex cdee8314d..b9f1528df 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -442,6 +442,13 @@ unit.order.move: "תנועה"unit.move_pick: "בחרו משושה מואר שאליו היחידה תנוע"# Approved by Beri, a native speaker, on #1265 (21 Oct 2026). For the native reviewer (#564)unit.move_queued: "ניתנה פקודת תנועה: היחידה תנוע בסיום התור"+# Fortify and Hold (#754): the names are Q-UI-2's, approved by the owner (#375).+unit.order.fortify: "ביצור"+unit.order.hold: "החזקה"+# Approved by Beri, a native speaker, on #1269 (21 Oct 2026). For the native reviewer (#564)+unit.fortify_queued: "ניתנה פקודת ביצור: היחידה תהיה מבוצרת מסוף התור"+# Approved by Beri, a native speaker, on #1269 (21 Oct 2026). For the native reviewer (#564)+unit.hold_queued: "ניתנה פקודת החזקה: היחידה תחזיק במשושה שלה בסיום התור"newgame.confirm: "יש ללחוץ שוב על משחק חדש כדי לעזוב את המשחק הזה ולהתחיל מחדש."newgame.delete_failed: "לא ניתן היה להסיר את השמירה הקודמת; היא תוחלף אחרי התור הבא."save.unreadable: "לא ניתן היה לטעון את המשחק השמור ({0}). משחק חדש התחיל."