Skip to content

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

Unity: the unit card's Move order, the reachable hexes lit from Movement.Reachable (GDD Phase 5 PR 15 slice 1, refs #754) (#1265)

Berie123971ccb67
diff --git a/changelog.d/unity-gdd-unit-orders-754.md b/changelog.d/unity-gdd-unit-orders-754.md
new file mode 100644
index 000000000..f258d87ad
--- /dev/null
+++ b/changelog.d/unity-gdd-unit-orders-754.md
@@ -0,0 +1,5 @@
+- GDD Phase 5 PR 15, slice 1: the unit card's Move order (refs #754, #385). In the GDD loop a unit's card shows a Move
+ button (Q-UI-2's name, "Move" / "תנועה") when the sim's `Movement.Reachable` has a hex for it. Pressing it lights
+ exactly those hexes on the map. A click on a lit hex queues the sim's `Move` and the card says the unit moves at End
+ turn. Any other click, a second press, a new turn or another selection ends the pick. Fortify, hold, attack and the
+ `smoke-orders` golden come in later slices.
diff --git a/docs/units.md b/docs/units.md
index da72da687..ba0a288fb 100644
--- a/docs/units.md
+++ b/docs/units.md
@@ -402,7 +402,13 @@ checks every anchor and logs each spot and its distance.
- It also gives the national values the token reflects on Israel's cards (legacy loop: "Reserve call-up 80% · security level
5 of 5"; in the GDD loop only the squadron's card has one, "Security level 5 of 5", see above) and the source
hosts, with a draft note that says "Wikipedia only" when the position's own sources are.
-- It has no orders; a button opens the Defence screen.
+- A button opens the Defence screen. In the GDD loop the card also gives the Move order (GDD Phase 5 PR 15, slice 1,
+ #754; Q-UI-2's name, "Move" / "תנועה"). The button shows only when `Movement.Reachable` has a hex for the unit (the
+ token's sim unit is its row's starting force, `UnitCard.SimUnit`), and not once the game is over. Pressing it lights
+ exactly those hexes (`MapScene.ShowReachable`, a band half the selection's width); a click on a lit hex queues the
+ sim's `Move` through `SimBridge` and the card says the move waits for End turn; any other click, a second press, a
+ turn 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`.
**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 the
diff --git a/unity/Assets/Scripts/Map/MapScene.cs b/unity/Assets/Scripts/Map/MapScene.cs
index 30de7ca3c..8c84aa435 100644
--- a/unity/Assets/Scripts/Map/MapScene.cs
+++ b/unity/Assets/Scripts/Map/MapScene.cs
@@ -149,6 +149,65 @@ namespace Statecraft.Game.Map
mr.enabled = true;
}
+ /// <summary>The hexes a unit's Move can go to, outlined while the player picks one (#754): a child of the terrain.</summary>
+ public const string ReachableName = "ReachableHexes";
+ /// <summary>The reachable hexes' band, half the selection's, so the lit hexes read as choices and not as the selection.</summary>
+ public const float ReachableWidth = SelectionWidth / 2;
+
+ /// <summary>Outlines every hex in <paramref name="hexes"/> (Movement.Reachable's, from InfoPanelPresenter) with a thin
+ /// band in one mesh, drawn and draped as <see cref="Select"/>'s outline and with its material; nothing to light (none,
+ /// or only hexes off the map) hides it. Display only: which hexes are lit is the sim's answer, never computed here.
+ /// A unit has at most 5 movement points (unit_types.yaml), so the mesh stays far under 16-bit indices.</summary>
+ public void ShowReachable(IEnumerable<(int q, int r)> hexes)
+ {
+ if (Terrain == null || Hexes == null) return;
+ var found = Terrain.transform.Find(ReachableName);
+ var go = found != null ? found.gameObject : null;
+ if (go == null)
+ {
+ go = new GameObject(ReachableName);
+ go.transform.SetParent(Terrain.transform, false);
+ var mesh = Terrain.GetComponent<MapRuntimeAssets>().Own(new Mesh { name = ReachableName });
+ go.AddComponent<MeshFilter>().sharedMesh = mesh;
+ var renderer = go.AddComponent<MeshRenderer>();
+ renderer.sharedMaterial = selectionMaterial;
+ renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
+ }
+ var byHex = new Dictionary<(int, int), HexJson>();
+ foreach (var h in Hexes.hexes) byHex[(h.q, h.r)] = h;
+ float size = Hexes.hex_size_km * 1000f;
+ int n = MapBuilder.RingVertices;
+ var verts = new List<Vector3>(); var tris = new List<int>();
+ var ring = new List<Vector3>(2 * n); var middle = new List<Vector3>(n);
+ foreach (var at in hexes)
+ {
+ if (!byHex.TryGetValue(at, out var hex)) continue;
+ var c = Frame.ToWorld(hex.lon, hex.lat, 0);
+ var centre = new Vector2(c.x, c.z);
+ ring.Clear(); middle.Clear();
+ MapBuilder.DrapedRing(Frame, Terrain.terrainData, centre, size, SelectionClearanceM, ring);
+ MapBuilder.DrapedRing(Frame, Terrain.terrainData, centre, size * (1f - ReachableWidth), SelectionClearanceM, ring);
+ MapBuilder.DrapedRing(Frame, Terrain.terrainData, centre, size * (1f - ReachableWidth / 2), SelectionClearanceM, middle);
+ int b0 = verts.Count;
+ for (int j = 0; j < n; j++) // each index at the highest of its three rings, as Select's band
+ {
+ float y = Mathf.Max(ring[j].y, Mathf.Max(ring[n + j].y, middle[j].y));
+ ring[j] = new Vector3(ring[j].x, y, ring[j].z); ring[n + j] = new Vector3(ring[n + j].x, y, ring[n + j].z);
+ }
+ verts.AddRange(ring);
+ for (int j = 0; j < n; j++)
+ {
+ int a = b0 + j, b = b0 + (j + 1) % n, ai = b0 + n + j, bi = b0 + n + (j + 1) % n;
+ tris.AddRange(new[] { a, ai, b, b, ai, bi }); // the shader draws both faces (Cull Off)
+ }
+ }
+ var m = go.GetComponent<MeshFilter>().sharedMesh;
+ m.Clear();
+ m.SetVertices(verts); m.SetTriangles(tris, 0);
+ m.RecalculateBounds();
+ go.GetComponent<MeshRenderer>().enabled = verts.Count > 0;
+ }
+
public void Configure(Material terrain, Material marker, Material selection, Material sea, Material frame)
{
terrainMaterial = terrain; markerMaterial = marker; selectionMaterial = selection;
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 9fc4e5896..8a2c9ecd3 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -330,7 +330,8 @@ namespace Statecraft.Game.UI
selectedUnit: () => unitLayer.Selected is string id ? unitLayer.Tokens.First(p => p.Token.Unit.Id == id) : (Statecraft.Game.Map.Units.PlacedToken?)null,
regions: regions, localitiesAt: localitiesAt,
townHex: InfoPanelPresenter.TownHex(map.SettlementsFor(inputs.Map.SettlementsYaml), map.Hexes),
- townNamesHe: map.SettlementsFor(inputs.Map.SettlementsYaml).ToDictionary(s => s.Id, s => s.NameHe)));
+ townNamesHe: map.SettlementsFor(inputs.Map.SettlementsYaml).ToDictionary(s => s.Id, s => s.NameHe),
+ showReachable: map.ShowReachable));
// A smoke session never touches the player's save: no autosave, and no New Game (which deletes the autosave).
// Leaving New Game out is safer than handing it a throwaway store: no file is ever deleted, no path has to be
// right on every platform, and the scripted run never presses it.
@@ -525,7 +526,8 @@ namespace Statecraft.Game.UI
/// <summary>A map click: on a unit's hex it selects the unit (the ring and its card; the hex outline is cleared, so
/// the unit has the promo's one highlight); a second click on it, or a click anywhere else, shows the hex (so a token
- /// never hides the hex's map actions).</summary>
+ /// never hides the hex's map actions). While the card's Move pick is open (#754), a click on a lit hex queues the move
+ /// and keeps the unit's card; any other click ends the pick first and then selects as usual.</summary>
internal static void OnHexClicked(MapScene map, Statecraft.Game.Map.Units.UnitLayer units, InfoPanelPresenter info, int q, int r)
{
if (info.Covered)
@@ -535,6 +537,7 @@ namespace Statecraft.Game.UI
if (info.Selected is (int sq, int sr) && !info.ShowsUnit) map.Select(sq, sr); else map.ClearSelection();
return;
}
+ if (info.PickMoveTarget(q, r)) { map.ClearSelection(); return; } // the unit keeps its ring, the one highlight
var id = units.UnitToSelectAt(q, r);
units.Select(id);
if (id != null) { map.ClearSelection(); info.ShowUnit(); }
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index d582f1fb3..245852a8f 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -12,8 +12,8 @@ namespace Statecraft.Game.UI
/// <summary>The info panel (bottom-left): the selected hex's land, height and the settlements it owns, what the player
/// 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 read-only card instead (<see cref="UnitCard"/>): no orders, only a button to the
- /// Defence screen (owner ruling, 2026-10-11).</summary>
+ /// (<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>
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,9 +25,14 @@ namespace Statecraft.Game.UI
readonly List<(VisualElement row, Label line)> rows = new List<(VisualElement, Label)>();
readonly VisualElement panel; readonly SimBridge bridge; readonly UiText text;
- readonly Button campButton, housingButton, defenceButton; readonly System.Action onCamp, onHousing, onDefence;
+ readonly Button campButton, housingButton, defenceButton, moveButton; readonly System.Action onCamp, onHousing, onDefence, onMove;
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>
+ readonly System.Action<IReadOnlyCollection<(int q, int r)>>? showReachable;
+ /// <summary>While the player picks a Move's hex: the unit, the hexes Movement.Reachable gave (the only ones a click
+ /// takes), and the session and turn they were read on (a turn or a load ends the pick, as the hexes change).</summary>
+ (int unit, HashSet<(int q, int r)> hexes, GameSession session, int turn)? pick;
readonly Label title, subtitle, region, settlements, localitiesLabel, placement, reason;
readonly System.Func<int, int, IReadOnlyList<Statecraft.Game.Map.Kits.Localities.Place>>? localitiesAt;
readonly UiIcon thumb;
@@ -53,10 +58,13 @@ namespace Statecraft.Game.UI
/// <param name="townNamesHe">Each settlement's Hebrew name (name_he), by id: the Hebrew UI names the town with it in the
/// title, the "Settlements" line and that note (#899), or with the English name where it has none (null: English
/// names).</param>
+ /// <param name="showReachable">Lights the hexes a Move can go to while the player picks one, and clears them with none
+ /// (GameRoot: MapScene.ShowReachable; null: the pick still works, with nothing lit).</param>
public InfoPanelPresenter(VisualElement root, SimBridge bridge, UiText text, IReadOnlyDictionary<string, string> settlementNames,
ScreenNav? nav = null, System.Func<PlacedToken?>? selectedUnit = null, MapRegions? regions = null,
System.Func<int, int, IReadOnlyList<Statecraft.Game.Map.Kits.Localities.Place>>? localitiesAt = null,
- System.Func<string, (int q, int r)>? townHex = null, IReadOnlyDictionary<string, string>? townNamesHe = null)
+ System.Func<string, (int q, int r)>? townHex = null, IReadOnlyDictionary<string, string>? townNamesHe = null,
+ System.Action<IReadOnlyCollection<(int q, int r)>>? showReachable = null)
{
panel = root.Q<VisualElement>("info-panel"); this.bridge = bridge; this.text = text;
this.settlementNames = settlementNames; this.regions = regions; this.localitiesAt = localitiesAt; this.townHex = townHex;
@@ -76,6 +84,11 @@ namespace Statecraft.Game.UI
onDefence = () => nav?.Open("defence");
defenceButton.clicked += onDefence;
defenceButton.text = text["unit.defence"];
+ this.showReachable = showReachable;
+ moveButton = panel.Q<Button>("info-move");
+ onMove = ToggleMovePick;
+ moveButton.clicked += onMove;
+ moveButton.text = text["unit.order.move"];
bridge.Changed += Render;
panel.parent?.RegisterCallback<GeometryChangedEvent>(OnHudGeometry);
Render();
@@ -84,7 +97,7 @@ namespace Statecraft.Game.UI
void 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; }
+ public void Dispose() { bridge.Changed -= Render; panel.parent?.UnregisterCallback<GeometryChangedEvent>(OnHudGeometry); campButton.clicked -= onCamp; housingButton.clicked -= onHousing; defenceButton.clicked -= onDefence; moveButton.clicked -= onMove; 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
@@ -115,6 +128,7 @@ namespace Statecraft.Game.UI
{
if (Covered) return; // covered (#210)
if (unitMode || Selected != (q, r)) projects.RemoveFromClassList(GddHexPanel.OpenClass); // a newly chosen hex starts with its city projects folded
+ EndPick();
unitMode = false; Selected = (q, r);
Render();
}
@@ -123,6 +137,7 @@ namespace Statecraft.Game.UI
public void ShowUnit()
{
if (Covered) return;
+ EndPick();
unitMode = true; Selected = null; Render();
}
@@ -130,9 +145,51 @@ namespace Statecraft.Game.UI
public void Clear()
{
if (Covered) return;
+ EndPick();
unitMode = false; Selected = null; Render();
}
+ /// <summary>The shown unit's sim id and the hexes its Move can go to (Movement.Reachable: the sim's answer, spec section
+ /// 2.6), or null when there is no Move to give: no unit card, no sim unit for it, no hex in reach, or the game is over.</summary>
+ (int unit, IReadOnlyDictionary<(int Q, int R), int> hexes)? MoveTargets()
+ {
+ var unit = unitMode ? selectedUnit() : null;
+ if (unit == null || bridge.State.GameOver != null || !(UnitCard.SimUnit(bridge.Content, bridge.State, unit.Value.Token.Unit) is int id)) return null;
+ var reach = Movement.Reachable(bridge.Content, bridge.State, id);
+ return reach.Count == 0 ? null : (id, reach);
+ }
+
+ /// <summary>Move's button: starts the pick (the reachable hexes lit), or ends it when pressed again.</summary>
+ void ToggleMovePick()
+ {
+ if (pick != null) { EndPick(); Render(); return; }
+ if (!(MoveTargets() is { } moves)) return;
+ var hexes = moves.hexes.Keys.Select(h => (h.Q, h.R)).ToList();
+ pick = (moves.unit, new HashSet<(int q, int r)>(hexes), bridge.Session, bridge.State.Turn);
+ showReachable?.Invoke(hexes);
+ Render();
+ }
+
+ void EndPick()
+ {
+ if (pick == null) return;
+ pick = null;
+ showReachable?.Invoke(System.Array.Empty<(int q, int r)>());
+ }
+
+ /// <summary>A map click while the player picks a Move's hex (GameRoot.OnHexClicked asks first): on a lit hex it queues
+ /// the sim's Move through the bridge and returns true (the click is taken, the card stays); anywhere else it only ends
+ /// the pick and returns false, so the click selects as usual. False when no pick is open.</summary>
+ public bool PickMoveTarget(int q, int r)
+ {
+ if (!(pick is { } p)) return false;
+ EndPick();
+ if (!p.hexes.Contains((q, r))) return false;
+ bridge.Queue(new Move(p.unit, q, r)); // a refusal is raised by the bridge (Refused)
+ Render(); // the card drops the pick line either way: a refused Queue raises no Changed
+ return true;
+ }
+
void Build(string action)
{
if (Selected == null) return;
@@ -248,12 +305,21 @@ namespace Statecraft.Game.UI
var camp = campButton; var housing = housingButton;
var unit = unitMode ? selectedUnit() : null;
defenceButton.style.display = unit != null ? DisplayStyle.Flex : DisplayStyle.None;
+ // A pick read on another turn or session, or for a unit no longer shown, is over: its hexes are not the sim's now.
+ if (pick is { } open
+ && (open.session != bridge.Session || open.turn != s.Turn || unit == null || UnitCard.SimUnit(c, s, unit.Value.Token.Unit) != open.unit))
+ EndPick();
+ var moves = MoveTargets();
+ moveButton.style.display = moves != null ? DisplayStyle.Flex : DisplayStyle.None;
panel.EnableInClassList(UnitClass, unit != null);
if (unit != null)
{
var card = UnitCard.For(unit.Value, s, text, c.IsGdd);
panel.EnableInClassList("info-empty", false);
- title.text = card.Title; subtitle.text = card.Subtitle; settlements.text = card.Body;
+ // The order's state under the card's lines: the pick asks for a hex; a queued Move 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;
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;
diff --git a/unity/Assets/Scripts/UI/UnitCard.cs b/unity/Assets/Scripts/UI/UnitCard.cs
index 2f3cc14bf..b731a9f41 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 (read only; no orders: the panel links to the Defence screen):
+ /// <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):
/// 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 an
@@ -18,6 +18,16 @@ namespace Statecraft.Game.UI
{
public string Title = "", Subtitle = "", Body = "", Footer = "", Note = "";
+ /// <summary>The sim unit <paramref name="row"/>'s token stands for in the GDD loop: unit i of a new game is
+ /// <c>c.StartingForces[i]</c> (R-UNIT-006), as UnitRoster.FromState draws it. Null for a row with no starting force (and
+ /// in the legacy loop, which has none), or once that unit has left the state. The card's orders go to this id (#754).</summary>
+ public static int? SimUnit(Content c, GameState s, UnitEntry row)
+ {
+ for (int i = 0; i < c.StartingForces.Count; i++)
+ if (c.StartingForces[i].Row == row.Id) return s.Units.ContainsKey(i) ? i : (int?)null;
+ return null;
+ }
+
public static UnitCard For(PlacedToken placed, GameState state, UiText text, bool gddLoop = false)
{
var t = placed.Token; var u = t.Unit; var a = t.Anchor;
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index c4eb9b8f2..0ab456b1a 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -38,7 +38,8 @@ public class InfoPanelLayoutTests
/// <summary>The real Game.uxml on the real PanelSettings at w x h, out of its loading state, with the top bar, an open event
/// card and the info panel (with the region lines) on the session given.</summary>
static IEnumerator Rendered(int w, int h, GameSession g, System.Action<VisualElement, InfoPanelPresenter> act, System.Action<VisualElement> check,
- UiText? text = null, bool hebrew = false, System.Action<VisualElement>? settled = null)
+ UiText? text = null, bool hebrew = false, System.Action<VisualElement>? settled = null,
+ System.Func<Statecraft.Game.Map.Units.PlacedToken?>? unit = null)
{
var t = text ?? Text;
var rt = new RenderTexture(w, h, 0);
@@ -56,7 +57,7 @@ public class InfoPanelLayoutTests
var bridge = new SimBridge(g, t);
var hud = new HudPresenter(root, bridge, t);
var card = new EventCardPresenter(root, bridge, t, null);
- var info = new InfoPanelPresenter(root, bridge, t, Names(), regions: Regions());
+ var info = new InfoPanelPresenter(root, bridge, t, Names(), regions: Regions(), selectedUnit: unit);
try
{
act(root, info);
@@ -195,6 +196,47 @@ public class InfoPanelLayoutTests
Assert.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>
+ [UnityTest]
+ public IEnumerator TheUnitCardWithItsMoveOrderFitsEveryWindow()
+ {
+ 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 })
+ {
+ 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");
+ 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" : "")}";
+ 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}");
+ 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)))
+ {
+ if (!Inside(l.worldBound, panel.worldBound)) problems.Add($"{at}: '{l.text}' {l.worldBound} leaves the panel {panel.worldBound}");
+ if (!TextFits(l)) problems.Add($"{at}: '{l.text}' does not fit its box {l.contentRect} ({l.name})");
+ }
+ }, hebrew ? he : Text, hebrew, root =>
+ {
+ if (!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"));
+ }, () => golani);
+ }
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
/// <summary>Owner ruling on #1150 (21 Oct 2026): on a stacked bar (1024x1024) the city's own hex shows "City projects (N)", N
/// the kinds listed, and the list behind it; a tap opens it and another closes it. A hex only one city reaches keeps the full
/// list there, and the city's own hex keeps it on a tall one-row window (1920x1080). English and Hebrew.</summary>
diff --git a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs
new file mode 100644
index 000000000..c87257dfa
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs
@@ -0,0 +1,183 @@
+#nullable enable
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.Map;
+using Statecraft.Game.Map.Units;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+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
+/// 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>
+public class UnitOrdersTests
+{
+ static readonly Content C = ContentLoader.Load(Paths.Content);
+ static List<UnitEntry> Units => UnitData.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", UnitData.DefaultFileName)));
+ static UiText Text => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+
+ static MapScene BuildMap()
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
+ var map = new GameObject("MapScene").AddComponent<MapScene>();
+ map.Configure(Load("Terrain"), Load("SettlementMarker"), Load("HexSelection"), Load("Sea"), Load("MapFrame"));
+ map.Build();
+ return map;
+ }
+
+ static bool Shown(VisualElement e) => e.style.display.value != DisplayStyle.None;
+
+ static Material Load(string name) => AssetDatabase.LoadAssetAtPath<Material>($"Assets/Materials/{name}.mat");
+
+ /// <summary>The sim unit a row stands for is the starting force of that row (R-UNIT-006: unit i of a new game is
+ /// StartingForces[i]); none for a row with no starting force, or once the unit has left the state.</summary>
+ [Test]
+ public void ARowsSimUnitIsItsStartingForce()
+ {
+ var s = GameSession.New(C, GoldenRun.Seed, Mode.Historical).State;
+ var golani = Units.Single(u => u.Id == "golani");
+ var id = C.StartingForces.ToList().FindIndex(f => f.Row == "golani");
+ Assert.GreaterOrEqual(id, 0, "precondition: Golani is a starting force");
+ Assert.AreEqual(id, UnitCard.SimUnit(C, s, golani));
+ Assert.IsNull(UnitCard.SimUnit(C, s, Units.Single(u => u.Id == "etzioni")), "Etzioni has no starting force (#1205)");
+ s.Units.Remove(id);
+ Assert.IsNull(UnitCard.SimUnit(C, s, golani), "a unit no longer in the state");
+ Assert.IsNull(UnitCard.SimUnit(SimBridgeGddTests.Legacy, s, golani), "the legacy loop has no starting forces");
+ }
+
+ /// <summary>The card shows Move only where Movement.Reachable has a hex: Golani's at the start; not an enemy force's
+ /// (Reachable is empty for it), and not once the game is over.</summary>
+ [Test]
+ public void TheCardOffersMoveOnlyWhereTheSimHasAHex()
+ {
+ using var ui = new UiTestKit();
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ var bridge = new SimBridge(g, Text);
+ var tokens = UnitRoster.FromState(Units, C, g.State, _ => true, (row, a, q, r) => a);
+ PlacedToken? shown = null;
+ var info = new InfoPanelPresenter(ui.Root, bridge, Text, new Dictionary<string, string>(), selectedUnit: () => shown);
+ var move = ui.Q<Button>("info-move");
+ var golani = tokens.Single(t => t.Unit.Id == "golani");
+ Assert.IsNotEmpty(Movement.Reachable(C, g.State, UnitCard.SimUnit(C, g.State, golani.Unit)!.Value), "precondition");
+ shown = new PlacedToken(golani, new AnchorSpot(0, 0, 0, 0, false));
+ info.ShowUnit();
+ Assert.AreEqual(DisplayStyle.Flex, move.style.display.value, "Golani can move");
+ Assert.AreEqual("Move", move.text, "Q-UI-2's approved name");
+ var enemy = tokens.First(t => t.Unit.Side != UnitData.Israel && UnitCard.SimUnit(C, g.State, t.Unit) != null);
+ Assert.IsEmpty(Movement.Reachable(C, g.State, UnitCard.SimUnit(C, g.State, enemy.Unit)!.Value), "precondition");
+ shown = new PlacedToken(enemy, new AnchorSpot(0, 0, 0, 0, false));
+ info.ShowUnit();
+ Assert.AreEqual(DisplayStyle.None, move.style.display.value, "an enemy force has no Move");
+ shown = new PlacedToken(golani, new AnchorSpot(0, 0, 0, 0, false));
+ g.State.GameOver = GameOverCodes.MvpEnded;
+ info.ShowUnit();
+ Assert.AreEqual(DisplayStyle.None, move.style.display.value, "no orders once the game is over");
+ info.Dispose();
+ }
+
+ /// <summary>Move lights exactly Movement.Reachable's hexes. A click on one queues Move(unit, q, r) through SimBridge and
+ /// keeps the card, which says the move waits for End turn; a click on an unlit hex queues nothing and shows that hex;
+ /// a second press of Move ends the pick. Each end of the pick clears the overlay.</summary>
+ [Test]
+ public void AClickOnALitHexQueuesTheMoveAndAnyOtherClickEndsThePick()
+ {
+ var map = BuildMap();
+ using var ui = new UiTestKit();
+ try
+ {
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);
+ var layer = UnitLayer.Create(map, Units, C.Hexes, still: true);
+ layer.Show(bridge.Content, bridge.State);
+ var lit = new List<IReadOnlyCollection<(int q, int r)>>();
+ var towns = SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", SettlementPlacer.DefaultFileName))).ToDictionary(t => t.Id, t => t.Name);
+ var info = new InfoPanelPresenter(ui.Root, bridge, Text, towns,
+ selectedUnit: () => layer.Selected is string sel ? layer.Tokens.First(p => p.Token.Unit.Id == sel) : (PlacedToken?)null,
+ showReachable: hexes => { lit.Add(hexes.ToList()); map.ShowReachable(hexes); });
+ var golani = layer.Tokens.Single(p => p.Token.Unit.Id == "golani");
+ var id = UnitCard.SimUnit(C, bridge.State, golani.Token.Unit)!.Value;
+ var reach = Movement.Reachable(C, bridge.State, id).Keys.ToList();
+ var move = ui.Q<Button>("info-move");
+ GameRoot.OnHexClicked(map, layer, info, golani.Q, golani.R);
+ Assert.IsTrue(info.ShowsUnit);
+ UiTestKit.Press(move);
+ CollectionAssert.AreEqual(reach, lit.Last(), "the overlay is Reachable's hexes, in its order");
+ Assert.IsTrue(map.Terrain.transform.Find(MapScene.ReachableName).GetComponent<MeshRenderer>().enabled);
+ Assert.IsTrue(ui.Q<Label>("info-settlements").text.Contains(Text["unit.move_pick"]), ui.Q<Label>("info-settlements").text);
+ UiTestKit.Press(move); // a second press ends the pick
+ Assert.IsEmpty(lit.Last());
+ Assert.IsFalse(map.Terrain.transform.Find(MapScene.ReachableName).GetComponent<MeshRenderer>().enabled);
+ // An unlit hex: nothing queued, the pick ends and the click selects as before (the hex, as the unit is not on it).
+ var tlv = C.SettlementHexes.Single(t => t.Id == "tel_aviv");
+ Assert.IsFalse(reach.Contains((tlv.Q, tlv.R)), "precondition: Tel Aviv is out of Golani's reach");
+ UiTestKit.Press(move);
+ GameRoot.OnHexClicked(map, layer, info, tlv.Q, tlv.R);
+ Assert.IsEmpty(lit.Last());
+ Assert.IsEmpty(bridge.Queued);
+ Assert.IsFalse(info.ShowsUnit);
+ Assert.AreEqual((tlv.Q, tlv.R), info.Selected);
+ // A lit hex: the sim's Move is queued, the unit stays selected and its card says the move waits for End turn.
+ GameRoot.OnHexClicked(map, layer, info, golani.Q, golani.R);
+ UiTestKit.Press(move);
+ var (q, r) = reach.Last();
+ map.Select(q, r); // MapPointer outlines the hex before it raises HexClicked
+ GameRoot.OnHexClicked(map, layer, info, q, r);
+ var queued = bridge.Queued.OfType<Move>().Single();
+ Assert.AreEqual((id, q, r), (queued.Unit, queued.Q, queued.R));
+ Assert.IsEmpty(lit.Last());
+ Assert.AreEqual("golani", layer.Selected);
+ Assert.IsTrue(info.ShowsUnit);
+ Assert.IsFalse(map.Terrain.transform.Find(MapScene.SelectionName).GetComponent<MeshRenderer>().enabled, "one highlight: the ring");
+ Assert.IsTrue(ui.Q<Label>("info-settlements").text.Contains(Text["unit.move_queued"]), ui.Q<Label>("info-settlements").text);
+ // A refused order (here the game ends while the pick is open): nothing more is queued and the pick line goes.
+ bridge.Withdraw(queued);
+ UiTestKit.Press(move);
+ bridge.State.GameOver = GameOverCodes.MvpEnded;
+ GameRoot.OnHexClicked(map, layer, info, q, r);
+ Assert.IsEmpty(bridge.Queued, "the bridge refuses an order once the game is over");
+ Assert.IsEmpty(lit.Last());
+ Assert.IsFalse(ui.Q<Label>("info-settlements").text.Contains(Text["unit.move_pick"]), ui.Q<Label>("info-settlements").text);
+ bridge.State.GameOver = null;
+ // A turn ends the pick (its hexes were the last turn's), as does another selection.
+ UiTestKit.Press(move);
+ Assert.IsNotEmpty(lit.Last());
+ bridge.EndTurn();
+ Assert.IsEmpty(lit.Last(), "End turn ends the pick");
+ Assert.IsFalse(ui.Q<Label>("info-settlements").text.Contains(Text["unit.move_pick"]));
+ Assert.IsTrue(info.ShowsUnit && Shown(move), "precondition: Golani's card still offers Move on the next turn");
+ UiTestKit.Press(move);
+ Assert.IsNotEmpty(lit.Last());
+ info.Clear();
+ Assert.IsEmpty(lit.Last(), "another selection ends the pick");
+ info.Dispose();
+ }
+ finally { Object.DestroyImmediate(map.gameObject); }
+ }
+
+ /// <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]
+ public void TheReachableOverlayHasOneBandPerHex()
+ {
+ var map = BuildMap();
+ try
+ {
+ var hexes = C.Hexes.Where(h => h.Land).Take(3).Select(h => (h.Q, h.R)).ToList();
+ map.ShowReachable(hexes);
+ var go = map.Terrain.transform.Find(MapScene.ReachableName);
+ Assert.IsTrue(go.GetComponent<MeshRenderer>().enabled);
+ Assert.AreEqual(3 * 2 * MapBuilder.RingVertices, go.GetComponent<MeshFilter>().sharedMesh.vertexCount);
+ map.ShowReachable(new[] { (9999, 9999) });
+ Assert.IsFalse(go.GetComponent<MeshRenderer>().enabled, "off the map: nothing to light");
+ map.ShowReachable(hexes);
+ map.ShowReachable(new (int, int)[0]);
+ Assert.IsFalse(go.GetComponent<MeshRenderer>().enabled);
+ }
+ finally { Object.DestroyImmediate(map.gameObject); }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs.meta b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs.meta
new file mode 100644
index 000000000..a5deefc86
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c400fa3134c003dc4a91bc8e84e6148c
\ No newline at end of file
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 95acc21d2..97bd4e7a7 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -148,6 +148,8 @@
<ui:Button name="build-camp" />
<ui:Button name="build-housing" />
<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" />
</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.yaml
index 9d154af2c..a78159a7f 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -410,6 +410,10 @@ unit.sources: "Sources: {0}"
unit.draft_wikipedia: "Draft: from Wikipedia only, not yet checked against a published history"
unit.draft: "Draft: not yet checked by a historian"
unit.defence: "Open the Defence screen"
+# The unit card's Move order (GDD Phase 5 PR 15, #754): the order's name is Q-UI-2's, approved by the owner (#375).
+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"
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.yaml
index 8317bdf1e..17df6be2e 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -432,6 +432,12 @@ unit.sources: "מקורות: {0}"
unit.draft_wikipedia: "טיוטה: מוויקיפדיה בלבד, טרם נבדק מול מחקר שפורסם"
unit.draft: "טיוטה: טרם נבדק בידי היסטוריון"
unit.defence: "פתיחת מסך הביטחון"
+# The unit card's Move order (#754): the order's name is Q-UI-2's, approved by the owner (#375).
+unit.order.move: "תנועה"
+# Approved by Beri, a native speaker, on #1265 (21 Oct 2026). For the native reviewer (#564)
+unit.move_pick: "בחרו משושה מואר שאליו היחידה תנוע"
+# Approved by Beri, a native speaker, on #1265 (21 Oct 2026). For the native reviewer (#564)
+unit.move_queued: "ניתנה פקודת תנועה: היחידה תנוע בסיום התור"
newgame.confirm: "יש ללחוץ שוב על משחק חדש כדי לעזוב את המשחק הזה ולהתחיל מחדש."
newgame.delete_failed: "לא ניתן היה להסיר את השמירה הקודמת; היא תוחלף אחרי התור הבא."
save.unreadable: "לא ניתן היה לטעון את המשחק השמור ({0}). משחק חדש התחיל."