A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Unit card: direction marks around Latin names in a Hebrew sector (Refs #2735 item 3) (#2793)
Beridc5334df7307
diff --git a/changelog.d/2735-sector-latin-marks.md b/changelog.d/2735-sector-latin-marks.mdnew file mode 100644index 000000000..8fe0f52f1--- /dev/null+++ b/changelog.d/2735-sector-latin-marks.md@@ -0,0 +1,4 @@+### Fixed++- On the Hebrew unit card, a Latin name inside the Hebrew sector line (HMCS Norsyd, HMCS Beauharnois, CIA) now sits+ between left-to-right marks, so it stays one run in the right-to-left line (Refs #2735, item 3).diff --git a/unity/Assets/Scripts/UI/UnitCard.cs b/unity/Assets/Scripts/UI/UnitCard.csindex f582656f5..d92c9c5f9 100644--- a/unity/Assets/Scripts/UI/UnitCard.cs+++ b/unity/Assets/Scripts/UI/UnitCard.cs@@ -3,6 +3,7 @@ using System;using System.Collections.Generic;using System.Globalization;using System.Linq;+using System.Text.RegularExpressions;using Statecraft.Game.Map.Units;using Statecraft.Sim;@@ -45,6 +46,9 @@ namespace Statecraft.Game.UI_ => null,};+ /// <summary>A run of Latin words: from a Latin letter to the last Latin letter or digit, across spaces and . ' & -.</summary>+ static readonly Regex LatinRun = new Regex(@"[A-Za-z][A-Za-z0-9]*(?:[ .'&-]+[A-Za-z][A-Za-z0-9]*)*", RegexOptions.CultureInvariant);+public static UnitCard For(PlacedToken placed, GameState state, UiText text, bool gddLoop = false, Content? content = null,IReadOnlyDictionary<string, string>? settlementNamesHe = null){@@ -89,7 +93,11 @@ namespace Statecraft.Game.UIif (!string.IsNullOrEmpty(u.Formed)) lines.Add(text.Format("unit.formed", Local(When(u.Formed!), u.FormedHe)));// The English decides whether the line exists: a Hebrew commander never adds one (owner, #558).if (!string.IsNullOrEmpty(u.FirstCommander)) lines.Add(text.Format("unit.commander", Local(u.FirstCommander!, u.FirstCommanderHe)));- if (!t.Raised) lines.Add(Local(u.Sector, u.SectorHe)); // a raised unit has no sourced sector+ // A raised unit has no sourced sector. A Hebrew sector can name a ship or an agency in Latin ("HMCS Norsyd",+ // "CIA"): each Latin run goes between left-to-right marks, as UiText.Format marks an inserted value (#543), so+ // it stays one run in the right-to-left line (HE-09, #2735). Format alone would not: it leaves Hebrew values alone.+ if (!t.Raised) lines.Add(hebrew && !string.IsNullOrEmpty(u.SectorHe)+ ? LatinRun.Replace(u.SectorHe!, UiText.LeftToRightMark + "$0" + UiText.LeftToRightMark) : u.Sector);// Israel's call-up and security level set only Israel's tokens; an Arab force's token reflects neither (#665).var national = u.Side != UnitData.Israel ? "": !gddLoop ? text.Format("unit.national", PlayerText.Percent(state.Mobilization), state.Rung)diff --git a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs b/unity/Assets/Tests/EditMode/UnitsInPlayTests.csindex cc58b3cad..e74c20fd1 100644--- a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs+++ b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs@@ -1159,6 +1159,25 @@ public class UnitsInPlayTests}}+ /// <summary>#2735 item 3 (HE-09): a Latin name inside a Hebrew sector goes between left-to-right marks on the Hebrew+ /// card, so it stays one run in the right-to-left line; the Hebrew text is otherwise as written, and the English card+ /// keeps its sector unmarked.</summary>+ [TestCase("ins_haganah", "HMCS Norsyd")]+ [TestCase("ins_wedgwood", "HMCS Beauharnois")]+ [TestCase("lebanese_army", "CIA")]+ public void TheHebrewCardMarksALatinNameInsideAHebrewSector(string id, string latin)+ {+ var u = Units.Single(x => x.Id == id);+ var placed = new PlacedToken(new UnitToken(u, u.Anchors.FirstOrDefault() ?? new UnitAnchor(), 0, "", false), default);+ var state = StateAt(C.Rules.Start, 5, 0.8);+ // Ordinal: NUnit's StringAssert compares by culture, which ignores U+200E, so it would pass with no marks at all.+ var body = UnitCard.For(placed, state, He).Body;+ Assert.IsTrue(body.Contains(u.SectorHe!.Replace(latin, "\u200E" + latin + "\u200E"), StringComparison.Ordinal), body);+ var english = UnitCard.For(placed, state, Text).Body;+ Assert.IsTrue(english.Contains(u.Sector, StringComparison.Ordinal), english);+ Assert.IsFalse(english.Contains("\u200E", StringComparison.Ordinal), english);+ }+[Test]public void AUnitWithNoHebrewNameKeepsItsEnglishNameInTheHebrewCard(){