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.

Turn report: the Immigration row says which number is the change and which is this turn's arrivals (Fixes #2576) (#2581)

Eyal Golandde0fdcb1212
diff --git a/changelog.d/2576-immigration-row.md b/changelog.d/2576-immigration-row.md
new file mode 100644
index 000000000..43328e408
--- /dev/null
+++ b/changelog.d/2576-immigration-row.md
@@ -0,0 +1,3 @@
+### Fixed
+
+- Label the Immigration turn-report value and its cause lines as this turn's arrivals while keeping the change since the preceding turn.
diff --git a/unity/Assets/Scripts/UI/HudModel.cs b/unity/Assets/Scripts/UI/HudModel.cs
index f8ee65f8b..235358af5 100644
--- a/unity/Assets/Scripts/UI/HudModel.cs
+++ b/unity/Assets/Scripts/UI/HudModel.cs
@@ -53,9 +53,10 @@ namespace Statecraft.Game.UI
_ => throw new ArgumentOutOfRangeException(nameof(id), id, "not a top-bar meter"),
};
- /// <summary>The main causes of a meter's change in <paramref name="turn"/> (#1037): the sim's own causes
- /// (StepResult.Why) for the quantity the meter shows, each worded by <paramref name="line"/> (CauseText.Line: the
- /// player's language, B1), the largest change first (each meter's causes share its unit),
+ /// <summary>The main causes behind a meter in <paramref name="turn"/> (#1037): the sim's own causes
+ /// (StepResult.Why) for the quantity the meter shows. Immigration's causes are this turn's arrivals, not causes of
+ /// the difference from the preceding turn. Each is worded by <paramref name="line"/> (CauseText.Line: the player's
+ /// language, B1), the largest change first (each meter's causes share its unit),
/// the sim's order breaking a tie, at most <see cref="MaxCauses"/>. Nothing is computed or reworded here: a cause is
/// matched by its target, as <see cref="From"/> reads the state (Money: the sim's EconomySystem.MovesMoney, the lines
/// that add up to the change in Treasury minus Debt, job income included and borrowing not, #2199; Immigration: the
diff --git a/unity/Assets/Scripts/UI/MeterTip.cs b/unity/Assets/Scripts/UI/MeterTip.cs
index 7547e7994..99d47483c 100644
--- a/unity/Assets/Scripts/UI/MeterTip.cs
+++ b/unity/Assets/Scripts/UI/MeterTip.cs
@@ -87,15 +87,16 @@ namespace Statecraft.Game.UI
public VisualElement? ShownFor => shownFor;
/// <summary>The tip's lines for <paramref name="meter"/> (an element named "meter-" + a HudModel.MeterIds id): its
- /// words and what the meter is (hud.tip.&lt;id&gt;, #2200), with the causes' heading when there are causes, and the
- /// causes, one a line (none when none).</summary>
+ /// words and what the meter is (hud.tip.&lt;id&gt;, #2200), with the causes' heading when there are causes (for
+ /// Immigration, this turn's arrivals), and the causes, one a line (none when none).</summary>
public (string words, IReadOnlyList<string> causes) Lines(VisualElement meter)
{
var id = meter.name.Substring("meter-".Length);
var causes = HudModel.Causes(bridge.Session.Last, id, bridge.Content,
w => CauseText.Line(w, bridge.Content, Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), text, TownNamesHe)); // no meter counts a unit line
var words = meter.tooltip + "\n" + text["hud.tip." + id]; // the number alone does not say what moves it (#2200)
- return causes.Count == 0 ? (words, causes) : (words + "\n" + text["hud.causes"], causes);
+ var causesHeading = id == "immigration" ? "hud.arrivals_this_turn" : "hud.causes";
+ return causes.Count == 0 ? (words, causes) : (words + "\n" + text[causesHeading], causes);
}
/// <summary>Shows the tip for the hovered meter, else the tapped one, with today's words (HudPresenter.Render calls
diff --git a/unity/Assets/Scripts/UI/TurnReportPresenter.cs b/unity/Assets/Scripts/UI/TurnReportPresenter.cs
index 66c2a3517..b00789c25 100644
--- a/unity/Assets/Scripts/UI/TurnReportPresenter.cs
+++ b/unity/Assets/Scripts/UI/TurnReportPresenter.cs
@@ -92,7 +92,8 @@ namespace Statecraft.Game.UI
/// key already closed the report through the Cancel event), as for OutcomePresenter.ClosedThisFrame.</summary>
public bool ClosedThisFrame => closedAt == UnityEngine.Time.frameCount;
- /// <summary>One line of the report: the meter's id, its caption with the change the bar shows, and its main causes.</summary>
+ /// <summary>One line of the report: the meter's id, its caption with the change the bar shows (and Immigration's
+ /// arrivals this turn), and its main causes.</summary>
public readonly struct Line
{
public readonly string Meter, Heading; public readonly IReadOnlyList<string> Causes;
@@ -111,7 +112,10 @@ namespace Statecraft.Game.UI
if (id == "cohesion" && !m.ShowsCohesion) continue;
var 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, bridge.Content,
+ var heading = id == "immigration"
+ ? text.Format("report.immigration_line", text["hud.caption.immigration"], meter.Delta, meter.Value)
+ : text.Format("report.line", text["hud.caption." + id], meter.Delta);
+ lines.Add(new Line(id, heading, HudModel.Causes(bridge.Session.Last, id, bridge.Content,
w => CauseText.Line(w, bridge.Content, units ?? Array.Empty<UnitEntry>(), text, townNamesHe))));
}
lines.AddRange(StockLines(bridge, text, units, townNamesHe));
diff --git a/unity/Assets/Tests/EditMode/TurnReportTests.cs b/unity/Assets/Tests/EditMode/TurnReportTests.cs
index f65fbec90..50dbf3783 100644
--- a/unity/Assets/Tests/EditMode/TurnReportTests.cs
+++ b/unity/Assets/Tests/EditMode/TurnReportTests.cs
@@ -124,7 +124,11 @@ public class TurnReportTests
{
// The heading is the bar's caption and the very change the bar shows next to the number.
var heading = k.Ui.Q<Label>("turn-report-heading-" + id).text;
- Assert.AreEqual(En.Format("report.line", En["hud.caption." + id], k.Ui.Q<Label>(id + "-delta").text), heading, id);
+ var expectedHeading = id == "immigration"
+ ? En.Format("report.immigration_line", En["hud.caption.immigration"], k.Ui.Q<Label>("immigration-delta").text,
+ k.Ui.Q<Label>("immigration-value").text)
+ : En.Format("report.line", En["hud.caption." + id], k.Ui.Q<Label>(id + "-delta").text);
+ Assert.AreEqual(expectedHeading, heading, id);
var causes = k.Ui.Root.Q("turn-report-causes-" + id);
var expected = HudModel.Causes(turn, id, C, w => CauseText.Line(w, C, System.Array.Empty<UnitEntry>(), En));
if (expected.Count == 0) { Assert.IsNull(causes, id + ": no cause line without a cause"); continue; }
@@ -153,6 +157,54 @@ public class TurnReportTests
Assert.IsNull(k.Ui.Root.Q("turn-report-causes-support"), "no cause names Public support (an average of the indicators)");
}
+ /// <summary>#2576 shape (b): Immigration keeps the change in arrivals as the report's number, while the current
+ /// arrival count and the population lines below it are labelled as this turn's arrivals, in both UI languages.</summary>
+ [Test]
+ public void ImmigrationReportsTheChangeAndLabelsThisTurnsArrivalsInBothLanguages()
+ {
+ foreach (var (text, heading, causesHeading, cause) in new[]
+ {
+ (En, "Immigration: change +20; arrivals this turn: 120", "Main arrivals this turn:", "120 immigrants arrived (Asia)"),
+ (He, "עלייה: שינוי של +20; עולים שהגיעו בתור הזה: 120", "הגעות עיקריות בתור הזה:", "עולים שהגיעו (אסיה): 120"),
+ })
+ {
+ var arrivals = new Queue<double>(new[] { 100d, 120d, 100d });
+ using var k = new Kit(text, (g, cmds) =>
+ {
+ var result = g.EndTurn(cmds);
+ var n = arrivals.Dequeue();
+ var arrival = new Cause("population", "asia", n,
+ System.FormattableString.Invariant($"{n:N0} immigrants arrived (Asia)"), key: CauseKeys.Arrived);
+ var controlled = new StepResult(result.State,
+ result.Why.Where(w => w.System != "population").Concat(new[] { arrival }).ToList(), result.Rejected);
+ typeof(GameSession).GetProperty(nameof(GameSession.Last))!.SetValue(g, controlled);
+ return controlled;
+ });
+
+ k.Bridge.EndTurn();
+ k.Bridge.EndTurn();
+
+ var meter = HudModel.From(k.Bridge, text).Immigration;
+ Assert.AreEqual(text.Format("hud.people", 120), meter.Value);
+ Assert.AreEqual(text.Format("hud.delta_people", 20), meter.Delta);
+ var plain = k.Ui.Q<Label>("turn-report-heading-immigration").text.Replace(UiText.LeftToRightMark.ToString(), "");
+ Assert.AreEqual(heading, plain);
+ var reportCauses = Causes(k.Ui, "immigration");
+ CollectionAssert.AreEqual(new[] { cause }, reportCauses.Select(x => x.Replace(UiText.LeftToRightMark.ToString(), "")).ToList());
+
+ using var tip = new MeterTip(k.Ui.Root, k.Bridge, text, System.Array.Empty<VisualElement>());
+ var tipLines = tip.Lines(k.Q("meter-immigration"));
+ Assert.AreEqual(causesHeading, tipLines.words.Split('\n').Last());
+ CollectionAssert.AreEqual(reportCauses, tipLines.causes, "the report and MeterTip label the same current-turn arrivals");
+
+ // A fall: 120 then 100 reads as a change of -20 beside this turn's 100 arrivals.
+ k.Bridge.EndTurn();
+ var fell = text.Format("report.immigration_line", text["hud.caption.immigration"], text.Format("hud.delta_people", -20),
+ text.Format("hud.people", 100)).Replace(UiText.LeftToRightMark.ToString(), "");
+ Assert.AreEqual(fell, k.Ui.Q<Label>("turn-report-heading-immigration").text.Replace(UiText.LeftToRightMark.ToString(), ""));
+ }
+ }
+
/// <summary>#1293: the opening turn's enemy orders (R-ENEMY-001): the four scripted forces march (R-ENEMY-002) and the
/// others fortify (R-ENEMY-003). After the bar's numbers the report lists each order, in the sim's order, its unit named
/// by its units_1948.yaml row, in the player's language.</summary>
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index ed359baa9..b0a858618 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -23,6 +23,7 @@ hud.say_million: "{0}{1} million"
hud.say_point: "{0:0} point"
hud.say_points: "{0:0} points"
hud.causes: "Main causes this turn:"
+hud.arrivals_this_turn: "Main arrivals this turn:"
# The top-bar captions, as Game.uxml shows them (HudTests.TheSpokenCaptionsAreTheBarsCaptions), for the words above.
hud.caption.treasury: "Money (net)"
hud.caption.immigration: "Immigration"
@@ -499,10 +500,12 @@ why.hex.south: "south"
why.hex.south_west: "south-west"
why.hex.west: "west"
why.hex.north_west: "north-west"
-# The turn report (#1037, TurnReportPresenter): a line is a top-bar caption and the change the bar shows.
+# The turn report (#1037, TurnReportPresenter): a line is a top-bar caption and the change the bar shows; Immigration also
+# labels the current turn's arrivals, whose lines follow it.
report.title: "What happened this turn"
report.intro: "What changed in the top bar, and the main causes:"
report.line: "{0}: {1}"
+report.immigration_line: "{0}: change {1}; arrivals this turn: {2}"
report.all: "See all in Why?"
report.close: "Close"
# The enemy's orders this turn (#1293): one line per order the enemy AI gave (R-ENEMY-001), and one per enemy unit in
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 977c525dc..ce9769074 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -18,6 +18,8 @@ hud.say_million: "{0}{1} מיליון"
hud.say_point: "{0:0} נקודה"
hud.say_points: "{0:0} נקודות"
hud.causes: "הסיבות העיקריות בתור הזה:"
+# For the native reviewer (#564): agent-drafted, #2576
+hud.arrivals_this_turn: "הגעות עיקריות בתור הזה:"
# hud.caption.treasury: Money (R-MONEY-001, Q-MONEY-4); the owner's Hebrew word for it, כסף (Q-HUD-3, 15 October 2026, #375).
hud.caption.treasury: "כסף (נטו)"
hud.caption.immigration: "עלייה"
@@ -577,10 +579,13 @@ why.hex.south: "מדרום"
why.hex.south_west: "מדרום־מערב"
why.hex.west: "ממערב"
why.hex.north_west: "מצפון־מערב"
-# The turn report (#1037, TurnReportPresenter): a line is a top-bar caption and the change the bar shows.
+# The turn report (#1037, TurnReportPresenter): a line is a top-bar caption and the change the bar shows; Immigration also
+# labels the current turn's arrivals, whose lines follow it.
report.title: "מה קרה בתור הזה"
report.intro: "מה השתנה בסרגל העליון, ומה הסיבות העיקריות:"
report.line: "{0}: שינוי של {1}"
+# For the native reviewer (#564): agent-drafted, #2576
+report.immigration_line: "{0}: שינוי של {1}; עולים שהגיעו בתור הזה: {2}"
# The Why screen named in a sentence goes in gershayim: owner, 25 Oct 2026.
report.all: "הכול במסך ״למה?״"
report.close: "סגירה"