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.

Why lines: the Israel Bonds Debt line reads as its Money effect in the Money row (Fixes #2558) (#2584)

Beri231c91b81cf4
diff --git a/changelog.d/2558-bonds-money-row.md b/changelog.d/2558-bonds-money-row.md
new file mode 100644
index 000000000..7e5a21c32
--- /dev/null
+++ b/changelog.d/2558-bonds-money-row.md
@@ -0,0 +1,5 @@
+### Fixed
+
+- Under gdd-0.3, the Money row of the turn report and the Money meter tip now show the Israel Bonds Debt line as its
+ effect on Money, "Money IL -18.6m (Israel Bonds)", in English and Hebrew. Before, it read "Debt IL +18.6m (Israel
+ Bonds)", which looked like a gain beside the Money lines (Fixes #2558). The Why screen still lists it as Debt.
diff --git a/sim/Statecraft.Sim.Tests/Gdd03EventRulesTests.cs b/sim/Statecraft.Sim.Tests/Gdd03EventRulesTests.cs
index 79c55deb8..35556ef75 100644
--- a/sim/Statecraft.Sim.Tests/Gdd03EventRulesTests.cs
+++ b/sim/Statecraft.Sim.Tests/Gdd03EventRulesTests.cs
@@ -520,6 +520,25 @@ public class Gdd03EventRulesTests
Assert.Equal(new DateTime(1951, 3, 15), CardDate("iraqi_exodus"));
Assert.Equal(new DateTime(1951, 11, 15), CardDate("forex_crisis_1951"));
}
+ // #2558: in the Money row the launch's Debt line reads as its Money effect, Money IL -18.6m, not as a Debt gain; the
+ // title and its Hebrew stay in the Args, so CauseText words it from why.cause.event_amount_from in both languages.
+ // Any other line is passed through as it is.
+ [Fact]
+ public void IsraelBondsDebtLineReadsAsItsMoneyEffectInTheMoneyRow()
+ {
+ var c = Real(true);
+ var s = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);
+ s.Date = new DateTime(1951, 5, 15); s.PendingEvents.Add("israel_bonds");
+ var why = new List<Cause>();
+ Assert.Null(EventSystem.Choose(c, s, "israel_bonds", "launch", why));
+ var debt = why.Single(x => x.Target == "debt" && x.Key == CauseKeys.EventAmount);
+ var line = EconomySystem.MoneyLine(c, debt);
+ Assert.Equal(("treasury", CauseKeys.EventAmount, "Money IL -18.6m (Israel Bonds)"), (line.Target, line.Key, line.Message));
+ Assert.Equal(EconomySystem.MoneyDelta(debt), line.Delta, 12);
+ Assert.Equal(debt.Args, line.Args);
+ Assert.True(EconomySystem.MovesMoney(line));
+ foreach (var other in why.Where(x => x != debt)) Assert.Same(other, EconomySystem.MoneyLine(c, other));
+ }
static readonly string[] SourceBytes =
{
"absorb_immigrants:95682d1835e8de59e3e69f56a9beb13ddf91447270a672d23eaff2523898fea1", // re-pinned for #1065 (reviewer comment matches the text), then for the stale reviewer comment (comment-only)
diff --git a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
index 39da67f7b..a66cc0372 100644
--- a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
+++ b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
@@ -116,7 +116,7 @@ public class RemainingCauseKeysTests
sites++;
}
}
- Assert.Equal(125, sites); // 125 with #1711's CityHeld (R-CITY-010); 124 with #2534's enemy attack-order line (Combat.Give marks the order's own cause); 123 with #2471's gdd-0.3 field Food line (R-FIELD-002); 122 with #2527's FoodImported and the conversion's fx_reserves line; 120 with #2457's event Debt line (R-EFX-009); 119 with #1700 slice B's ProjectBuilderFreed; 118 with #1700's builders (R-CITY-011: two ProjectBuilder lines, ProjectWaiting, the build order's job-default line); 114 with #1703's gdd-0.3 housing surcharge and housing cohesion lines; 112 with the arms workshops' five (R-ARMS-005 with its job-default line, R-ARMS-006; #1701); 107 with R-MONEY-004's DollarsConverted (#813); 106 since #2212: EconomySystem.OtherMoney's line (105 since #2199: PayOrBorrow's Paid line)
+ Assert.Equal(126, sites); // 126 with #2558: EconomySystem.MoneyLine, the event Debt line worded for the Money row; 125 with #1711's CityHeld (R-CITY-010); 124 with #2534's enemy attack-order line (Combat.Give marks the order's own cause); 123 with #2471's gdd-0.3 field Food line (R-FIELD-002); 122 with #2527's FoodImported and the conversion's fx_reserves line; 120 with #2457's event Debt line (R-EFX-009); 119 with #1700 slice B's ProjectBuilderFreed; 118 with #1700's builders (R-CITY-011: two ProjectBuilder lines, ProjectWaiting, the build order's job-default line); 114 with #1703's gdd-0.3 housing surcharge and housing cohesion lines; 112 with the arms workshops' five (R-ARMS-005 with its job-default line, R-ARMS-006; #1701); 107 with R-MONEY-004's DollarsConverted (#813); 106 since #2212: EconomySystem.OtherMoney's line (105 since #2199: PayOrBorrow's Paid line)
}
[Fact]
diff --git a/sim/Statecraft.Sim/EconomySystem.cs b/sim/Statecraft.Sim/EconomySystem.cs
index 9de5a84e2..417cab0fd 100644
--- a/sim/Statecraft.Sim/EconomySystem.cs
+++ b/sim/Statecraft.Sim/EconomySystem.cs
@@ -48,6 +48,17 @@ namespace Statecraft.Sim
/// <summary>The change a <see cref="MovesMoney"/> line makes to the Money (net): its Delta, negated for a Debt line.</summary>
public static double MoneyDelta(Cause w) => w.Target == "debt" ? -w.Delta : w.Delta;
+ /// <summary>#2558: <paramref name="w"/> as the Money row (HudModel.Causes) words it. An event's Debt line becomes a
+ /// Money line of its <see cref="MoneyDelta"/> with the same key and Args (the event's title), so it reads "Money IL
+ /// -18.6m (Israel Bonds)" and not as a Debt gain beside the Money lines; any other line is returned as it is.</summary>
+ public static Cause MoneyLine(Content c, Cause w)
+ {
+ if (w.Target != "debt" || w.Key != CauseKeys.EventAmount) return w;
+ var delta = MoneyDelta(w);
+ // "events" as a literal (every event_amount Debt line is EventSystem's), so WhyScreenTests' source scan sees it.
+ return new Cause("events", "treasury", delta, $"{PlayerText.Change(c, "treasury", delta)} ({w.Args[0]})", key: w.Key, args: w.Args);
+ }
+
/// <summary>#2212: the one Money line for the causes a list leaves out. The turn report and the meter tip show the
/// largest Money causes (HudModel.Causes, at most HudModel.MaxCauses); this is the sum of the turn's other lines
/// <see cref="MovesMoney"/> picks (<paramref name="why"/> minus <paramref name="shown"/>, by reference), so the lines
diff --git a/unity/Assets/Scripts/UI/HudModel.cs b/unity/Assets/Scripts/UI/HudModel.cs
index 235358af5..d4e35386b 100644
--- a/unity/Assets/Scripts/UI/HudModel.cs
+++ b/unity/Assets/Scripts/UI/HudModel.cs
@@ -64,7 +64,8 @@ namespace Statecraft.Game.UI
/// fx_reserves; Security: security). Public support is an average the sim computes from the indicators
/// (EffectsSystem.Approval) and no cause names it, so it has none. Money adds one line after them for the causes
/// left out, summed by the sim (EconomySystem.OtherMoney, #2212), so its lines add up to the change; none when
- /// nothing is left over or the rest shows as IL 0.0m. <paramref name="c"/> is the game's content (its currency).</summary>
+ /// nothing is left over or the rest shows as IL 0.0m. An event's Debt line is worded there as its Money effect
+ /// (EconomySystem.MoneyLine, #2558). <paramref name="c"/> is the game's content (its currency).</summary>
public static IReadOnlyList<string> Causes(StepResult? turn, string meter, Content c, Func<Cause, string> line)
{
if (turn == null) return Array.Empty<string>();
@@ -81,7 +82,9 @@ namespace Statecraft.Game.UI
var shown = turn.Why.Select((w, i) => (w, i)).Where(x => match(x.w) && x.w.Delta != 0)
.OrderByDescending(x => Math.Abs(x.w.Delta)).ThenBy(x => x.i).Take(MaxCauses).Select(x => x.w).ToList();
if (meter == "treasury" && EconomySystem.OtherMoney(c, turn.Why, shown) is Cause other) shown.Add(other);
- return shown.Select(line).ToList();
+ // #2558: in the Money row an event's Debt line is worded as its Money effect (EconomySystem.MoneyLine), after
+ // OtherMoney, which matches the turn's own lines by reference.
+ return shown.Select(w => line(meter == "treasury" ? EconomySystem.MoneyLine(c, w) : w)).ToList();
}
public static HudModel From(SimBridge b, UiText t)
diff --git a/unity/Assets/Tests/EditMode/CauseTextTests.cs b/unity/Assets/Tests/EditMode/CauseTextTests.cs
index 6f3b1c92d..619b33ef7 100644
--- a/unity/Assets/Tests/EditMode/CauseTextTests.cs
+++ b/unity/Assets/Tests/EditMode/CauseTextTests.cs
@@ -268,6 +268,25 @@ public class CauseTextTests
AssertHebrew(he, debt.Key);
}
+ /// <summary>#2558: in the Money row (the turn report and the Money meter tip, HudModel.Causes) the Israel Bonds Debt
+ /// line reads as its Money effect (EconomySystem.MoneyLine), not as a Debt gain: "Money IL -18.6m (Israel Bonds)" in
+ /// English, and in Hebrew כסף with the same change and the Hebrew title, without חוב.</summary>
+ [Test]
+ public void TheEventDebtLineReadsAsItsMoneyEffectInTheMoneyRow()
+ {
+ var debt = new Cause("events", "debt", 18.564, $"{PlayerText.Change(C, "debt", 18.564)} (Israel Bonds)",
+ key: CauseKeys.EventAmount, args: new[] { "Israel Bonds", "מלווה העצמאות" });
+ var turn = new StepResult(new GameState(), new List<Cause> { debt }, new Rejection[0]);
+ CollectionAssert.AreEqual(new[] { "Money IL -18.6m (Israel Bonds)" },
+ HudModel.Causes(turn, "treasury", C, w => CauseText.Line(w, C, NoRows, En)));
+ var he = HudModel.Causes(turn, "treasury", C, w => CauseText.Line(w, C, NoRows, He)).Single();
+ StringAssert.Contains("כסף", he);
+ StringAssert.Contains(PlayerText.MoneyChange(C, "treasury", -18.564), he);
+ StringAssert.Contains("מלווה העצמאות", he);
+ StringAssert.DoesNotContain("חוב", he);
+ AssertHebrew(he, debt.Key);
+ }
+
[Test]
public void AResolvedEventUsesItsHistoricalContentSnapshots()
{