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.

ui: #1527 follow-ups: unit names in the Why lines, Send home blocks every order, skips survive a language switch (#1631)

Eyal Golan7ec163c46be4
diff --git a/changelog.d/1527-followups.md b/changelog.d/1527-followups.md
new file mode 100644
index 000000000..116873334
--- /dev/null
+++ b/changelog.d/1527-followups.md
@@ -0,0 +1,7 @@
+### Fixed
+- A unit raised in play is named as one unit in the Why lines and toasts ("Recruit unit, Tel Aviv", "Halutz group"),
+ not by its type's plural ("Recruits, Tel Aviv") or a raw id ("halutz"). The Hebrew unit lines no longer give a unit's
+ name a verb that suits only feminine names, so the Arab forces' lines read correctly too.
+- Once Send home is queued for a unit, it takes no other order: the card offers none, a Reinforce for it is refused,
+ and a Reinforce queued before Send home is withdrawn and its Attention refunded.
+- Switching the language in Settings keeps this turn's "Skip this turn" choices.
diff --git a/docs/WRITING_UI_HE.md b/docs/WRITING_UI_HE.md
index 9ed26a16c..1e5287889 100644
--- a/docs/WRITING_UI_HE.md
+++ b/docs/WRITING_UI_HE.md
@@ -142,6 +142,7 @@ Status: proposed review process. New Hebrew recommendations need native review;
### HE-15 Agreement with a placeholder
Status: #1136 applied Beri's native review from #564 to the budget strings after the interim neutral wording in #1081. A changing placeholder must not receive a fixed verb or pronoun that fits only one possible name. The current strings are "{0} מצביעה על התקציב, אך ההצבעה אינה מחייבת: לקואליציה יש {1} מתוך {2} {3}" (`budget.vote_advisory`), "{0} אינה מצביעה על התקציב" (`budget.no_vote`) and "מתייעצת עם {0} · {1} חברים · ההצבעות אינן מחייבות" (`cabinet.legislature_advisory`). Beri's note explains why the budget's feminine forms work: all three current legislature names are feminine. A masculine-named body would need new wording. Keep the native-reviewed wording for the current bodies; it is not a universal solution for every future name. ContentNames.Of reads legislature body_he (#861). A new grammatical-gender field remains a separate design decision.
+The unit Why lines (`why.line.*`) name any unit, the Arab forces' masculine names, Israel's feminine ones and a raised unit's (`unit.name.*`), so since the follow-up to #1527 none of them has a verb or pronoun that agrees with the name: the name opens the line as its label ("{0}: נסיגה למשושה {1}"), or sits in a noun phrase ("ההתקפה של {0}"). WhyUnitNamesTests checks every unit through every line.
For the native reviewer: review any new body name against these sentences and mark any other string whose verb or pronoun assumes the gender of a changing placeholder.
## Candidate fixes for the Hebrew file (all unapproved)
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index dd2e81305..c7e98b17f 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -232,6 +232,7 @@ namespace Statecraft.Game.UI
DiagLog.BootPhase($"session started (turn {session.State.Turn}, replayed)");
var bridge = Bridge = new SimBridge(session, text);
if (keep != null) foreach (var order in keep.Queued) bridge.Queue(order); // in their order: each was within the attention left
+ if (keep != null) foreach (var unit in keep.Skipped) bridge.Skip(unit); // this turn's skips too: no reload, no new turn
if (Statecraft.HexTiles.HexTilesLook.Requested()) // opt-in hex-tile map (docs/hex-tiles/README.md); presentation only
{
Statecraft.HexTiles.HexTilesLook.Apply(map, true);
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index 151b01ec5..6692db823 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -204,7 +204,8 @@ namespace Statecraft.Game.UI
(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) is int id)) return null;
+ if (unit == null || bridge.State.GameOver != null || !(UnitCard.SimUnit(bridge.Content, bridge.State, unit.Value.Token) is int id)
+ || bridge.GoingHome(id)) return null;
var reach = Movement.Reachable(bridge.Content, bridge.State, id, bridge.Spent);
return reach.Count == 0 ? null : (id, reach);
}
@@ -259,14 +260,17 @@ namespace Statecraft.Game.UI
return text.Format("unit.attack_odds", who, p.RatioPercent) + "\n" + string.Join("\n", bands); // one band a line
}
- /// <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()
+ /// <summary>The shown unit's sim id, or null: no unit card, no sim unit for it, or the game is over.</summary>
+ int? ShownUnit()
{
var unit = unitMode ? selectedUnit() : null;
return unit == null || bridge.State.GameOver != null ? null : UnitCard.SimUnit(bridge.Content, bridge.State, unit.Value.Token);
}
+ /// <summary>The shown unit's sim id, or null when it can take no order: none is shown (ShownUnit), or Send home is
+ /// queued for it (the bridge refuses it every other order, spec 3.2).</summary>
+ int? OrderUnit() => ShownUnit() is int id && !bridge.GoingHome(id) ? id : (int?)null;
+
/// <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)
@@ -534,7 +538,7 @@ namespace Statecraft.Game.UI
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 orderUnit = OrderUnit(); var shownUnit = ShownUnit();
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) })
@@ -556,7 +560,7 @@ namespace Statecraft.Game.UI
// the missing strength up to the city's free civilians; the sim's own Reinforce, run on a copy, decides, and its
// refusal shows as the other orders' do. None while one is queued for the unit.
reinforce = null;
- var reinforceQueued = orderUnit is int rq && bridge.QueuedLike(new Reinforce(rq, "", 0)) != null;
+ var reinforceQueued = shownUnit is int rq && bridge.QueuedLike(new Reinforce(rq, "", 0)) != null;
if (orderUnit is int ru && own && !reinforceQueued && s.Units.TryGetValue(ru, out var formation) && Training.Room(s, formation) > 0
&& c.SettlementHexes.FirstOrDefault(h => h.Q == formation.Q && h.R == formation.R && s.Cities.ContainsKey(h.Id)) is { } home)
{
@@ -575,15 +579,15 @@ namespace Statecraft.Game.UI
// 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).
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"] : "";
- var standing = orderUnit is int su && s.Units.TryGetValue(su, out var shown)
+ var standing = shownUnit is int su && s.Units.TryGetValue(su, out var shown)
? shown.Order == Orders.Fortify || shown.Order == Orders.Fortifying ? text["unit.fortify_queued"]
: shown.Order == Orders.Hold ? text["unit.hold_queued"]
: bridge.QueuedLike(new UnitOrder(su, Demobilization.SendHome)) != null ? text["unit.send_home_queued"] : ""
: "";
- var points = orderUnit is int pu && s.Units.TryGetValue(pu, out var military) && military.Side == Movement.PlayerSide
+ var points = shownUnit is int pu && s.Units.TryGetValue(pu, out var military) && military.Side == Movement.PlayerSide
&& c.UnitTypes.FirstOrDefault(t => t.Id == military.Type) is { MovementPoints: > 0 } type
? text.Format("unit.points", Movement.PointsLeft(c, s, pu, bridge.Spent), type.MovementPoints) : "";
- var routeLine = orderUnit is int routeUnit ? GoToLine(routeUnit) : "";
+ var routeLine = shownUnit is int routeUnit ? GoToLine(routeUnit) : "";
var lines = new[] { card.Body, points, order, routeLine, standing, reinforceQueued ? text["unit.reinforce_queued"] : "" }.Where(x => x != "");
title.text = card.Title; subtitle.text = card.Subtitle; settlements.text = string.Join("\n", lines);
ShowLocalities("");
diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.cs
index deb61d3c4..fa31b6637 100644
--- a/unity/Assets/Scripts/UI/SimBridge.cs
+++ b/unity/Assets/Scripts/UI/SimBridge.cs
@@ -28,6 +28,8 @@ namespace Statecraft.Game.UI
/// <summary>The movement points each unit has spent this turn.</summary>
public IReadOnlyDictionary<int, int> Spent => Session.Now.Spent;
public IReadOnlyList<Command> Queued => deferred;
+ /// <summary>The units skipped this turn: Settings' language switch carries them to the rebuilt bridge with Queued.</summary>
+ public IReadOnlyCollection<int> Skipped => skipped;
/// <summary>R-MOVE-010: the units End turn waits for, in ascending id, less those skipped this turn and those going home.</summary>
public IReadOnlyList<int> NeedsOrders => Movement.NeedsOrders(Content, State, Spent).Where(id => !skipped.Contains(id) && !GoingHome(id)).ToList();
/// <summary>The orders the last turn ran with (empty until a turn has run, and after a refused batch): what the player
@@ -115,7 +117,21 @@ namespace Statecraft.Game.UI
IReadOnlyList<Command> All => Session.Committed.Concat(deferred).ToList();
- bool GoingHome(int unit) => deferred.Any(x => x is UnitOrder o && o.Unit == unit && o.Order == Demobilization.SendHome);
+ /// <summary>Whether Send home is queued for the unit: it then takes no other order (spec 3.2), deferred or instant.</summary>
+ public bool GoingHome(int unit) => deferred.Any(x => IsSendHome(x) && UnitOf(x) == unit);
+
+ static bool IsSendHome(Command c) => c is UnitOrder o && o.Order == Demobilization.SendHome;
+
+ /// <summary>The unit an order is given to (a move, a unit order, a reinforcement, pioneer work or its stop), or null.</summary>
+ static int? UnitOf(Command c) => c switch
+ {
+ Move m => m.Unit,
+ UnitOrder o => o.Unit,
+ Reinforce x => x.Unit,
+ PioneerWork w => w.Unit,
+ StopWork w => w.Unit,
+ _ => (int?)null,
+ };
/// <summary>Skips the unit for this turn: not an order, not saved, nothing in the game changes (spec 7.2).</summary>
public void Skip(int unit) { if (skipped.Add(unit)) Notify(Changed); }
@@ -221,10 +237,9 @@ namespace Statecraft.Game.UI
var bad = Validate(c);
if (bad != null) return Refuse(bad);
if (State.GameOver != null) return Refuse(text["order.game_over"]);
+ if (UnitOf(c) is int unit && !IsSendHome(c) && GoingHome(unit)) return Refuse(text["order.going_home"]);
if (Simulation.IsInstant(c))
{
- var unit = c is Move m ? m.Unit : ((UnitOrder)c).Unit;
- if (GoingHome(unit)) return Refuse(text["order.going_home"]);
var before = Session.Now.Why.Count;
var refused = Session.Commit(c);
if (refused != null) return Refuse(refused);
@@ -238,6 +253,10 @@ namespace Statecraft.Game.UI
Notify(RefusedForAttention); // presentation only: a failing listener never changes the refusal
return Refuse(text.Format("order.no_attention", Price(c), LeftFor(c)));
}
+ // Send home takes the unit's place in the queue: an order queued for it earlier (a reinforcement) is withdrawn, and
+ // its Attention refunded, so End turn never acts on a unit it sends home in the same turn. Withdrawing only refunds,
+ // so the check above still holds.
+ if (IsSendHome(c)) deferred.RemoveAll(x => UnitOf(x) == UnitOf(c) && Key(x) != Key(c));
var old = QueuedLike(c);
if (old != null) deferred[deferred.IndexOf(old)] = c; else deferred.Add(c);
Notify(Changed);
diff --git a/unity/Assets/Scripts/UI/UnitCard.cs b/unity/Assets/Scripts/UI/UnitCard.cs
index f5f11cfe1..765f2019a 100644
--- a/unity/Assets/Scripts/UI/UnitCard.cs
+++ b/unity/Assets/Scripts/UI/UnitCard.cs
@@ -34,8 +34,8 @@ namespace Statecraft.Game.UI
public static int? SimUnit(Content c, GameState s, UnitToken token) =>
token.SimId is int id ? s.Units.ContainsKey(id) ? id : (int?)null : SimUnit(c, s, token.Unit);
- /// <summary>A raised unit's type on screen (#1396), or null for a type no raised unit has. The card's title and the
- /// Why lines' unit names (UnitNames, #1399) both read it.</summary>
+ /// <summary>A raised unit's type on screen (#1396), or null for a type no raised unit has: the card's title. The Why
+ /// lines name the unit as one formation instead (unit.name.&lt;type&gt;, UnitNames).</summary>
public static string? RaisedType(string type, UiText text) => type switch
{
"recruit" => text["city.track_recruit"],
diff --git a/unity/Assets/Scripts/UI/UnitNames.cs b/unity/Assets/Scripts/UI/UnitNames.cs
index bd079e94c..990cffa1e 100644
--- a/unity/Assets/Scripts/UI/UnitNames.cs
+++ b/unity/Assets/Scripts/UI/UnitNames.cs
@@ -10,7 +10,8 @@ namespace Statecraft.Game.UI
{
/// <summary>#1399: names a unit snapshot and formats the structured Why lines that contain one. A starting force is
/// named by its units_1948.yaml row (name_he in Hebrew where the row has one); a raised unit by its type and home city
- /// (UnitCard.RaisedType; the city's Hebrew name from <c>namesHe</c>, the map's parse, as the unit card does).</summary>
+ /// (unit.name.&lt;type&gt;: one formation, singular, as the lines' verbs are, never the type's plural label; the city's
+ /// Hebrew name from <c>namesHe</c>, the map's parse, as the unit card does).</summary>
public static class UnitNames
{
public static string Of(UnitRef unit, Content c, IReadOnlyList<UnitEntry> rows, UiText text,
@@ -27,7 +28,7 @@ namespace Statecraft.Game.UI
}
}
- var type = UnitCard.RaisedType(unit.Type, text) ?? unit.Type;
+ var type = text.Has("unit.name." + unit.Type) ? text["unit.name." + unit.Type] : unit.Type;
return string.IsNullOrEmpty(unit.HomeCity)
? type
: text.Format("unit.raised_name", type, ContentNames.Settlement(text, c, unit.HomeCity, namesHe));
diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
index 22830eeaa..ed4da726b 100644
--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs
+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
@@ -147,6 +147,26 @@ public class HebrewUiTests
Assert.AreEqual(UiLanguage.English, settings.Read(SettingsPresenter.LanguageKey));
}
+ /// <summary>Codex's review of #1527, finding 4: the language switch keeps this turn's "Skip this turn" choices as it
+ /// keeps the queued orders, so End turn does not ask again for a unit the player skipped.</summary>
+ [Test]
+ public void TheLanguageSwitchKeepsThisTurnsSkips()
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ Object.FindFirstObjectByType<MapScene>().Build(Inputs.Map);
+ var game = Object.FindFirstObjectByType<GameRoot>();
+ game.Store = new SaveStore(saveDir);
+ game.Settings = new SettingsStore(Path.Combine(saveDir, "settings"));
+ game.Begin(Inputs, 0);
+ var skipped = game.Bridge!.NeedsOrders[0];
+ game.Bridge.Skip(skipped);
+
+ UiTestKit.Press(Ui.Q<Button>("settings-language-he"));
+ Assert.IsTrue(Ui.Q("root").ClassListContains(UiLanguage.HebrewClass), "precondition: the UI was rebuilt");
+ Assert.IsTrue(game.Bridge!.IsSkipped(skipped), "the skip is kept");
+ CollectionAssert.DoesNotContain(game.Bridge.NeedsOrders.ToList(), skipped);
+ }
+
/// <summary>A language named in the address or on the command line (the store page's "?lang=he" link) holds for that
/// visit over the stored choice; without one the stored choice holds; with neither, English.</summary>
[Test]
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index 530ca76c4..7cc81e138 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -202,7 +202,7 @@ 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), after the
- /// armistices with Send home queued (#1309: its button and its line), on the turn
+ /// armistices with Send home offered (#1309: its button) and queued (its line, and no other order: #1527's follow-up), 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>
@@ -214,13 +214,15 @@ 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", "info-send-home", "holding", "info-attack" })
+ foreach (var state in new[] { "", "info-move", "info-fortify", "armistice", "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";
+ // "armistice": Send home is offered beside the other orders; "info-send-home": pressed, the unit takes no other order.
+ if (state == "armistice" || state == "info-send-home") foreach (var front in Prisoners.Fronts) g.State.ChosenOptions["armistice_" + front] = "sign";
+ var goingHome = state == "info-send-home";
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)
@@ -232,12 +234,12 @@ 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");
+ if (Shown(move) == goingHome) { problems.Add($"{at}: precondition: the Move button shows unless the unit is going home"); return; }
+ if (Shown(root.Q<Button>("info-send-home")) != (state == "armistice")) 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.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 (Shown(root.Q<Button>("info-hold")) == (state == "holding" || goingHome)) problems.Add($"{at}: precondition: Hold shows only while it is not held and the unit is not going home");
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)))
{
diff --git a/unity/Assets/Tests/EditMode/SimBridgeGddTests.cs b/unity/Assets/Tests/EditMode/SimBridgeGddTests.cs
index a8de063df..e6b957502 100644
--- a/unity/Assets/Tests/EditMode/SimBridgeGddTests.cs
+++ b/unity/Assets/Tests/EditMode/SimBridgeGddTests.cs
@@ -75,6 +75,37 @@ public class SimBridgeGddTests
Assert.IsEmpty(bridge.Session.Committed);
}
+ /// <summary>Codex's review of #1527, finding 3: Send home queued first, a deferred order for the unit (Reinforce, the
+ /// one a soldier can take) is refused like an instant one, and only Send home stays queued.</summary>
+ [Test]
+ public void SendHomeThenReinforceRefusesTheReinforcement()
+ {
+ var bridge = new SimBridge(GameSession.New(Slice, GoldenRun.Seed, Mode.Historical), Text);
+ var unit = bridge.NeedsOrders[0];
+ var home = new UnitOrder(unit, Demobilization.SendHome);
+ Assert.IsNull(bridge.Queue(home));
+ Assert.AreEqual(Text["order.going_home"], bridge.Queue(new Reinforce(unit, "tel_aviv", 1)));
+ CollectionAssert.AreEqual(new Command[] { home }, bridge.Queued.ToList());
+ }
+
+ /// <summary>Codex's review of #1527, finding 3, the other order: Reinforce queued first, Send home takes the unit's
+ /// place in the queue. The reinforcement is withdrawn and its Attention refunded, so End turn never trains replacements
+ /// for a unit that goes home in the same turn.</summary>
+ [Test]
+ public void ReinforceThenSendHomeWithdrawsTheReinforcement()
+ {
+ var bridge = new SimBridge(GameSession.New(Slice, GoldenRun.Seed, Mode.Historical), Text);
+ var unit = bridge.NeedsOrders[0]; var other = bridge.NeedsOrders[1];
+ var start = bridge.AttentionLeft;
+ var kept = new Reinforce(other, "tel_aviv", 1);
+ Assert.IsNull(bridge.Queue(new Reinforce(unit, "tel_aviv", 1)));
+ Assert.IsNull(bridge.Queue(kept));
+ var home = new UnitOrder(unit, Demobilization.SendHome);
+ Assert.IsNull(bridge.Queue(home));
+ CollectionAssert.AreEqual(new Command[] { kept, home }, bridge.Queued.ToList(), "the other unit's order stays");
+ Assert.AreEqual(start - bridge.Price(kept) - bridge.Price(home), bridge.AttentionLeft, 1e-9, "the withdrawn order is refunded");
+ }
+
[Test]
public void SkippedUnitsAndUnitsGoingHomeDoNotNeedOrders()
{
diff --git a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs
index 19c501be6..f19c0e82e 100644
--- a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs
@@ -423,6 +423,34 @@ public class UnitOrdersTests
}
}
+ /// <summary>Codex's review of #1527, finding 3, on the card: once Send home is queued for a unit, the card offers it no
+ /// other order (Move, Fortify, Hold, Attack, Reinforce, Skip, nor Send home again) and says the unit goes home.</summary>
+ [Test]
+ public void AUnitGoingHomeIsOfferedNoOtherOrder()
+ {
+ using var ui = new UiTestKit();
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ var bridge = new SimBridge(g, Text);
+ var token = UnitRoster.FromState(Units, C, g.State, _ => true, (row, a, q, r) => a).Single(x => x.Unit.Id == "golani");
+ var id = UnitCard.SimUnit(C, g.State, token.Unit)!.Value;
+ var u = g.State.Units[id];
+ var city = C.SettlementHexes.Single(h => h.Id == "tel_aviv");
+ g.State.Units[id] = new Unit(u.Id, u.Type, city.Q, city.R, u.Service, u.Side, u.Strength - 2, u.Order, u.OrderTarget, u.HomeCity, u.Strength);
+ g.State.Arms = 100;
+ PlacedToken? selected = new PlacedToken(token, new AnchorSpot(0, 0, 0, 0, false));
+ var info = new InfoPanelPresenter(ui.Root, bridge, Text, new Dictionary<string, string>(), selectedUnit: () => selected);
+ var orders = new[] { "info-move", "info-fortify", "info-hold", "info-reinforce", "info-skip" }.Select(n => ui.Q<Button>(n)).ToList();
+ info.ShowUnit();
+ foreach (var b in orders) Assert.IsTrue(Shown(b), $"precondition: {b.name} is offered");
+
+ Assert.IsNull(bridge.Queue(new UnitOrder(id, Demobilization.SendHome)));
+ info.ShowUnit();
+ foreach (var b in orders.Append(ui.Q<Button>("info-attack")).Append(ui.Q<Button>("info-send-home")))
+ Assert.IsFalse(Shown(b), $"{b.name} is not offered to a unit going home");
+ StringAssert.Contains(Text["unit.send_home_queued"], ui.Q<Label>("info-settlements").text, "the card says it goes home");
+ 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/Tests/EditMode/WhyUnitNamesTests.cs b/unity/Assets/Tests/EditMode/WhyUnitNamesTests.cs
index 0eec1b257..28f73c056 100644
--- a/unity/Assets/Tests/EditMode/WhyUnitNamesTests.cs
+++ b/unity/Assets/Tests/EditMode/WhyUnitNamesTests.cs
@@ -40,6 +40,72 @@ public class WhyUnitNamesTests
StringAssert.DoesNotContain(raised.Id.ToString(), name);
}
+ /// <summary>Every unit the Why lines can name: each starting force (Israel's brigades and every Arab force, by its row),
+ /// and each type a unit of Israel's is raised as in play (recruits, veterans, the guns, the armoured cars and the halutz
+ /// groups, which have no row), with a home city and without one.</summary>
+ static IEnumerable<UnitRef> EveryUnit(GameState s)
+ {
+ foreach (var id in Enumerable.Range(0, C.StartingForces.Count).Where(s.Units.ContainsKey)) yield return new UnitRef(s.Units[id]);
+ foreach (var type in C.UnitTypes.Where(t => t.Kind == "unit" && (t.Side == "" || t.Side == Movement.PlayerSide)))
+ foreach (var home in new[] { "tel_aviv", "" })
+ yield return new UnitRef(new Unit(s.NextId, type.Id, 0, 0, side: type.Side, strength: 2, homeCity: home));
+ }
+
+ /// <summary>Each line's values after its unit names, as the sim gives them (UnitLines.Line and the engagement's own).</summary>
+ static string[] Args(string key) => key switch
+ {
+ WhyKeys.UnitMoved => new[] { "5,5", "2" },
+ WhyKeys.AttackCalledOff => new[] { "5,5", "2", "1" },
+ WhyKeys.Engagement => new[] { "5,5", "80", "10", "20", "1" },
+ WhyKeys.Destroyed => new string[0],
+ WhyKeys.SurrenderedPrisoners => new[] { "300" },
+ WhyKeys.SurrenderedHeld => new[] { "300" },
+ WhyKeys.SentHome => new[] { "300", "tel_aviv" },
+ WhyKeys.Withdrew => new[] { "tel_aviv", "5,5" },
+ _ => new[] { "5,5" },
+ };
+
+ /// <summary>Codex's review of #1527, finding 2: a unit's name never meets a verb or pronoun that fits only some names.
+ /// English: every name is singular, as the lines' verbs are ("was destroyed", "its people"); a raised unit is named as one
+ /// formation, never by a plural type label ("Recruits"). Hebrew: the lines agree with no name's gender or number (HE-15 in
+ /// docs/WRITING_UI_HE.md; the Arab forces' names are masculine, Israel's feminine, the type labels plural): the name
+ /// opens the line as its label ("{0}: ..."), or sits in a noun phrase ("ההתקפה של {0}", the engagement's brackets), or
+ /// is followed by no verb ("{0} בדרך"). Every unit, through every line, in both languages.</summary>
+ [Test]
+ public void EveryUnitReadsGrammaticallyInEveryLineInBothLanguages()
+ {
+ var s = Simulation.NewGame(C, GoldenRun.Seed, Mode.Historical);
+ var en = En; var he = He; var rows = Rows; // each property parses its file again: once here, not per line
+ var enemy = new UnitRef(s.Units.Values.First(u => u.Side != "" && u.Side != Movement.PlayerSide));
+ var plurals = new[] { "city.track_recruit", "unit.type.veteran_soldier", "city.track_armoured_car", "city.track_halutz" }.Select(k => en[k]).ToList();
+ var checkedLines = 0;
+ foreach (var unit in EveryUnit(s))
+ {
+ var english = UnitNames.Of(unit, C, rows, en);
+ Assert.IsFalse(plurals.Any(p => english.StartsWith(p, System.StringComparison.Ordinal)), $"{unit.Type}: '{english}' is plural");
+ // Every line, and a one-point move too (why.line.unit_moved_one, #1633).
+ foreach (var (key, args) in WhyKeys.All.Select(k => (k, Args(k))).Append((WhyKeys.UnitMoved, new[] { "5,5", "1" })))
+ {
+ var units = key == WhyKeys.Engagement ? new[] { unit, enemy } : new[] { unit };
+ var cause = new Cause("map", "0", 0, "fallback", key: key, units: units, args: args);
+ foreach (var text in new[] { en, he })
+ {
+ var name = UnitNames.Of(unit, C, rows, text);
+ StringAssert.DoesNotContain(unit.Type, name, $"{unit.Type} has a name in {text["ui.lang"]}");
+ var line = UnitNames.Line(cause, C, rows, text).Replace(UiText.LeftToRightMark.ToString(), ""); // the marks around a Latin value
+ StringAssert.Contains(name, line, key);
+ StringAssert.DoesNotContain("{", line, key);
+ if (text == he)
+ Assert.IsTrue(line.StartsWith(name + ": ", System.StringComparison.Ordinal) || line.Contains("של " + name)
+ || key == WhyKeys.Engagement || key == WhyKeys.OnItsWay && line.StartsWith(name + " בדרך ", System.StringComparison.Ordinal),
+ $"{key}: no verb may agree with '{name}': {line}");
+ checkedLines++;
+ }
+ }
+ }
+ Assert.Greater(checkedLines, 0);
+ }
+
[Test]
public void AMoveLineHasNoSimNumberInEitherLanguage()
{
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 70b85b39e..d533b74cf 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -517,6 +517,14 @@ unit.draft_wikipedia: "Draft: from Wikipedia only, not yet checked against a pub
unit.draft: "Draft: not yet checked by a historian"
unit.defence: "Open the Defence screen"
unit.raised_name: "{0}, {1}"
+# A unit raised in play, named as one formation in the Why lines and toasts ({0} of unit.raised_name): singular, as the
+# lines' verbs are ("was destroyed", "its people"), never the type's plural label (Codex's review of #1527).
+unit.name.recruit: "Recruit unit"
+unit.name.veteran_soldier: "Veteran soldier unit"
+unit.name.artillery: "Artillery unit"
+unit.name.armoured_car: "Armoured car unit"
+unit.name.halutz: "Halutz group"
+unit.name.veteran_halutz: "Veteran halutz group"
# 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 now, or another hex to send the unit there over several turns"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index f120af9f6..cc27975cf 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -308,28 +308,30 @@ why.effects: "השפעות מתמשכות"
why.situations: "מצבים"
why.other: "אחר"
why.nothing: "לא קרה דבר ראוי לציון בתור הזה."
-# Hebrew drafts for the structured unit Why lines (#1399); native review pending (#564).
-why.line.unit_moved: "{0} נעה למשושה {1} תמורת {2} נקודות תנועה"
-why.line.unit_moved_one: "{0} נעה למשושה {1} תמורת נקודת תנועה אחת"
-why.line.fortify_lost: "{0} עזבה את משושה {1} ואינה מבוצרת עוד"
-why.line.fortifying: "{0} מתבצרת במשושה {1}; היא תהיה מבוצרת מסוף התור"
-why.line.holds: "{0} מחזיקה במשושה {1}"
+# Hebrew drafts for the structured unit Why lines (#1399); native review pending (#564). HE-15: {0} is any unit's name, the
+# Arab forces' masculine, Israel's feminine and a raised unit's, so no verb or pronoun agrees with it: the name opens the
+# line as its label ("{0}: ..."), or sits in a noun phrase (Codex's review of #1527).
+why.line.unit_moved: "{0}: תנועה למשושה {1} תמורת {2} נקודות תנועה"
+why.line.unit_moved_one: "{0}: תנועה למשושה {1} תמורת נקודת תנועה אחת"
+why.line.fortify_lost: "{0}: יציאה ממשושה {1}, והביצור שם אבד"
+why.line.fortifying: "{0}: התבצרות במשושה {1}; הביצור חל מסוף התור"
+why.line.holds: "{0}: החזקה במשושה {1}"
why.line.attack_ended_truce: "ההתקפה של {0} על משושה {1} מסתיימת: שביתת נשק בתוקף"
-why.line.attack_ordered: "{0} תתקוף את משושה {1}"
+why.line.attack_ordered: "{0}: פקודת התקפה על משושה {1}"
why.line.attack_ended: "ההתקפה של {0} על משושה {1} מסתיימת: אין שם יחידת אויב"
-why.line.holds_fire: "{0} אינה יורה: אין התקפה על משושה {1} לתמוך בה"
+why.line.holds_fire: "{0}: ללא ירי, כי אין התקפה על משושה {1} לתמוך בה"
why.line.attack_called_off: "ההתקפה של {0} על משושה {1} מבוטלת: נדרשים {2} כלי נשק ובמלאי יש {3}"
why.line.engagement: "ההתקפה על משושה {2} ({0} נגד {1}, יחס כוחות {3}%): התוקפים איבדו {4:N0} איש והמגינים איבדו {5:N0} איש"
-why.line.destroyed: "{0} הושמדה"
-why.line.retreated: "{0} נסוגה למשושה {1}"
-why.line.surrendered_prisoners: "{0} נכנעה עם {1:N0} איש: לא היה לה משושה לסגת אליו. הם מוחזקים כשבויים"
-why.line.surrendered_held: "{0} נכנעה עם {1:N0} איש: לא היה לה משושה לסגת אליו. הם מוחזקים בידי האויב"
-why.line.sent_home: "{0} נשלחת הביתה: {1:N0} אנשיה הם כעת אזרחים ב־{2}"
-why.line.withdrew: "{0} נסוגה מ־{1} למשושה {2}"
+why.line.destroyed: "{0}: היחידה הושמדה"
+why.line.retreated: "{0}: נסיגה למשושה {1}"
+why.line.surrendered_prisoners: "{0}: כניעה עם {1:N0} איש, כי לא היה משושה לסגת אליו. הם מוחזקים כשבויים"
+why.line.surrendered_held: "{0}: כניעה עם {1:N0} איש, כי לא היה משושה לסגת אליו. הם מוחזקים בידי האויב"
+why.line.sent_home: "{0}: שחרור הביתה; {1:N0} איש הם כעת אזרחים ב־{2}"
+why.line.withdrew: "{0}: נסיגה מ־{1} למשושה {2}"
why.line.on_its_way: "{0} בדרך למשושה {1}"
-why.line.stopped_no_route: "{0} נעצרה: אין מסלול שמגיע למשושה {1}"
-why.line.stopped_full: "{0} נעצרה: משושה {1} מלא"
-why.line.arrived: "{0} הגיעה למשושה {1}"
+why.line.stopped_no_route: "{0}: עצירה, כי אין מסלול שמגיע למשושה {1}"
+why.line.stopped_full: "{0}: עצירה, כי משושה {1} מלא"
+why.line.arrived: "{0}: הגעה למשושה {1}"
# A hex in the unit lines (HexPlaces), after the lines' "משושה": a settlement's hex is its name alone ("משושה חיפה"); any
# other hex is said from the nearest settlement, {0} the km (to the nearest 5), {1} the compass point, {2} the settlement,
# with a maqaf after the prefix as in why.line.sent_home. Agent-drafted Hebrew; native review pending (#564).
@@ -538,6 +540,14 @@ unit.draft: "טיוטה: טרם נבדק בידי היסטוריון"
unit.defence: "פתיחת מסך הביטחון"
# Hebrew draft for a raised unit's type and home city (#1399); native review pending (#564).
unit.raised_name: "{0}, {1}"
+# A unit raised in play, named as one formation in the Why lines and toasts (Codex's review of #1527): agent-drafted Hebrew,
+# native review pending (#564). יחידת as the UI's "היחידה"; קבוצת חלוצים as site.group.
+unit.name.recruit: "יחידת מגויסים"
+unit.name.veteran_soldier: "יחידת חיילים ותיקים"
+unit.name.artillery: "יחידת ארטילריה"
+unit.name.armoured_car: "יחידת שריוניות"
+unit.name.halutz: "קבוצת חלוצים"
+unit.name.veteran_halutz: "קבוצת חלוצים ותיקים"
# The unit card's Move order (#754): the order's name is Q-UI-2's, approved by the owner (#375).
unit.order.move: "תנועה"
# Hebrew route draft for #1398; native review pending (#564).