A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix: Hebrew turn report and meter tip name settlements in Hebrew (#1684)
Eyal Golan08104c856fed
diff --git a/changelog.d/c193-hebrew-place-names.md b/changelog.d/c193-hebrew-place-names.mdnew file mode 100644index 000000000..a74b94db0--- /dev/null+++ b/changelog.d/c193-hebrew-place-names.md@@ -0,0 +1,3 @@+### Fixed++- Hebrew turn-report and meter explanations use the same sourced settlement names as Why; untranslated names keep the existing English fallback.diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex 83e2f2c4f..60c9c66c9 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -251,7 +251,7 @@ namespace Statecraft.Game.UI// The toast first: the autosave (below) must report a failed write after the toast has shown the turn's refusals.var toast = Own(new ToastPresenter(root, bridge, text));unseenSkipped = () => toast.Show(text["toast.unit_unseen_skipped"]);- Own(new HudPresenter(root, bridge, text, selectUnit: _ => FocusNextUnit()));+ var hudPresenter = Own(new HudPresenter(root, bridge, text, selectUnit: _ => FocusNextUnit()));nav = Own(new ScreenNav(root)); // every screen starts hidden (USS); ScreenNav opens one at a timeOwn(new PointerBlur(root)); // a mouse click leaves no focus fill behind (keyboard keeps it)Own(new FocusScroll(root)); // keyboard focus scrolls its ScrollView to it (a11y H1)@@ -383,6 +383,7 @@ namespace Statecraft.Game.UI.Select(p => UnitCard.For(p, bridge.State, text, bridge.Content.IsGdd, bridge.Content, townNamesHe).Title).FirstOrDefault(),unitDone: FocusNextUnit, showRoute: map.ShowRoute, clearSelection: () => { unitLayer.Select(null); map.ClearSelection(); }));toast.Units = unitData; toast.TownNamesHe = townNamesHe; why.TownNamesHe = townNamesHe;+ report.TownNamesHe = townNamesHe; hudPresenter.TownNamesHe = townNamesHe;// 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.diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.csindex f8f3315cb..1a52e72ac 100644--- a/unity/Assets/Scripts/UI/HudPresenter.cs+++ b/unity/Assets/Scripts/UI/HudPresenter.cs@@ -122,6 +122,12 @@ namespace Statecraft.Game.UIreadonly HoverTip? railTips, barTips;/// <summary>The meters' explanations under the bar (#1037): their words and the turn's causes.</summary>readonly MeterTip? meterTip;+ /// <summary>Pass the same map names used by Why to the meter causes.</summary>+ public IReadOnlyDictionary<string, string>? TownNamesHe+ {+ get => meterTip?.TownNamesHe;+ set { if (meterTip != null) meterTip.TownNamesHe = value; }+ }/// <summary>The panels under the bar (Statecraft.uss: top 456 px under the three-row bar), which PlaceUnderBar moves/// by what the three-row bar grows past, or shrinks under, its 440 px (#1089).</summary>diff --git a/unity/Assets/Scripts/UI/MeterTip.cs b/unity/Assets/Scripts/UI/MeterTip.csindex 58ef0ef0e..cfa5f2b14 100644--- a/unity/Assets/Scripts/UI/MeterTip.cs+++ b/unity/Assets/Scripts/UI/MeterTip.cs@@ -18,6 +18,8 @@ namespace Statecraft.Game.UIpublic sealed class MeterTip : IDisposable{public const string TipName = "meter-tip";+ /// <summary>Each settlement's Hebrew name (name_he), by id: the map's parse, the same rows Why and the toasts use.</summary>+ public IReadOnlyDictionary<string, string>? TownNamesHe { get; set; }/// <summary>The gap between the tip and the window's edge, and between the meter and the tip.</summary>const float Margin = 8f;@@ -89,7 +91,7 @@ namespace Statecraft.Game.UIpublic (string words, IReadOnlyList<string> causes) Lines(VisualElement meter){var causes = HudModel.Causes(bridge.Session.Last, meter.name.Substring("meter-".Length),- w => CauseText.Line(w, bridge.Content, Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), text)); // no meter counts a unit line+ w => CauseText.Line(w, bridge.Content, Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), text, TownNamesHe)); // no meter counts a unit linereturn causes.Count == 0 ? (meter.tooltip, causes) : (meter.tooltip + "\n" + text["hud.causes"], causes);}diff --git a/unity/Assets/Scripts/UI/TurnReportPresenter.cs b/unity/Assets/Scripts/UI/TurnReportPresenter.csindex 3d3d40b33..d802594e9 100644--- a/unity/Assets/Scripts/UI/TurnReportPresenter.cs+++ b/unity/Assets/Scripts/UI/TurnReportPresenter.cs@@ -29,6 +29,8 @@ namespace Statecraft.Game.UI/// <summary>The units_1948.yaml rows, which name the enemy's units in that row (GameRoot sets them once the map has read/// them); without a row a unit is named by its id (report.unit).</summary>public IReadOnlyList<UnitEntry>? Units { get; set; }+ /// <summary>Each settlement's Hebrew name (name_he), by id: the map's parse, the same rows Why and the toasts use.</summary>+ public IReadOnlyDictionary<string, string>? TownNamesHe { get; set; }readonly VisualElement hudRoot, report; readonly ScrollView rows; readonly SimBridge bridge; readonly UiText text;readonly ScreenNav nav; readonly Button close, all;@@ -94,7 +96,8 @@ namespace Statecraft.Game.UI/// <summary>The report's lines for the session's last turn: each top-bar meter whose shown change is not empty, in/// the bar's order (the meters have different units, so no order by size is given without a rule); then, under/// <see cref="EnemyRow"/>, the enemy's orders (#1293).</summary>- public static IReadOnlyList<Line> Lines(SimBridge bridge, UiText text, IReadOnlyList<UnitEntry>? units = null)+ public static IReadOnlyList<Line> Lines(SimBridge bridge, UiText text, IReadOnlyList<UnitEntry>? units = null,+ IReadOnlyDictionary<string, string>? townNamesHe = null){var m = HudModel.From(bridge, text); var lines = new List<Line>();foreach (var id in HudModel.MeterIds)@@ -103,7 +106,7 @@ namespace Statecraft.Game.UIvar meter = m.For(id);if (meter.Delta.Length == 0) continue;lines.Add(new Line(id, text.Format("report.line", text["hud.caption." + id], meter.Delta), HudModel.Causes(bridge.Session.Last, id,- w => CauseText.Line(w, bridge.Content, units ?? Array.Empty<UnitEntry>(), text))));+ w => CauseText.Line(w, bridge.Content, units ?? Array.Empty<UnitEntry>(), text, townNamesHe))));}var enemy = EnemyOrders(bridge, text, units);if (enemy.Count > 0) lines.Add(new Line(EnemyRow, text["report.enemy"], enemy));@@ -134,7 +137,7 @@ namespace Statecraft.Game.UIvoid Show(){rows.Clear();- foreach (var line in Lines(bridge, text, Units))+ foreach (var line in Lines(bridge, text, Units, TownNamesHe)){var row = new VisualElement { name = "turn-report-" + line.Meter };row.AddToClassList("turn-report-row");diff --git a/unity/Assets/Tests/EditMode/TurnReportTests.cs b/unity/Assets/Tests/EditMode/TurnReportTests.csindex 4229be5b4..1b5b2c6da 100644--- a/unity/Assets/Tests/EditMode/TurnReportTests.cs+++ b/unity/Assets/Tests/EditMode/TurnReportTests.cs@@ -53,6 +53,47 @@ public class TurnReportTestsstatic List<string> Causes(UiTestKit ui, string meter) =>ui.Q<VisualElement>("turn-report-causes-" + meter).Query<Label>(className: "turn-report-cause").ToList().Select(l => l.text).ToList();+ /// <summary>The main B1 occupation/deport borrowing keys use the real map names in report and meter paths too.+ /// This is only a formatter fixture: it does not enable or execute the disabled Deport command.</summary>+ [TestCase(CauseKeys.Purpose.Occupation)]+ [TestCase(CauseKeys.Purpose.Deport)]+ public void ReportAndMeterCausesUseSourcedHebrewPlacesAndKeepEnglishFallback(string purpose)+ {+ const string city = "tel_aviv";+ var namesHe = Statecraft.Game.Map.SettlementPlacer.Parse(+ File.ReadAllText(Path.Combine(Paths.Content, "map", "settlements_1948.yaml")))+ .ToDictionary(s => s.Id, s => s.NameHe);+ Assert.IsTrue(namesHe.ContainsKey(city) && namesHe[city] != "", "sourced map name required");+ using var k = new Kit(He);+ k.Bridge.EndTurn();+ var last = k.Bridge.Session.Last!;+ var why = new List<Cause>();+ var placeName = PlayerText.Settlement(C, city);+ var englishPurpose = purpose == CauseKeys.Purpose.Deport ? $"for the Deport of {placeName}" : $"for the occupation of {placeName}";+ EconomySystem.PayOrBorrow(C, last.State, last.State.Treasury + 3, englishPurpose, why, purpose, city);+ var cause = why.Single();+ Assert.AreEqual(CauseKeys.Borrowed, cause.Key);+ // Existing TurnReportTests uses this setter for a precise report fixture; no simulation input or content is changed.+ typeof(GameSession).GetProperty(nameof(GameSession.Last))!.SetValue(k.Bridge.Session,+ new StepResult(last.State, why, last.Rejected));+ var reportLines = TurnReportPresenter.Lines(k.Bridge, He, null, namesHe)+ .Single(row => row.Meter == "treasury").Causes;+ using var tip = new MeterTip(k.Ui.Root, k.Bridge, He, System.Array.Empty<VisualElement>()) { TownNamesHe = namesHe };+ var meterLines = tip.Lines(k.Q("meter-treasury")).causes;+ foreach (var lines in new[] { reportLines, meterLines })+ {+ Assert.IsNotEmpty(lines);+ var line = string.Join("\n", lines);+ StringAssert.Contains(namesHe[city], line);+ StringAssert.DoesNotContain(placeName, line);+ Assert.IsTrue(UiDirection.RightToLeft(line));+ }+ Assert.AreEqual(cause.Message, CauseText.Line(cause, C, System.Array.Empty<UnitEntry>(), En, namesHe));+ var missingNames = new Dictionary<string, string>();+ StringAssert.Contains(placeName, CauseText.Line(cause, C, System.Array.Empty<UnitEntry>(), He, missingNames),+ "missing name_he retains main's English fallback, never an invented translation");+ }+[Test]public void TheFixedTurnReportsEachChangedNumberWithTheSimsOwnCauses(){