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.

Dollars: one DollarsMinimum constant for the conversion refusal and its message (R-MONEY-004) (#2704)

Eyal Golanea390f7f52c3
diff --git a/changelog.d/2704.md b/changelog.d/2704.md
new file mode 100644
index 000000000..3c201149a
--- /dev/null
+++ b/changelog.d/2704.md
@@ -0,0 +1,4 @@
+### Changed
+
+- Behind the scenes: the smallest dollar conversion is one value, which both the refusal and its message read, so
+ they cannot disagree. No gameplay change (Refs #2704).
diff --git a/sim/Statecraft.Sim.Tests/DollarsTests.cs b/sim/Statecraft.Sim.Tests/DollarsTests.cs
index b2acf0734..78db283d7 100644
--- a/sim/Statecraft.Sim.Tests/DollarsTests.cs
+++ b/sim/Statecraft.Sim.Tests/DollarsTests.cs
@@ -25,6 +25,21 @@ public class DollarsTests
static PreviewResult Orders(Content c, GameState s, params Command[] orders) => Simulation.Preview(c, s, orders);
+ // R-MONEY-004: the smallest conversion is EconomySystem.DollarsMinimum (US$1m). The sim refuses below it, the UI words
+ // the refusal from the same constant (SimBridge.ReasonText; DollarConversionTests pins that), and the sim's own English,
+ // a constant tests name in attributes, says the same amount, so none of the three can drift from the others (#2704).
+ [Fact]
+ public void TheConversionMinimumIsOneConstantTheRefusalAndItsWordingShare()
+ {
+ var c = Gdd();
+ var s = War(c);
+ Assert.Equal(EconomySystem.RefusedDollarsMinimum, EconomySystem.DollarsRefusal(c, s, EconomySystem.DollarsMinimum - 1));
+ Assert.NotEqual(EconomySystem.RefusedDollarsMinimum, EconomySystem.DollarsRefusal(c, s, EconomySystem.DollarsMinimum));
+ Assert.Equal(EconomySystem.RefusedDollarsMinimum,
+ string.Format(System.Globalization.CultureInfo.InvariantCulture, "Convert at least ${0}m", EconomySystem.DollarsMinimum));
+ Assert.True(EconomySystem.RefusedDollarsMinimum == "Convert at least $1m", "the sim's English stays byte for byte as it was");
+ }
+
// R-MONEY-004: $3m at IL 0.5 per $ moves IL 1.5m into the Treasury and takes $3m from the reserves, with a cause line.
[Fact]
public void ConvertingMovesTheDollarsTimesTheRateIntoMoney()
diff --git a/sim/Statecraft.Sim/EconomySystem.cs b/sim/Statecraft.Sim/EconomySystem.cs
index f3f7e7828..9de5a84e2 100644
--- a/sim/Statecraft.Sim/EconomySystem.cs
+++ b/sim/Statecraft.Sim/EconomySystem.cs
@@ -10,6 +10,11 @@ namespace Statecraft.Sim
/// <summary>The command kind that converts foreign currency into Money (R-MONEY-004).</summary>
public const string ConvertDollarsKind = "convert_dollars";
+ /// <summary>R-MONEY-004: the smallest conversion, in US$ millions. DollarsRefusal refuses below it and the UI words that
+ /// refusal from it (SimBridge.ReasonText), so the two cannot drift apart (#2704).</summary>
+ public const int DollarsMinimum = 1;
+ /// <summary>The sim's English for a conversion below <see cref="DollarsMinimum"/>. A constant, since tests name it in
+ /// attributes; DollarsTests pins it to DollarsMinimum.</summary>
public const string RefusedDollarsMinimum = "Convert at least $1m";
public const string RefusedDollarsNotAtWar = "Dollars can be converted only during the war";
public const string RefusedDollarsMonthly = "That is more dollars than may be converted this month";
@@ -128,7 +133,7 @@ namespace Statecraft.Sim
public static string? DollarsRefusal(Content c, GameState s, int amount, int thisTurn = 0, int? startRung = null)
{
var r = c.RulesAt(s.Date).Mvp!; // the loader requires the three values in the GDD loop
- if (amount < 1) return RefusedDollarsMinimum;
+ if (amount < DollarsMinimum) return RefusedDollarsMinimum;
if ((startRung ?? s.Rung) < WarRung) return RefusedDollarsNotAtWar;
if ((long)thisTurn + amount > r.DollarsPerTurn!.Value) return RefusedDollarsMonthly;
if ((long)s.DollarsConverted + amount > r.DollarsTotal!.Value) return RefusedDollarsTotal;
diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.cs
index 7037033cc..ea76b55f3 100644
--- a/unity/Assets/Scripts/UI/SimBridge.cs
+++ b/unity/Assets/Scripts/UI/SimBridge.cs
@@ -312,7 +312,7 @@ namespace Statecraft.Game.UI
if (ReasonKeys.TryGetValue(reason, out var key))
{
if (reason != EconomySystem.RefusedDollarsMinimum) return text[key];
- return c == null ? reason : text.Format(key, PlayerText.Money(c, "fx_reserves", 1));
+ return c == null ? reason : text.Format(key, PlayerText.Money(c, "fx_reserves", EconomySystem.DollarsMinimum));
}
foreach (var (pattern, format) in ReasonFormats)
if (pattern.Match(reason) is { Success: true } m)
diff --git a/unity/Assets/Tests/EditMode/DollarConversionTests.cs b/unity/Assets/Tests/EditMode/DollarConversionTests.cs
index 0eaf683c3..532de61e7 100644
--- a/unity/Assets/Tests/EditMode/DollarConversionTests.cs
+++ b/unity/Assets/Tests/EditMode/DollarConversionTests.cs
@@ -200,7 +200,7 @@ public class DollarConversionTests
Assert.AreEqual(EconomySystem.RefusedDollarsMinimum, SimBridge.ReasonText(En, EconomySystem.RefusedDollarsMinimum));
foreach (var reason in refusals)
{
- var money = PlayerText.Money(c, "fx_reserves", 1);
+ var money = PlayerText.Money(c, "fx_reserves", EconomySystem.DollarsMinimum); // the constant the sim refuses on (#2704)
var expected = reason == EconomySystem.RefusedDollarsMinimum ? En.Format("dollars.refused_minimum", money) : reason;
Assert.AreEqual(expected, SimBridge.ReasonText(En, reason, c), "the English string uses the sim's words and formatted money");
var he = SimBridge.ReasonText(He, reason, c);