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.

Fixes #1309 (#1383)

Eyal Golan85fa622bdc10
diff --git a/changelog.d/1309.md b/changelog.d/1309.md
new file mode 100644
index 000000000..43b9d5138
--- /dev/null
+++ b/changelog.d/1309.md
@@ -0,0 +1,2 @@
+- The unit card offers Send home (R-UNIT-005) once the unit's front has signed its armistice: the button shows only when
+ the sim's Demobilization.Check accepts, queues the order for End turn and says so under the card's lines (Fixes #1309).
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index 31a5d4fa2..ea7f33f0b 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -13,7 +13,8 @@ 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, Fortify, Hold and Attack orders (GDD Phase 5 PR 15, #754).</summary>
+ /// ruling, 2026-10-11) and, in the GDD loop, the Move, Fortify, Hold and Attack orders (GDD Phase 5 PR 15, #754),
+ /// and Send home after the unit's front signs its armistice (#1309).</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,8 +26,8 @@ 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, moveButton, fortifyButton, holdButton, attackButton;
- readonly System.Action onCamp, onHousing, onDefence, onMove, onFortify, onHold, onAttack;
+ readonly Button campButton, housingButton, defenceButton, moveButton, fortifyButton, holdButton, attackButton, sendHomeButton;
+ readonly System.Action onCamp, onHousing, onDefence, onMove, onFortify, onHold, onAttack, onSendHome;
readonly System.Func<PlacedToken?> selectedUnit;
bool unitMode;
/// <summary>Lights the hexes the Move or Attack pick offers on the map (none: clears them); null: nothing is drawn.</summary>
@@ -110,6 +111,10 @@ namespace Statecraft.Game.UI
onAttack = () => TogglePick(attack: true);
attackButton.clicked += onAttack;
attackButton.text = text["unit.order.attack"];
+ sendHomeButton = panel.Q<Button>("info-send-home");
+ onSendHome = () => GiveOrder(Demobilization.SendHome);
+ sendHomeButton.clicked += onSendHome;
+ sendHomeButton.text = text["unit.order.send_home"];
bridge.Changed += Render;
panel.parent?.RegisterCallback<GeometryChangedEvent>(OnHudGeometry);
Render();
@@ -118,7 +123,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() { presses.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; attackButton.clicked -= onAttack; EndPick(); }
+ public void Dispose() { presses.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; attackButton.clicked -= onAttack; sendHomeButton.clicked -= onSendHome; 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
@@ -239,8 +244,8 @@ namespace Statecraft.Game.UI
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>
+ /// <summary>Fortify, Hold or Send home's button: queues the sim's order for the shown unit (one per unit: another
+ /// UnitOrder 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;
@@ -412,19 +417,24 @@ namespace Statecraft.Game.UI
var attacks = AttackTargets();
attackButton.style.display = attacks is { } at && at.hexes.Count > 0 ? DisplayStyle.Flex : DisplayStyle.None;
foreach (var why in attacks?.refused ?? new List<string>()) if (own && !refusals.Contains(why)) refusals.Add(why);
+ // Send home (#1309): Demobilization.Check is the complete eligibility rule. A refusal hides the order and adds
+ // no card copy; the player sees it only after the relevant armistice makes the order available.
+ var sendHomeWhy = orderUnit is int du ? Demobilization.Check(c, s, du) : null;
+ sendHomeButton.style.display = orderUnit != null && sendHomeWhy == 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);
// The orders' state under the card's lines: the pick asks for a hex (an attack's with each lit hex's odds, Q-UI-1);
- // a queued Move, Fortify, Hold or Attack waits for End turn (an attack's with its hex's odds).
+ // a queued Move, Fortify, Hold, Attack or Send home waits for End turn (an attack's with its hex's odds).
var order = pick is { attack: true } ap ? string.Join("\n", new[] { text["unit.attack_pick"] }.Concat(ap.hexes.Select(h => Odds(ap.unit, h.q, h.r))).Where(x => x != ""))
: pick != null ? text["unit.move_pick"]
: moves is { } m && bridge.QueuedLike(new Move(m.unit, 0, 0)) != null ? text["unit.move_queued"] : "";
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"]
- : given.Order == Combat.Attack && given.Q is int gq && given.R is int gr ? text["unit.attack_queued"] + "\n" + Odds(su, gq, gr) : "" : "";
+ : given.Order == Combat.Attack && given.Q is int gq && given.R is int gr ? text["unit.attack_queued"] + "\n" + Odds(su, gq, gr)
+ : given.Order == Demobilization.SendHome ? text["unit.send_home_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("");
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index e071b3c7c..dfe51f12d 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -197,7 +197,8 @@ public class InfoPanelLayoutTests
}
/// <summary>GDD Phase 5 PR 15, slices 1 to 3 (#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), on the turn
+ /// as it is, picking a Move's hex (the pick line under the card's lines), with Fortify queued (its line), after the
+ /// armistices with Send home queued (#1309: its button and its line), on the turn
/// after a Hold (Hold refused, with the sim's reason), and picking an Attack's hex (an enemy put in its reach if none is) (the
/// pick line, the enemy's name, strength ratio and outcome bands), 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>
@@ -209,12 +210,13 @@ public class InfoPanelLayoutTests
var problems = new List<string>();
foreach (var hebrew in new[] { false, true })
foreach (var (w, h) in Windows)
- foreach (var state in new[] { "", "info-move", "info-fortify", "holding", "info-attack" })
+ foreach (var state in new[] { "", "info-move", "info-fortify", "info-send-home", "holding", "info-attack" })
{
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) });
if (state == "info-attack") UnitOrdersTests.EnemyInGolanisReach(g.State);
+ if (state == "info-send-home") foreach (var front in Prisoners.Fronts) g.State.ChosenOptions["armistice_" + front] = "sign";
var t = hebrew ? he : Text;
var names = Statecraft.Game.Map.Units.UnitRoster.FromState(units, C, g.State, null, (row, a, q, r) => a)
.Where(x => UnitCard.SimUnit(C, g.State, x.Unit) != null)
@@ -227,8 +229,9 @@ public class InfoPanelLayoutTests
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; }
+ if (Shown(root.Q<Button>("info-send-home")) != (state == "info-send-home")) problems.Add($"{at}: Send home visibility");
var lines = root.Q<Label>("info-settlements").text;
- foreach (var (key, when) in new[] { ("unit.move_pick", "info-move"), ("unit.fortify_queued", "info-fortify"), ("unit.attack_pick", "info-attack") })
+ foreach (var (key, when) in new[] { ("unit.move_pick", "info-move"), ("unit.fortify_queued", "info-fortify"), ("unit.send_home_queued", "info-send-home"), ("unit.attack_pick", "info-attack") })
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}");
diff --git a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs
index 4be550db3..b4882e70d 100644
--- a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs
@@ -236,6 +236,47 @@ public class UnitOrdersTests
info.Dispose();
}
+ /// <summary>R-UNIT-005 (#1309): Send home is absent until the shown Israeli unit's own front has signed its armistice,
+ /// then carries the localized label, queues the sim's UnitOrder through the same bridge as the standing orders and shows
+ /// its queued line under the card's lines.</summary>
+ [Test]
+ public void SendHomeAppearsAfterTheFrontsArmisticeAndQueuesTheSimsOrder()
+ {
+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ foreach (var (t, label) in new[] { (Text, "Send home"), (he, "שליחה הביתה") })
+ {
+ using var ui = new UiTestKit();
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ var bridge = new SimBridge(g, t);
+ var tokens = UnitRoster.FromState(Units, C, g.State, _ => true, (row, a, q, r) => a);
+ var token = tokens.Single(x => x.Unit.Id == "golani");
+ var id = UnitCard.SimUnit(C, g.State, token.Unit)!.Value;
+ var u = g.State.Units[id];
+ var next = new[] { (1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1) }.Select(d => (q: u.Q + d.Item1, r: u.R + d.Item2))
+ .First(h => C.HexAt(h.q, h.r)?.Land == true && !g.State.Units.Values.Any(x => (x.Q, x.R) == h));
+ var egypt = g.State.Units.Values.First(x => x.Side == "egypt");
+ g.State.Units[egypt.Id] = new Unit(egypt.Id, egypt.Type, next.q, next.r, egypt.Service, egypt.Side, egypt.Strength,
+ egypt.Order, egypt.OrderTarget, egypt.HomeCity);
+ PlacedToken? selected = new PlacedToken(token, new AnchorSpot(0, 0, 0, 0, false));
+ var info = new InfoPanelPresenter(ui.Root, bridge, t, new Dictionary<string, string>(), selectedUnit: () => selected);
+ var button = ui.Q<Button>("info-send-home");
+ Assert.AreEqual("The armistice with Egypt is not signed", Demobilization.Check(C, g.State, id), "precondition");
+ info.ShowUnit();
+ Assert.AreEqual(DisplayStyle.None, button.style.display.value, "hidden before the relevant armistice");
+
+ g.State.ChosenOptions["armistice_egypt"] = "sign";
+ Assert.IsNull(Demobilization.Check(C, g.State, id), "precondition: the relevant armistice opens the order");
+ info.ShowUnit();
+ Assert.AreEqual(DisplayStyle.Flex, button.style.display.value, "shown after the relevant armistice");
+ Assert.AreEqual(label, button.text);
+ UiTestKit.Press(button);
+ var queued = bridge.Queued.OfType<UnitOrder>().Single();
+ Assert.AreEqual((id, Demobilization.SendHome, (int?)null, (int?)null), (queued.Unit, queued.Order, queued.Q, queued.R));
+ StringAssert.Contains(t["unit.send_home_queued"], ui.Q<Label>("info-settlements").text, "the card says the order waits for End turn");
+ info.Dispose();
+ }
+ }
+
/// <summary>Gives the state the Arms for an attack and, when Golani has no enemy in reach (the sim's Combat.Check takes no
/// hex), puts the first enemy sim unit on the first free land hex next to it; returns Golani's sim id.</summary>
internal static int EnemyInGolanisReach(GameState s)
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index eeee663d8..11b8cdfc8 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -156,6 +156,8 @@
<ui:Button name="info-hold" />
<!-- Attack (#754): shown only when the sim's Combat.Check takes some hex; the pick shows each hex's odds. -->
<ui:Button name="info-attack" />
+ <!-- Send home (#1309): shown only when the sim's Demobilization.Check takes the unit. -->
+ <ui:Button name="info-send-home" />
</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 35defaa7a..e8b334ad6 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -465,6 +465,9 @@ unit.attack_odds: "{0}: strength ratio {1:0'%'}"
unit.attack_band: "{0} in {1}: you lose {2:N0} people, they lose {3:N0}"
unit.attack_band_retreat: "{0} in {1}: you lose {2:N0} people, they lose {3:N0} and retreat"
unit.attack_queued: "Attack ordered: the unit attacks when you end the turn"
+# The unit card's player-triggered demobilisation order (R-UNIT-005, #1309).
+unit.order.send_home: "Send home"
+unit.send_home_queued: "Send home ordered: the unit goes home 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 f95b4fc15..866b52781 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -493,6 +493,10 @@ unit.attack_band: "{0} מתוך {1}: אתם מאבדים {2:N0} איש, הם מ
unit.attack_band_retreat: "{0} מתוך {1}: אתם מאבדים {2:N0} איש, הם מאבדים {3:N0} ונסוגים"
# Approved by Beri, a native speaker, on #1277 (21 Oct 2026). For the native reviewer (#564)
unit.attack_queued: "ניתנה פקודת התקפה: היחידה תתקוף בסיום התור"
+# The unit card's Send home order and its queued line (R-UNIT-005, #1309), in unit.order.*'s and unit.*_queued's form.
+# Hebrew drafts: agent-checked; native review pending (#564).
+unit.order.send_home: "שליחה הביתה"
+unit.send_home_queued: "ניתנה פקודת שליחה הביתה: היחידה תחזור הביתה בסיום התור"
newgame.confirm: "יש ללחוץ שוב על משחק חדש כדי לעזוב את המשחק הזה ולהתחיל מחדש."
newgame.delete_failed: "לא ניתן היה להסיר את השמירה הקודמת; היא תוחלף אחרי התור הבא."
save.unreadable: "לא ניתן היה לטעון את המשחק השמור ({0}). משחק חדש התחיל."