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.

Spend the dollars: convert war-time foreign currency into Money (R-MONEY-004, refs #813) (#2204)

Eyal Golan0c7672d1865f
diff --git a/changelog.d/813-spend-dollars.md b/changelog.d/813-spend-dollars.md
new file mode 100644
index 000000000..da619195d
--- /dev/null
+++ b/changelog.d/813-spend-dollars.md
@@ -0,0 +1,9 @@
+- During the war (security rungs 4 and 5) the player can convert up to $4m a month of foreign currency into Money, $100m
+ in all, from the Defence screen, which shows the foreign-currency reserve beside the order (R-MONEY-004; owner ruling on
+ #813, 2 November 2026: "Spend the dollars (Recommended)"). The rate is the sourced one of the day: IL 0.333 per $ to 18
+ September 1949, IL 0.357 from the 19th. Each conversion lowers the debt and brings the 1951 currency crisis and its
+ Food-import cut closer; refusals (past the month's or the game's limit, or past the reserves) are explained in English
+ and Hebrew before End turn, and an amount refused is never queued. Outside the war the panel is greyed with the reason.
+ A new amount in the box replaces the queued conversion at once, and a turn's conversion runs before its Arms purchase
+ whatever the click order (owner, 2 November 2026: "Box shows queued order (Recommended)", "Grey it with the reason
+ (Recommended)", "Conversion counts first (Recommended)").
diff --git a/content/rules.yaml b/content/rules.yaml
index cccb4fcc0..37a71ba45 100644
--- a/content/rules.yaml
+++ b/content/rules.yaml
@@ -26,6 +26,7 @@ attention_cost:
cancel_project: 0.5 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6, D-C5, Q-PROJ-5: cancel_training's cost)
move: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free)
buy_arms: 1 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6, D-G6, #781: one order, whatever the quantity)
+ convert_dollars: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6, D-C3, #813: the war months' cards already take all of Attention in 5 of 11 turns, so the lever is free; owner 2 November 2026 on #2204: "Keep 0", the recommended option)
resolve_capture: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free; Q-TECH-3: one key, so Raid, Occupy and Deport cost the same; proposed on #797)
end_occupation: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free; R-CTRL-014: one key for Annex and Withdraw, as resolve_capture; proposed on #799)
# Turn length on each security rung, rungs 1 to 5 (R-TURN-001). The GDD MVP plays monthly turns on every rung (D-B1), so
@@ -110,6 +111,23 @@ mvp:
arms_start: 12 # DESIGN VALUE: owner-set balance, not a historical figure (D-G6, #781: Arms on 15 May 1948)
arms_price: 1 # DESIGN VALUE: owner-set balance, not a historical figure (D-G6, #781: IL millions per Arms)
arms_per_recruit_group: 1 # DESIGN VALUE: owner-set balance, not a historical figure (D-G6, Q-UNIT-3: Arms per recruit group trained)
+ # R-MONEY-004, "Spend the dollars" (#813; owner, 2 November 2026: "Spend the dollars (Recommended)",
+ # https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564883926): during the war the player may
+ # convert up to $4m a turn of foreign currency into Money, $100m in all; the reserves run out sooner, and the sourced
+ # 1951 currency crisis (fx_start, capital_inflow_per_year below) and its Food-import cut come closer. $100m is the
+ # Export-Import Bank's 1949 credit (FRUS 1949 vol. VI, editorial note d407,
+ # https://history.state.gov/historicaldocuments/frus1949v06/d407).
+ dollars_per_turn: 4 # DESIGN VALUE: owner-set balance, not a historical figure (D-C3, #813: US$ millions a turn)
+ dollars_total: 100 # DESIGN VALUE: owner-set balance, not a historical figure (D-C3, #813: US$ millions in all)
+ # The rate, IL millions per US$ million, each from its day on (sourced on #813, comment 6565039439). To 18 September
+ # 1949 the effective dollar rate was IL 0.333 per $ ($3.00): the official sterling parity gave IL 0.248 per $, but most
+ # dollar transactions ran at 0.333. The devaluation of 19 September 1949 set IL 0.357 per $ ($2.80), in force to 14
+ # February 1952. Sources: IMF Annual Report 1950, Appendix I, pp. 88-89; Federal Reserve Bulletin, November 1949, p. 1336;
+ # Michaely, Israel's Foreign Exchange Rate System (1971), p. 10 and Table 2-1; Patinkin, The Israel Economy: The First
+ # Decade, Table 43, p. 121. The economy comment below rounds the second rate to 0.36; the lever uses 0.357.
+ il_per_dollar:
+ - { from: 1948-05-15, rate: 0.333, status: sourced }
+ - { from: 1949-09-19, rate: 0.357, status: sourced }
# Agent-proposed values accepted by the owner on 19 October 2026 (Q-GEN-1, Q-UNIT-2, Q-UNIT-3):
# https://github.com/eyalgolan/statecraft-israel/pull/1130#issuecomment-6269103829
# Upkeep is per formation, not strength:
diff --git a/docs/GDD.md b/docs/GDD.md
index 2417fb581..b39da13ff 100644
--- a/docs/GDD.md
+++ b/docs/GDD.md
@@ -388,6 +388,12 @@ On 2 November 2026 the owner ruled on Arms bought on credit, a lever on the war
| The war debt of about IL 5m a month | "Give the player a lever (Recommended)", then "Spend the dollars (Recommended)" | The player gets a lever on the war debt: during the war, up to $4m a month of foreign currency can be moved into Money, $100m in total, which brings the sourced 1951 currency crisis and its Food-import cut closer. One foreign-currency readout is shown, so foreign currency is no longer wholly internal (Q2) ([lever](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564721721), [options](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564855158), [dollars](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564883926)). |
| The armistice-lines switch and legend | Switch: "Tie to Borders button (Recommended)"; legend: "Restyle Jordan lines (Recommended)" | The minimap's Borders button also hides and shows the armistice lines, with no new strings. The low-accuracy Jordan lines get a pattern apart from the legend's grey dash for no-man's land and the demilitarized zones, with no text changes ([#2195](https://github.com/eyalgolan/statecraft-israel/pull/2195#issuecomment-6565077805)). |
+#### Later rulings, 2 November 2026
+
+| Question | Owner's answer (2 November 2026) | Rule |
+|-|-|-|
+| A lever for the war-time debt (#813) | "Spend the dollars (Recommended)" | During the war (rungs 4 and 5) the player may convert up to $4m a month of foreign currency into Money, $100m in total; the reserves run out sooner, so the sourced 1951 currency crisis and its Food-import cut come closer (`R-MONEY-004`; [ruling](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564883926), [options](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564855158)). This overrides D-C3 ("Keep them internal, under Money, at least through cutover ... and hide them if they confuse") only for the foreign-currency reserve shown on the Defence screen where this order is made; the top bar keeps its Foreign currency meter (owner, 2 November 2026: "Keep it", [#2204](https://github.com/eyalgolan/statecraft-israel/pull/2204#issuecomment-6569134870)). |
+
## Deferred decisions
These are recorded once here. Feature files link here instead of maintaining competing open-question lists.
diff --git a/docs/gdd/balance.md b/docs/gdd/balance.md
index 0cc58e7d7..65052cd2d 100644
--- a/docs/gdd/balance.md
+++ b/docs/gdd/balance.md
@@ -122,6 +122,9 @@ The proposed immigration mix and ship schedule are non-operative [S1]. Retained
| `money.debt_ceiling` | `250` | IL millions of debt at which Money is exhausted | Retained `debt_ceiling` value [S10]; only the threshold of the economic defeat, not a credit cap: no order is refused or part-funded at it (owner, 1 November 2026, Q22) [S12], except an Arms purchase whose borrowing would take Debt past it, which is refused (owner, 2 November 2026, #2198: "Refuse buys over ceiling (Recommended)", https://github.com/eyalgolan/statecraft-israel/issues/2198#issuecomment-6564721486) |
| starting Debt | `0` | IL millions | Owner, 1 November 2026, Q23 [S12]: main has no start key, and Money is IL 1m a unit (`money.il_millions`) |
| `defeat_turns` | `3` | turn ends in a row with Money and Food exhausted | Retained `R-END-002` value [S10]; owner, 1 November 2026, Q25 [S12] |
+| `mvp.dollars_per_turn` | `4` | US$ millions of foreign currency converted into Money in one turn of the war | Owner, 2 November 2026 (`R-MONEY-004`) [S13] |
+| `mvp.dollars_total` | `100` | US$ millions converted in the whole game | Owner, 2 November 2026 (`R-MONEY-004`); the Export-Import Bank's 1949 credit [S13] |
+| `mvp.il_per_dollar` | `0.333`, then `0.357` from 19 September 1949 | IL millions per US$ million converted | Sourced effective dollar rates (`R-MONEY-004`) [S14] |
### Military and control
@@ -199,6 +202,8 @@ Historical census estimates, real camp opening dates, authored region borders, a
- [S10] Retained numerical and rule catalogue, `content/projects.yaml`, `content/rules.yaml` and `docs/rules/mvp.md` (`R-PROJ-001`, `R-TRAIN-001` and `R-UNIT-005`).
- [S11] Owner's 30 October 2026 rulings, [GDD conflict decisions](../GDD.md#30-october-2026-conflict-decisions).
- [S12] Owner's 1 November 2026 answers, [GDD 1 November 2026 answers](../GDD.md#1-november-2026-answers).
+- [S13] Owner's 2 November 2026 ruling on #813, "Spend the dollars (Recommended)", [GDD later rulings, 2 November 2026](../GDD.md#later-rulings-2-november-2026); the $100m is the Export-Import Bank's 1949 credit (FRUS 1949 vol. VI, editorial note d407).
+- [S14] Israel's dollar rates, 1948-1952: IMF, Annual Report 1950, Appendix I, pp. 88-89; Federal Reserve Bulletin, November 1949, p. 1336; Michaely, *Israel's Foreign Exchange Rate System* (1971), p. 10 and Table 2-1; Patinkin, *The Israel Economy: The First Decade*, Table 43, p. 121 ([#813](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6565039439), checked 2026-11-02).
## Open questions
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index bba90f6a6..0c71a7081 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -400,6 +400,8 @@ R-MONEY-002: In step 7, after Food consumption and imports, the Treasury pays ea
R-MONEY-003: A GDD cost above the Treasury is paid, and the shortfall moves to debt, as map actions do: the Treasury stops at 0, and a cause names what the shortfall was borrowed for (Q-MONEY-3, owner decision "Allow borrowing", 15 October 2026, for training and pioneer work; the Phase 2 plan applies it to every GDD cost). It covers the deficit, map actions, training (R-TRAIN-001), pioneer work (R-SITE-001) and an event option's Treasury cost.
+R-MONEY-004: "Spend the dollars" (#813; owner, 2 November 2026: "Spend the dollars (Recommended)", https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564883926). `ConvertDollars(amount)`, save line `dollars N`, scenario kind `convert_dollars`, converts `amount` US$ millions of foreign currency into Money: the reserves lose `amount` and the Treasury gains `amount` times the `mvp.il_per_dollar` rate in force on the turn's date, with a cause line, so the turn's deficit borrows that much less (R-MONEY-003); no principal is added to Debt (Q5). A turn's conversions run before its Arms purchases, whatever the queue order, so a purchase borrows only what the conversions leave it short (#2206; owner, 2 November 2026: "Conversion counts first (Recommended)", [#813](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6569645587)). It is a GDD order, refused in the legacy loop. It is refused, state and Attention unchanged, below $1m ("Convert at least $1m"), outside the war, a rung below 4 at the turn's start ("Dollars can be converted only during the war"), when the turn's conversions would pass `mvp.dollars_per_turn` (4; "That is more dollars than may be converted this month"), when the game's would pass `mvp.dollars_total` (100, the Export-Import Bank's 1949 credit, FRUS 1949 vol. VI, d407; "That would pass the total of dollars that may be converted"), or when the reserves would go below 0 ("There are not enough dollars in the reserves"). `GameState.DollarsConverted` keeps the game's total and is hashed as `dollars=` only when not 0. The rate is sourced and dated: IL 0.333 per $ ($3.00), the effective dollar rate, to 18 September 1949 (the official sterling parity gave IL 0.248 per $, but most dollar transactions ran at 0.333), and IL 0.357 per $ ($2.80) from the devaluation of 19 September 1949 to 14 February 1952 (IMF, Annual Report 1950, Appendix I, pp. 88-89; Federal Reserve Bulletin, November 1949, p. 1336; Michaely, *Israel's Foreign Exchange Rate System* (1971), p. 10 and Table 2-1; Patinkin, *The Israel Economy: The First Decade*, Table 43, p. 121 (gathered on [#813](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6565039439))). `dollars_per_turn` and `dollars_total` are labelled design values, and the Attention cost `attention_cost.convert_dollars` is 0 (owner, 2 November 2026: "Keep 0 (Recommended)", [#2204](https://github.com/eyalgolan/statecraft-israel/pull/2204#issuecomment-6569134870)). The Defence screen makes the order and shows the foreign-currency reserve beside it. With a conversion queued, a new amount in its box replaces the order at once, or withdraws it when the amount would be refused, so the box, its Money line and what End turn converts agree; the reserve and the total converted keep the turn's start until End turn (owner, 2 November 2026: "Box shows queued order (Recommended)", [#813](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6569645587)). Outside the war the panel stays visible but disabled, with one line saying conversion is for wartime only (owner, 2 November 2026: "Grey it with the reason (Recommended)", [#813](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6569645587)); the top bar gains nothing and keeps its Foreign currency meter (owner, 2 November 2026: "Keep it", [#2204](https://github.com/eyalgolan/statecraft-israel/pull/2204#issuecomment-6569134870)). The same rules apply under `gdd-0.1` and `gdd-0.3`, which share this economy (D1).
+
The top bar shows the net position, Treasury minus debt (`HudModel.From`), so it reads below 0 once anything is borrowed.
## Food
@@ -418,7 +420,7 @@ The national Arms pool (D-G6, decided 15 October 2026: "From events (sourced arm
R-ARMS-001: Arms is a national stock of whole units (`GameState.Arms`, hashed as `arms=` only when not 0); one Arms is the equipment package for one recruit group of `people_per_unit` (1,000) people. A new game starts the stock at `arms_start` (12). It never goes below 0. `arms_start`, `arms_price` and `arms_per_recruit_group` are required in the GDD loop (`rules.yaml` `mvp:`); a missing or negative value is a load error.
-R-ARMS-002: `BuyArms(count)` adds `count` units to the stock at once, with no delivery delay, and the Treasury pays `count * arms_price` (IL 1m an Arms), borrowing what it lacks (R-MONEY-003). It is refused, state and Attention unchanged, for fewer than one unit, a stock that would pass a whole number's range, or a purchase whose borrowing would take the debt past `debt_ceiling` (#2198; owner, 2 November 2026: "Refuse buys over ceiling (Recommended)", https://github.com/eyalgolan/statecraft-israel/issues/2198#issuecomment-6564721486), with the reason "Buying that many Arms would take the debt past its ceiling"; the legacy loop refuses it before charging Attention. The debt after is R-MONEY-003's: the debt plus what the Treasury lacks (`Debt + max(0, cost - Treasury)`). A debt exactly at the ceiling is allowed, and a purchase the Treasury pays in full borrows nothing and is never refused at it, even with the debt already past it. This overrides Q22 for Arms purchases only; every other cost still borrows past the ceiling (R-MONEY-003). The Defence screen shows the same reason before End turn when the amount would be refused at the current Treasury and debt. Its Attention cost is `attention_cost.buy_arms` (1), whatever the count.
+R-ARMS-002: `BuyArms(count)` adds `count` units to the stock at once, with no delivery delay, and the Treasury pays `count * arms_price` (IL 1m an Arms), borrowing what it lacks (R-MONEY-003). It is refused, state and Attention unchanged, for fewer than one unit, a stock that would pass a whole number's range, or a purchase whose borrowing would take the debt past `debt_ceiling` (#2198; owner, 2 November 2026: "Refuse buys over ceiling (Recommended)", https://github.com/eyalgolan/statecraft-israel/issues/2198#issuecomment-6564721486), with the reason "Buying that many Arms would take the debt past its ceiling"; the legacy loop refuses it before charging Attention. The debt after is R-MONEY-003's: the debt plus what the Treasury lacks (`Debt + max(0, cost - Treasury)`). A debt exactly at the ceiling is allowed, and a purchase the Treasury pays in full borrows nothing and is never refused at it, even with the debt already past it. This overrides Q22 for Arms purchases only; every other cost still borrows past the ceiling (R-MONEY-003). The Defence screen shows the same reason before End turn when the amount would be refused at the current Treasury and debt. The turn's dollar conversions (R-MONEY-004) run before its Arms purchases, whatever the queue order: a conversion queued after the turn's first `BuyArms` runs just before it, with the other such conversions in their queue order, and every other order keeps its queue place (#2206). Its Attention cost is `attention_cost.buy_arms` (1), whatever the count.
R-ARMS-003: Recruit training (R-TRAIN-001) takes `arms_per_recruit_group` (1) Arms for each group when it starts, after its other checks and before it pays. A stock short of that refuses the order with a reason naming the need and the stock, state and Attention unchanged (Q-UNIT-3). A gun or armoured car crew takes its type's `training_arms` a group instead, by the same rule (R-UNIT-008). Pioneer training takes no Arms. The cohort keeps the Arms it took, and the state hash writes them with it; cancelling the cohort (R-TRAIN-002) returns them to the pool, up to the most the stock can hold, although the Money stays paid (owner, 18 October 2026, #1047: "Refund on cancel"). Replacement groups (R-TRAIN-004) take their course's Arms by the same rule (owner, 23 October 2026, #1510: "Replacements cost Arms").
diff --git a/sim/Statecraft.Sim.Tests/CommandGuardTests.cs b/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
index 8adb7f1a9..243f1a5dc 100644
--- a/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
+++ b/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
@@ -32,6 +32,7 @@ public class CommandGuardTests
[typeof(CancelProject)] = new CancelProject(1),
[typeof(Move)] = new Move(1, 2, 0),
[typeof(BuyArms)] = new BuyArms(0), // refused (fewer than one unit), as GovernmentTests.ARefusedGddOrderRefundsItsAttention needs
+ [typeof(ConvertDollars)] = new ConvertDollars(0), // refused (below $1m), like BuyArms(0); R-MONEY-004
[typeof(ResolveCapture)] = new ResolveCapture("town_a", "raid"), // refused (nothing awaits a decision), like BuyArms(0)
[typeof(EndOccupation)] = new EndOccupation("town_a", "annex"), // refused (nothing awaits the end of an occupation)
};
diff --git a/sim/Statecraft.Sim.Tests/DeportTests.cs b/sim/Statecraft.Sim.Tests/DeportTests.cs
index c506f53ea..8199364b4 100644
--- a/sim/Statecraft.Sim.Tests/DeportTests.cs
+++ b/sim/Statecraft.Sim.Tests/DeportTests.cs
@@ -213,7 +213,7 @@ public class DeportTests
// These name no place or hex: a city, a cohort, a unit's own work, a policy, a budget, an event, an office or a count.
[typeof(SetPolicy)] = null, [typeof(AllocateBudget)] = null, [typeof(ChooseEventOption)] = null, [typeof(SetMobilization)] = null,
[typeof(SecurityOrder)] = null, [typeof(Appoint)] = null, [typeof(AssignWorkers)] = null, [typeof(Train)] = null,
- [typeof(CancelTraining)] = null, [typeof(Reinforce)] = null, [typeof(ReturnCraftsmen)] = null, [typeof(ReassignCraftsmen)] = null, [typeof(ReassignPioneers)] = null, [typeof(StopWork)] = null, [typeof(CancelProject)] = null, [typeof(BuyArms)] = null,
+ [typeof(CancelTraining)] = null, [typeof(Reinforce)] = null, [typeof(ReturnCraftsmen)] = null, [typeof(ReassignCraftsmen)] = null, [typeof(ReassignPioneers)] = null, [typeof(StopWork)] = null, [typeof(CancelProject)] = null, [typeof(BuyArms)] = null, [typeof(ConvertDollars)] = null,
};
var kinds = typeof(Command).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Command)) && !t.IsAbstract).OrderBy(t => t.Name, StringComparer.Ordinal);
Assert.Equal(kinds.Select(t => t.Name), aimed.Keys.OrderBy(t => t.Name, StringComparer.Ordinal).Select(t => t.Name));
diff --git a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
index cdb49e8b7..17ed29e6f 100644
--- a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
+++ b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
@@ -189,6 +189,10 @@ public partial class DesignValuesTests
("rules.yaml", "mvp.arms_start"),
("rules.yaml", "mvp.arms_price"),
("rules.yaml", "mvp.arms_per_recruit_group"),
+ // "Spend the dollars" (R-MONEY-004; #813, owner 2 November 2026: "Spend the dollars (Recommended)").
+ ("rules.yaml", "attention_cost.convert_dollars"), // free, as the cards take all of Attention in the war (owner 2 November 2026 on #2204: "Keep 0 (Recommended)")
+ ("rules.yaml", "mvp.dollars_per_turn"),
+ ("rules.yaml", "mvp.dollars_total"),
// Prisoners (Phase 5 PR 12, #751; Q-POW-2, Q-POW-4, Q-POW-5): agent defaults, accepted by the owner as design values (owner, 21 October 2026, #751).
("rules.yaml", "mvp.food_per_prisoner_unit"),
("rules.yaml", "mvp.prisoner_shortfall_cohesion"),
@@ -306,6 +310,7 @@ public partial class DesignValuesTests
Assert.Equal((0.35, 0.15), (m.HousingStartCondition, m.OverflowConditionLoss)); // Q-START-3, Q-HOUSE-1 (D-D1)
Assert.Equal((5, 0.5), (m.DelegationLoyaltyFloor, m.DisloyalEffectShare)); // R-EVT-003, #107 (D-H1)
Assert.Equal((12, 1.0, 1, 1.0), (m.ArmsStart, m.ArmsPrice, m.ArmsPerRecruitGroup, c.Rules.AttentionCost["buy_arms"])); // #781 (D-G6)
+ Assert.Equal((4, 100, 0.0), (m.DollarsPerTurn, m.DollarsTotal, c.Rules.AttentionCost["convert_dollars"])); // #813 (D-C3), R-MONEY-004; the rates are sourced, not design values
Assert.Equal((0.05, 6), (m.MilitaryUpkeepPerTurn, m.VeteranSoldierService)); // Q-GEN-1: owner-accepted initial design values (19 October 2026), not history.
Assert.Equal((1, 5, 6), (m.ArmsPerAttack, m.CombatTable.Count, m.CombatTable[0].AttackerLoss.Count)); // #747 (D-G6, D-G3), accepted by the owner 20 Oct 2026
Assert.Equal((1, 0.01, 10, 0.005), (m.FoodPerPrisonerUnit, m.PrisonerShortfallCohesion, m.PointsPerPrisonerUnitReturned, m.HeldSoldierCostPerTurn)); // #751 (Q-POW-2, Q-POW-4, Q-POW-5), accepted by the owner (owner, 21 October 2026, #751)
diff --git a/sim/Statecraft.Sim.Tests/DollarsTests.cs b/sim/Statecraft.Sim.Tests/DollarsTests.cs
new file mode 100644
index 000000000..1f6a0b903
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/DollarsTests.cs
@@ -0,0 +1,384 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>R-MONEY-004, "Spend the dollars" (#813; owner, 2 November 2026: "Spend the dollars (Recommended)",
+/// https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564883926): during the war (rung 4 or 5) the
+/// player may convert up to mvp.dollars_per_turn of foreign currency a turn into Money, mvp.dollars_total in all, never
+/// taking the reserves below 0, at the rate of mvp.il_per_dollar in force on the turn's date. The fixture converts at IL 0.5
+/// per $ (IL 0.25 from 15 August 1948), $4m a turn and $10m in all.</summary>
+public class DollarsTests
+{
+ static readonly Content Real = ContentLoader.Load(RealContentTests.ContentRoot());
+
+ static Content Gdd() => ContentLoader.Load(Fixture.Write(Fixture.Gdd()));
+
+ /// <summary>A new fixture game at the war's rung 5, with the Treasury and the reserves set for round sums.</summary>
+ static GameState War(Content c, double fx = 50, int converted = 0)
+ {
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ Assert.Equal(5, s.Rung);
+ s.Treasury = 1; s.Debt = 0; s.FxReserves = fx; s.DollarsConverted = converted;
+ return s;
+ }
+
+ static PreviewResult Orders(Content c, GameState s, params Command[] orders) => Simulation.Preview(c, s, orders);
+
+ // 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()
+ {
+ var c = Gdd();
+ Assert.Equal((4, 10, 0.5), (c.Rules.Mvp!.DollarsPerTurn, c.Rules.Mvp.DollarsTotal, c.Rules.Mvp.IlPerDollarOn(c.Rules.Start)));
+ var s = War(c);
+ var r = Orders(c, s, new ConvertDollars(3));
+ Assert.Empty(r.Rejected);
+ Assert.Equal((2.5, 0.0, 47.0, 3), (r.State.Treasury, r.State.Debt, r.State.FxReserves, r.State.DollarsConverted));
+ var line = Assert.Single(r.Why, w => w.Key == CauseKeys.DollarsConverted);
+ Assert.Equal(("economy", "treasury", 1.5), (line.System, line.Target, line.Delta));
+ Assert.Equal(new[] { "3" }, line.Args);
+ Assert.Contains(CauseKeys.DollarsConverted, CauseKeys.All); // so the UI words it (CauseText)
+ Assert.Equal("Converted $3.0m of foreign currency into Money: " + PlayerText.MoneyChange(c, "treasury", 1.5), line.Message);
+ }
+
+ // R-MONEY-004: the rate is the one in force on the turn's date (mvp.il_per_dollar, each rate from its day on).
+ [Theory]
+ [InlineData("1948-08-14", 1.0)] [InlineData("1948-08-15", 0.5)] [InlineData("1949-01-15", 0.5)]
+ public void TheRateIsTheOneInForceOnTheTurnsDate(string date, double money)
+ {
+ var c = Gdd();
+ var s = War(c);
+ s.Date = DateTime.Parse(date, System.Globalization.CultureInfo.InvariantCulture);
+ var r = Orders(c, s, new ConvertDollars(2));
+ Assert.Empty(r.Rejected);
+ Assert.Equal(1 + money, r.State.Treasury, 12);
+ // End turn converts at the same rate: the turn's start date, not its end (the 14 August turn ends after the 15th).
+ var none = Simulation.Step(c, s, Array.Empty<Command>()).State;
+ var sold = Simulation.Step(c, s, new Command[] { new ConvertDollars(2) });
+ Assert.Empty(sold.Rejected);
+ Assert.Equal(none.Treasury - none.Debt + money, sold.State.Treasury - sold.State.Debt, 9);
+ }
+
+ // R-MONEY-004: the IL goes into the Treasury before the turn's economy, so the turn's own deficit borrows less
+ // (R-MONEY-003): the net position (Treasury minus Debt) ends exactly the conversion higher. The fixture's turn borrows
+ // about IL 0.48m, so $1m (IL 0.5m) covers it and $4m (IL 2m) also leaves Money in the Treasury.
+ [Theory]
+ [InlineData(1)] [InlineData(4)]
+ public void TheConversionLowersTheTurnsBorrowing(int amount)
+ {
+ var c = Gdd();
+ var s = War(c);
+ s.Treasury = 0;
+ var none = Simulation.Step(c, s, Array.Empty<Command>()).State;
+ var sold = Simulation.Step(c, s, new Command[] { new ConvertDollars(amount) }).State;
+ Assert.True(none.Debt > 0 && none.Debt < 0.5, $"the fixture's turn borrows under IL 0.5m ({none.Debt})");
+ Assert.Equal((0.0, 0.0), (none.Treasury, sold.Debt));
+ Assert.Equal(none.Treasury - none.Debt + amount * 0.5, sold.Treasury - sold.Debt, 9);
+ Assert.Equal(none.FxReserves - amount, sold.FxReserves, 9);
+ Assert.Equal(amount, sold.DollarsConverted);
+ }
+
+ // R-MONEY-004: a turn converts at most dollars_per_turn, over all of its orders together.
+ [Fact]
+ public void ATurnConvertsAtMostItsMonthlyLimit()
+ {
+ var c = Gdd();
+ var s = War(c);
+ Assert.Equal(EconomySystem.RefusedDollarsMonthly, Assert.Single(Orders(c, s, new ConvertDollars(5)).Rejected).Reason);
+ var two = Orders(c, s, new ConvertDollars(2), new ConvertDollars(2));
+ Assert.Empty(two.Rejected);
+ Assert.Equal(4, two.State.DollarsConverted);
+ var over = Orders(c, s, new ConvertDollars(3), new ConvertDollars(2));
+ Assert.Equal(EconomySystem.RefusedDollarsMonthly, Assert.Single(over.Rejected).Reason);
+ Assert.Equal(3, over.State.DollarsConverted);
+ // A refused order uses none of the limit: 3, then 2 refused, then 1 makes 4.
+ var after = Orders(c, s, new ConvertDollars(3), new ConvertDollars(2), new ConvertDollars(1));
+ Assert.Equal(EconomySystem.RefusedDollarsMonthly, Assert.Single(after.Rejected).Reason);
+ Assert.Equal(2, ((ConvertDollars)after.Rejected[0].Command).Amount);
+ Assert.Equal(4, after.State.DollarsConverted);
+ // The limit is per turn: the next turn may convert its own dollars_per_turn again.
+ var next = Simulation.Step(c, s, new Command[] { new ConvertDollars(4) }).State;
+ Assert.Equal(5, next.Rung);
+ Assert.Empty(Orders(c, next, new ConvertDollars(4)).Rejected);
+ // A limit of 0 refuses every amount.
+ foreach (var r in c.EraRules.Values.Append(c.Rules)) r.Mvp!.DollarsPerTurn = 0;
+ Assert.Equal(EconomySystem.RefusedDollarsMonthly, Assert.Single(Orders(c, s, new ConvertDollars(1)).Rejected).Reason);
+ }
+
+ // R-MONEY-004: the game converts at most dollars_total; an amount that would pass it is refused whole.
+ [Fact]
+ public void TheGameConvertsAtMostItsTotal()
+ {
+ var c = Gdd();
+ var s = War(c, converted: 8);
+ Assert.Equal(EconomySystem.RefusedDollarsTotal, Assert.Single(Orders(c, s, new ConvertDollars(3)).Rejected).Reason);
+ var two = Orders(c, s, new ConvertDollars(2));
+ Assert.Empty(two.Rejected);
+ Assert.Equal(10, two.State.DollarsConverted);
+ Assert.Equal(EconomySystem.RefusedDollarsTotal, Assert.Single(Orders(c, two.State, new ConvertDollars(1)).Rejected).Reason);
+ }
+
+ // R-MONEY-004: a conversion may take the reserves to 0, never below.
+ [Fact]
+ public void TheReservesNeverGoBelowZero()
+ {
+ var c = Gdd();
+ Assert.Equal(EconomySystem.RefusedDollarsReserves, Assert.Single(Orders(c, War(c, fx: 2.5), new ConvertDollars(3)).Rejected).Reason);
+ var exact = Orders(c, War(c, fx: 3), new ConvertDollars(3));
+ Assert.Empty(exact.Rejected);
+ Assert.Equal(0.0, exact.State.FxReserves);
+ Assert.Equal(EconomySystem.RefusedDollarsReserves, Assert.Single(Orders(c, War(c, fx: -1), new ConvertDollars(1)).Rejected).Reason);
+ }
+
+ // R-MONEY-004: only during the war, rung 4 or 5.
+ [Theory]
+ [InlineData(1, false)] [InlineData(2, false)] [InlineData(3, false)] [InlineData(4, true)] [InlineData(5, true)]
+ public void OnlyTheWarRungsMayConvert(int rung, bool allowed)
+ {
+ var c = Gdd();
+ var s = War(c);
+ s.Rung = rung;
+ var r = Orders(c, s, new ConvertDollars(1));
+ if (allowed) Assert.Empty(r.Rejected);
+ else Assert.Equal(EconomySystem.RefusedDollarsNotAtWar, Assert.Single(r.Rejected).Reason);
+ }
+
+ const string RungEvent = @"
+id: rung
+title: A choice
+text: '{finance_minister} asks for a decision.'
+office: finance_minister
+anchor: hard
+from: 1948-05-15
+options:
+ - id: history
+ text: The way it went
+ historical: true
+ set_rung: RUNG
+";
+
+ // R-MONEY-004: the war is the rung the turn started at. An earlier order of the same turn that moves the rung (an
+ // event's set_rung) changes neither way whether the conversion is allowed, so End turn agrees with the Defence screen,
+ // which checks the turn's start.
+ [Theory]
+ [InlineData(5, 3, true)] [InlineData(4, 2, true)] [InlineData(3, 5, false)]
+ public void TheWarIsTheRungTheTurnStartedAt(int start, int set, bool allowed)
+ {
+ var c = ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string> { ["events/rung.yaml"] = RungEvent.Replace("RUNG", set.ToString(System.Globalization.CultureInfo.InvariantCulture)) })));
+ var s = War(c);
+ s.Rung = start;
+ Assert.Contains("rung", s.PendingEvents);
+ var orders = new Command[] { new ChooseEventOption("rung", "history"), new ConvertDollars(1) };
+ var preview = Orders(c, s, orders);
+ Check(preview.State, preview.Rejected);
+ var step = Simulation.Step(c, s, orders);
+ Check(step.State, step.Rejected);
+ void Check(GameState state, IEnumerable<Rejection> rejected)
+ {
+ Assert.Equal(set, state.Rung);
+ if (allowed) { Assert.Empty(rejected); Assert.Equal(1, state.DollarsConverted); }
+ else { Assert.Equal(EconomySystem.RefusedDollarsNotAtWar, Assert.Single(rejected).Reason); Assert.Equal(0, state.DollarsConverted); }
+ }
+ Assert.Equal(allowed ? null : EconomySystem.RefusedDollarsNotAtWar, EconomySystem.DollarsRefusal(c, s, 1)); // the screen's check
+ }
+
+ // R-MONEY-004: at least $1m.
+ [Theory]
+ [InlineData(0)] [InlineData(-3)]
+ public void AnAmountBelowOneIsRefused(int amount)
+ {
+ var c = Gdd();
+ Assert.Equal(EconomySystem.RefusedDollarsMinimum, Assert.Single(Orders(c, War(c), new ConvertDollars(amount)).Rejected).Reason);
+ }
+
+ // R-MONEY-004: every refusal leaves the state as the turn with no order, Attention included, and says nothing in Why.
+ // The order is priced at 1 here (content prices it at 0), so a refusal that kept the Attention would show.
+ [Theory]
+ [InlineData(0, 50, 0, 5, EconomySystem.RefusedDollarsMinimum)]
+ [InlineData(1, 50, 0, 3, EconomySystem.RefusedDollarsNotAtWar)]
+ [InlineData(5, 50, 0, 5, EconomySystem.RefusedDollarsMonthly)]
+ [InlineData(3, 50, 8, 5, EconomySystem.RefusedDollarsTotal)]
+ [InlineData(3, 2.5, 0, 5, EconomySystem.RefusedDollarsReserves)]
+ public void ARefusalLeavesTheStateUntouched(int amount, double fx, int converted, int rung, string reason)
+ {
+ var c = Gdd();
+ foreach (var r in c.EraRules.Values.Append(c.Rules)) r.AttentionCost[EconomySystem.ConvertDollarsKind] = 1;
+ var s = War(c, fx, converted);
+ s.Rung = rung;
+ Assert.True(AttentionSystem.Cost(c, s, EconomySystem.ConvertDollarsKind) > 0 && s.Attention >= AttentionSystem.Cost(c, s, EconomySystem.ConvertDollarsKind));
+ var refused = Simulation.Step(c, s, new Command[] { new ConvertDollars(amount) });
+ Assert.Equal(reason, Assert.Single(refused.Rejected).Reason);
+ Assert.Equal(Simulation.Step(c, s, Array.Empty<Command>()).State.Hash(), refused.State.Hash());
+ Assert.DoesNotContain(refused.Why, w => w.Key == CauseKeys.DollarsConverted);
+ // Step refills Attention at the turn's end, so only the dry run shows the refund.
+ var preview = Orders(c, s, new ConvertDollars(amount));
+ Assert.Equal(reason, Assert.Single(preview.Rejected).Reason);
+ Assert.Equal(s.Attention, preview.State.Attention);
+ Assert.Equal(Orders(c, s).State.Hash(), preview.State.Hash());
+ }
+
+ // R-MONEY-004: a GDD order; the legacy loop refuses it before charging Attention.
+ [Fact]
+ public void TheLegacyLoopRefusesIt()
+ {
+ var c = ContentLoader.Load(Fixture.Write());
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ var r = Simulation.Step(c, s, new Command[] { new ConvertDollars(1) });
+ Assert.Equal("That order is not available in this game", Assert.Single(r.Rejected).Reason);
+ Assert.Equal(Simulation.Step(c, s, Array.Empty<Command>()).State.Hash(), r.State.Hash());
+ }
+
+ // R-MONEY-004: the total is in the state hash only once something is converted, so a run without the order hashes as before.
+ [Fact]
+ public void TheTotalIsHashedOnlyWhenSet()
+ {
+ var c = Gdd();
+ var s = War(c);
+ Assert.DoesNotContain("dollars=", s.Describe());
+ var after = Orders(c, s, new ConvertDollars(2)).State;
+ Assert.Contains("dollars=2", after.Describe());
+ Assert.NotEqual(s.Hash(), after.Hash());
+ }
+
+ // R-MONEY-004: the order is saved as `dollars N`, replayed on load, and the total comes back with the same hash.
+ [Fact]
+ public void TheTotalRoundTripsThroughTheSave()
+ {
+ var c = Gdd();
+ var g = GameSession.New(c, 7, Mode.Historical);
+ g.Step(new Command[] { new ConvertDollars(3) });
+ g.Step(new Command[] { new ConvertDollars(4) });
+ Assert.Equal(7, g.State.DollarsConverted);
+ var text = g.Save.Write();
+ Assert.Contains("\ndollars 3\n", text);
+ var back = GameSession.Load(c, text, out var warnings);
+ Assert.Empty(warnings);
+ Assert.Equal(7, back.State.DollarsConverted);
+ Assert.Equal(g.State.Hash(), back.State.Hash());
+ var parsed = Assert.IsType<ConvertDollars>(SaveGame.Parse(text).Turns[1].Single());
+ Assert.Equal(4, parsed.Amount);
+ var built = Assert.IsType<ConvertDollars>(Scenario.Build(new Dictionary<string, object> { ["kind"] = "convert_dollars", ["amount"] = 2 }));
+ Assert.Equal(2, built.Amount);
+ }
+
+ // R-MONEY-004: the real content's values, as ruled: $4m a turn and $100m in all, at the sourced rates (#813 comment
+ // 6565039439): the effective dollar rate IL 0.333 per $ ($3.00) to 18 September 1949, IL 0.357 ($2.80) from the 19th.
+ [Fact]
+ public void TheRealContentConvertsFourMillionAMonthAndAHundredInAll()
+ {
+ var m = Real.Rules.Mvp!;
+ Assert.Equal((4, 100), (m.DollarsPerTurn, m.DollarsTotal));
+ Assert.Equal((0.333, 0.333, 0.333, 0.357, 0.357), (m.IlPerDollarOn(new DateTime(1948, 5, 15)), m.IlPerDollarOn(new DateTime(1949, 3, 15)),
+ m.IlPerDollarOn(new DateTime(1949, 9, 18)), m.IlPerDollarOn(new DateTime(1949, 9, 19)), m.IlPerDollarOn(new DateTime(1952, 1, 15))));
+ Assert.Equal(0.0, Real.Rules.AttentionCost["convert_dollars"]);
+ }
+
+ static (string, string, double, string)[] Lines(StepResult r) => r.Why.Select(w => (w.System, w.Target, w.Delta, w.Message)).ToArray();
+
+ // R-MONEY-004, R-ARMS-002 (#2206; owner, 2 November 2026: "Conversion counts first (Recommended)"): a turn's dollar
+ // conversions run before its Arms purchases, so the purchase borrows only what the conversion leaves it short, whatever
+ // the queue order. The real content's first turn: rung 5, Treasury IL 20m, no debt, IL 1m an Arms, IL 0.333 per $.
+ // Queued before or after $4m (IL 1.332m), 271 Arms give the same turn: the same state, causes and rejections.
+ [Fact]
+ public void AConversionCountsForAnArmsPurchaseWhateverTheQueueOrder()
+ {
+ var s = Simulation.NewGame(Real, GoldenRun.Seed, Mode.Historical);
+ var m = Real.RulesAt(s.Date).Mvp!;
+ Assert.Equal((5, 20.0, 0.0, 1.0, 0.333), (s.Rung, s.Treasury, s.Debt, m.ArmsPrice!.Value, m.IlPerDollarOn(s.Date)));
+ var first = Simulation.Step(Real, s, new Command[] { new ConvertDollars(4), new BuyArms(271) });
+ var last = Simulation.Step(Real, s, new Command[] { new BuyArms(271), new ConvertDollars(4) });
+ Assert.Empty(first.Rejected);
+ Assert.Empty(last.Rejected);
+ Assert.Equal(first.State.Hash(), last.State.Hash());
+ Assert.Equal(Lines(first), Lines(last));
+ Assert.Equal(s.Arms + 271, last.State.Arms);
+ // The money adds up: the orders leave the Treasury at 0 and the debt at 271 - 20 - 4 * 0.333, and the turn ends the
+ // purchase less and the conversion more than the turn with no order.
+ var orders = Simulation.Preview(Real, s, new Command[] { new BuyArms(271), new ConvertDollars(4) }).State;
+ Assert.Equal(0.0, orders.Treasury, 9);
+ Assert.Equal(271 - 20 - 4 * 0.333, orders.Debt, 9);
+ var none = Simulation.Step(Real, s, Array.Empty<Command>()).State;
+ Assert.Equal(none.Treasury - none.Debt - 271 + 4 * 0.333, last.State.Treasury - last.State.Debt, 9);
+ }
+
+ // #2206: only the conversions queued after the turn's first Arms purchase move, to just before it, in their queue order;
+ // every other order keeps its place (here, the order of the rejections).
+ [Fact]
+ public void OnlyTheConversionsMoveAheadOfTheFirstArmsPurchase()
+ {
+ var c = Gdd();
+ var s = War(c);
+ var r = Orders(c, s, new BuyArms(0), new ConvertDollars(0), new BuyArms(-1), new ConvertDollars(5));
+ Assert.Equal(new[] { "convert_dollars 0", "convert_dollars 5", "buy_arms 0", "buy_arms -1" },
+ r.Rejected.Select(x => x.Command.Kind + " " + (x.Command is ConvertDollars d ? d.Amount : ((BuyArms)x.Command).Count)
+ .ToString(System.Globalization.CultureInfo.InvariantCulture)));
+ var none = Orders(c, s, new ConvertDollars(5), new ConvertDollars(0));
+ Assert.Equal(new[] { 5, 0 }, none.Rejected.Select(x => ((ConvertDollars)x.Command).Amount));
+ }
+
+ const string Rates = " il_per_dollar: [{ from: 1948-05-15, rate: 0.5, status: sourced }, { from: 1948-08-15, rate: 0.25, status: sourced }]\n";
+
+ // R-MONEY-004: missing or out-of-range values are load errors, never a default.
+ [Theory]
+ [InlineData(" dollars_per_turn: 4\n", "", "mvp.dollars_per_turn", "required")]
+ [InlineData(" dollars_per_turn: 4\n", " dollars_per_turn: -1\n", "mvp.dollars_per_turn", ">= 0")]
+ [InlineData(" dollars_total: 10\n", "", "mvp.dollars_total", "required")]
+ [InlineData(" dollars_total: 10\n", " dollars_total: -1\n", "mvp.dollars_total", ">= 0")]
+ [InlineData(Rates, "", "mvp.il_per_dollar", "required")]
+ [InlineData(Rates, " il_per_dollar: []\n", "mvp.il_per_dollar", "required")]
+ [InlineData(Rates, " il_per_dollar: [{ from: 1948-05-15, rate: -0.1, status: sourced }]\n", "mvp.il_per_dollar[0].rate", "finite number >= 0")]
+ [InlineData(Rates, " il_per_dollar: [{ from: 1948-05-15, rate: .inf, status: sourced }]\n", "mvp.il_per_dollar[0].rate", "finite number >= 0")]
+ [InlineData(Rates, " il_per_dollar: [{ from: 1948-05-16, rate: 0.5, status: sourced }]\n", "mvp.il_per_dollar[0].from", "on or before the start")]
+ [InlineData(Rates, " il_per_dollar: [{ from: 1948-05-15, rate: 0.5, status: sourced }, { from: 1948-05-15, rate: 0.4, status: sourced }]\n", "mvp.il_per_dollar[1].from", "after the previous")]
+ public void MissingOrBadValuesAreLoadErrors(string line, string replacement, string field, string message)
+ {
+ var files = Fixture.Gdd();
+ Assert.Contains(line, files["rules.yaml"]);
+ files["rules.yaml"] = files["rules.yaml"].Replace(line, replacement);
+ var e = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(files)));
+ Assert.Contains(field, e.Message);
+ Assert.Contains(message, e.Message);
+ }
+
+ /// <summary>The #813 prototype's run: real content, seed 1948, Historical, every card delegated (no orders but the
+ /// conversion), converting <paramref name="perTurn"/> each turn that starts at rung 4 or 5. Returns the debt at the end
+ /// of the turn ending 15 April 1949, the end state, the first turn end with the currency crisis on and the dollars converted.</summary>
+ static (double April1949, GameState End, DateTime? Crisis, int Converted) Prototype(int perTurn)
+ {
+ var s = Simulation.NewGame(Real, GoldenRun.Seed, Mode.Historical);
+ double? april = null; DateTime? crisis = null;
+ for (int turn = 0; turn < 1000 && s.GameOver == null; turn++)
+ {
+ var orders = perTurn > 0 && s.Rung >= 4 ? new Command[] { new ConvertDollars(perTurn) } : Array.Empty<Command>();
+ var r = Simulation.Step(Real, s, orders);
+ Assert.Empty(r.Rejected);
+ s = r.State;
+ if (s.Date == new DateTime(1949, 4, 15)) april = s.Debt;
+ if (crisis == null && s.ActiveSituations.Contains(EconomySystem.FxCrisis)) crisis = s.Date;
+ }
+ return (april!.Value, s, crisis, s.DollarsConverted);
+ }
+
+ // R-MONEY-004, #813's measurement (https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6564855158):
+ // with no lever the debt is IL 40.59m on 15 April 1949 and IL 180.44m at the end, the first crisis on 15 December 1951.
+ // The prototype converted $4m a month in the war (11 turns, $44m) at IL 0.36 per $: IL 15.84m less debt (24.75 and
+ // 164.60) and the crisis on 15 March 1951. The game converts at the sourced war-time rate, IL 0.333 per $ (#813
+ // comment 6565039439). Every war turn ends with the Treasury at 0 and a deficit larger than the conversion, so each
+ // IL converted is an IL not borrowed: the debt falls by exactly 44 * 0.333 = IL 14.652m, to IL 25.94m on 15 April 1949
+ // and IL 165.79m at the end. The foreign currency is the prototype's, so the crisis still comes on 15 March 1951.
+ [Fact]
+ public void TheWarOnlyRunReproducesThePrototypeAtTheSourcedRate()
+ {
+ var none = Prototype(0);
+ Assert.Equal((40.59, 180.44), (Math.Round(none.April1949, 2), Math.Round(none.End.Debt, 2)));
+ Assert.Equal(new DateTime(1951, 12, 15), none.Crisis);
+ var sold = Prototype(4);
+ Assert.Equal(44, sold.Converted);
+ var saved = 44 * 0.333;
+ Assert.Equal(none.April1949 - saved, sold.April1949, 9);
+ Assert.Equal(none.End.Debt - saved, sold.End.Debt, 9);
+ Assert.Equal((25.94, 165.79), (Math.Round(sold.April1949, 2), Math.Round(sold.End.Debt, 2)));
+ Assert.Equal(new DateTime(1951, 3, 15), sold.Crisis);
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.cs
index ce7cbfa0e..0ee7d9131 100644
--- a/sim/Statecraft.Sim.Tests/Fixture.cs
+++ b/sim/Statecraft.Sim.Tests/Fixture.cs
@@ -245,7 +245,7 @@ series:
}
/// <summary>The fixture's attention_cost line with the GDD command kinds added (replaces "map_action: 1 }").</summary>
- public const string GddCosts = "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1, reinforce: 1, return_craftsmen: 0.5, reassign_craftsmen: 0.5, reassign_pioneers: 0, pioneer_work: 0, stop_work: 0, start_project: 1, cancel_project: 0.5, buy_arms: 1, move: 0, unit_order: 0, resolve_capture: 0, end_occupation: 0 }";
+ public const string GddCosts = "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1, reinforce: 1, return_craftsmen: 0.5, reassign_craftsmen: 0.5, reassign_pioneers: 0, pioneer_work: 0, stop_work: 0, start_project: 1, cancel_project: 0.5, buy_arms: 1, convert_dollars: 0, move: 0, unit_order: 0, resolve_capture: 0, end_occupation: 0 }";
public const string GddRules = @"
mvp:
@@ -280,6 +280,9 @@ mvp:
arms_start: 20
arms_price: 0.25
arms_per_recruit_group: 2
+ dollars_per_turn: 4
+ dollars_total: 10
+ il_per_dollar: [{ from: 1948-05-15, rate: 0.5, status: sourced }, { from: 1948-08-15, rate: 0.25, status: sourced }]
military_upkeep_per_turn: 0.1
veteran_soldier_service: 3
veteran_halutz_service: 4
diff --git a/sim/Statecraft.Sim.Tests/NoAttentionTests.cs b/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
index 9cf287e3a..78ec6f149 100644
--- a/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
+++ b/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
@@ -49,6 +49,7 @@ public class NoAttentionTests
case "move":s.Units[99]=new Unit(99,"recruit",1,0,side:"israel",strength:1);valid=new Move(99,2,0);invalid=new Move(999,2,0);break;
case "unit_order":s.Units[99]=new Unit(99,"recruit",1,0,side:"israel",strength:1);valid=new UnitOrder(99,"fortify");invalid=new UnitOrder(999,"fortify");break;
case "buy_arms":valid=new BuyArms(1);invalid=new BuyArms(0);break;
+ case "convert_dollars":valid=new ConvertDollars(1);invalid=new ConvertDollars(0);break; // R-MONEY-004
case "resolve_capture":s.Units[99]=CaptureTests.Soldier(99,1,0);s.Settlements["town_a"]=new SettlementControl("israel",SettlementControl.AwaitingChoice,s.Date);valid=new ResolveCapture("town_a","raid");invalid=new ResolveCapture("town_a","missing");break;
case "end_occupation":s.Units[99]=CaptureTests.Soldier(99,1,0);s.Settlements["town_a"]=new SettlementControl("israel",SettlementControl.AwaitingEnd,s.Date);valid=new EndOccupation("town_a","withdraw");invalid=new EndOccupation("town_a","missing");break;
}
@@ -56,7 +57,7 @@ public class NoAttentionTests
}
[Fact] public void CoversEveryConcreteCommand()
{
- Assert.Equal(23,Kinds().Count());
+ Assert.Equal(24,Kinds().Count());
Assert.Equal(CommandGuardTests.Samples.Keys.OrderBy(t=>t.Name),typeof(Command).Assembly.GetTypes().Where(t=>t.IsSubclassOf(typeof(Command))&&!t.IsAbstract).OrderBy(t=>t.Name));
}
[Theory] [MemberData(nameof(Kinds))]
diff --git a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
index 21630f5fd..a76ef5ccb 100644
--- a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
+++ b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
@@ -115,7 +115,7 @@ public class RemainingCauseKeysTests
sites++;
}
}
- Assert.Equal(106, sites); // 106 since #2212: EconomySystem.OtherMoney's line (105 since #2199: PayOrBorrow's Paid line)
+ Assert.Equal(107, sites); // 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.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
index 31ba9162c..afaee1477 100644
--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs
+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
@@ -29,7 +29,7 @@ public class SaveGameTests
new Command[] { new SetPolicy("odd id with spaces%", 0.5), new MapAction("transit_camp", 4, 0) },
new Command[] { new AssignWorkers("town_a", "job", 1), new UnitOrder(1, "hold") }, // GDD orders: the legacy fixture refuses them
new Command[] { new Train("town_a", "halutz", 1), new CancelTraining(1), new ReturnCraftsmen("town_a", 1), new ReassignCraftsmen("town_a", 1), new ReassignPioneers("town_a", "halutz", 1), new Reinforce(1, "town_a", 1) }, // GDD orders too
- new Command[] { new PioneerWork(1, "build_yishuv", "site_a"), new StopWork(1), new StartProject("housing", "town_a", 1, 1), new CancelProject(1), new BuyArms(2), new Move(1, -2, 3), new ResolveCapture("town_a", "raid"), new EndOccupation("town_a", "annex") },
+ new Command[] { new PioneerWork(1, "build_yishuv", "site_a"), new StopWork(1), new StartProject("housing", "town_a", 1, 1), new CancelProject(1), new BuyArms(2), new ConvertDollars(1), new Move(1, -2, 3), new ResolveCapture("town_a", "raid"), new EndOccupation("town_a", "annex") },
new Command[] { new SecurityOrder(1) }, new Command[0],
};
foreach (var o in orders) g.Step(o);
diff --git a/sim/Statecraft.Sim/AttentionSystem.cs b/sim/Statecraft.Sim/AttentionSystem.cs
index 0af35d926..808f998a8 100644
--- a/sim/Statecraft.Sim/AttentionSystem.cs
+++ b/sim/Statecraft.Sim/AttentionSystem.cs
@@ -9,11 +9,11 @@ namespace Statecraft.Sim
public static class AttentionSystem
{
static readonly HashSet<string> Kinds = new HashSet<string>
- { "set_policy", "allocate_budget", "choose_event_option", "set_mobilization", "security_order", "appoint", "map_action", "assign_workers", "train", "cancel_training", "reinforce", "return_craftsmen", "reassign_craftsmen", "reassign_pioneers", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "move", "unit_order", "resolve_capture", "end_occupation" };
+ { "set_policy", "allocate_budget", "choose_event_option", "set_mobilization", "security_order", "appoint", "map_action", "assign_workers", "train", "cancel_training", "reinforce", "return_craftsmen", "reassign_craftsmen", "reassign_pioneers", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "convert_dollars", "move", "unit_order", "resolve_capture", "end_occupation" };
/// <summary>The kinds only the GDD v0.1 loop runs. Rules price them only when systems.loop is gdd, and the legacy loop
/// refuses them before charging Attention.</summary>
- static readonly HashSet<string> GddKinds = new HashSet<string> { "assign_workers", "train", "cancel_training", "reinforce", "return_craftsmen", "reassign_craftsmen", "reassign_pioneers", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "move", "unit_order", "resolve_capture", "end_occupation" };
+ static readonly HashSet<string> GddKinds = new HashSet<string> { "assign_workers", "train", "cancel_training", "reinforce", "return_craftsmen", "reassign_craftsmen", "reassign_pioneers", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "convert_dollars", "move", "unit_order", "resolve_capture", "end_occupation" };
public static IReadOnlyCollection<string> CommandKinds => Kinds;
diff --git a/sim/Statecraft.Sim/Cause.cs b/sim/Statecraft.Sim/Cause.cs
index 7516e2f89..a397994c9 100644
--- a/sim/Statecraft.Sim/Cause.cs
+++ b/sim/Statecraft.Sim/Cause.cs
@@ -130,6 +130,8 @@ namespace Statecraft.Sim
public const string ProjectCompleted = "project_completed";
/// <summary>Args: CauseKeys.Number(cost).</summary>
public const string ArmsBought = "arms_bought";
+ /// <summary>Args: CauseKeys.Number(amount), the US$ millions converted.</summary>
+ public const string DollarsConverted = "dollars_converted";
/// <summary>Args: f.Id.</summary>
public const string FoodHarvest = "food_harvest";
/// <summary>Args: CauseKeys.Number(need).</summary>
@@ -248,7 +250,7 @@ namespace Statecraft.Sim
EventNew, EventChosen, EventDelegated, EventDelegatedPartial, EventAmount, EventStock, EventGrant, EventCity,
EventUnlock, EventPolicy, EventSetRung, EventRejoin, MilitaryUpkeep,
ObjectiveCompleted, PrisonersReturned, SoldiersReturned,
- WorkersAssigned, WagesPaid, ImmigrantsHoused, HousingShortage, ImmigrantsWaiting, RecruitsVeteran, CorridorStarted, CorridorCancelled, CorridorCompleted, PioneersVeteran, MapBorrowed, MapBuilt, LandWorkStarted, SiteStarted, SiteCancelled, SiteCompleted, ProjectStarted, ProjectCancelled, ProjectCompleted, ArmsBought, FoodHarvest, FoodShortage, FoodWithoutImports, PrisonerFood, PrisonerFoodShortage, CraftsmenReturned, CraftsmenReassigned, PioneerReturned, PioneersReassigned, TrainingStarted, TrainingArms, TrainingCancelled, TrainingArmsReturned, ReplacementsStopped, ReplacementsJoined, MilitaryTrained, PioneersTrained, CraftsmenTrained, Appointed, Reshuffle, AppointmentsEnded, ApprovalStability, CoalitionCollapsed, LegislatureConvened, GovernmentTookOffice, CoalitionChanged, EraEnded, AdvisoryPolicyRejected, PolicyRejected, PolicySet, AdvisoryBudgetRejected, BudgetRejected, PlaceCaptured, EnemyRegained, PlaceAnnexed, PlaceWithdrawn, PlaceDeported, DeportEffect, DeportCost, OccupationStarted, PendingBecameRaid, OccupationLostUnit, OccupationCountdown, DepopulationSupport,
+ WorkersAssigned, WagesPaid, ImmigrantsHoused, HousingShortage, ImmigrantsWaiting, RecruitsVeteran, CorridorStarted, CorridorCancelled, CorridorCompleted, PioneersVeteran, MapBorrowed, MapBuilt, LandWorkStarted, SiteStarted, SiteCancelled, SiteCompleted, ProjectStarted, ProjectCancelled, ProjectCompleted, ArmsBought, DollarsConverted, FoodHarvest, FoodShortage, FoodWithoutImports, PrisonerFood, PrisonerFoodShortage, CraftsmenReturned, CraftsmenReassigned, PioneerReturned, PioneersReassigned, TrainingStarted, TrainingArms, TrainingCancelled, TrainingArmsReturned, ReplacementsStopped, ReplacementsJoined, MilitaryTrained, PioneersTrained, CraftsmenTrained, Appointed, Reshuffle, AppointmentsEnded, ApprovalStability, CoalitionCollapsed, LegislatureConvened, GovernmentTookOffice, CoalitionChanged, EraEnded, AdvisoryPolicyRejected, PolicyRejected, PolicySet, AdvisoryBudgetRejected, BudgetRejected, PlaceCaptured, EnemyRegained, PlaceAnnexed, PlaceWithdrawn, PlaceDeported, DeportEffect, DeportCost, OccupationStarted, PendingBecameRaid, OccupationLostUnit, OccupationCountdown, DepopulationSupport,
};
/// <summary>A number as an Arg: invariant and round-trip, so the UI rounds exactly the value Message rounded.</summary>
diff --git a/sim/Statecraft.Sim/Commands.cs b/sim/Statecraft.Sim/Commands.cs
index fed829f94..c948145d4 100644
--- a/sim/Statecraft.Sim/Commands.cs
+++ b/sim/Statecraft.Sim/Commands.cs
@@ -188,6 +188,15 @@ namespace Statecraft.Sim
public BuyArms(int count) { Count = count; }
}
+ /// <summary>Converts <see cref="Amount"/> US$ millions of foreign currency into Money during the war (EconomySystem.ConvertDollars,
+ /// R-MONEY-004; #813, owner 2 November 2026: "Spend the dollars (Recommended)"). GDD loop only.</summary>
+ public sealed class ConvertDollars : Command
+ {
+ public override string Kind => EconomySystem.ConvertDollarsKind;
+ public int Amount { get; }
+ public ConvertDollars(int amount) { Amount = amount; }
+ }
+
/// <summary>Answers the capture of <see cref="Settlement"/> with <see cref="Outcome"/>: raid, occupy or deport
/// (SettlementControl.Resolve, R-CTRL-007 to R-CTRL-010). One kind for every outcome, so they cost the same Attention
/// (Q-TECH-3). GDD v0.1 loop only.</summary>
@@ -263,6 +272,7 @@ namespace Statecraft.Sim
case CancelProject _: break;
case Move _: break;
case BuyArms _: break;
+ case ConvertDollars _: break;
case ResolveCapture r: Text(r.Settlement, "Settlement"); Text(r.Outcome, "Outcome"); break;
case EndOccupation e: Text(e.Settlement, "Settlement"); Text(e.Outcome, "Outcome"); break;
case SetMobilization _: case SecurityOrder _: break;
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 58691ed6c..dc27a0f6c 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -590,6 +590,19 @@ namespace Statecraft.Sim
/// <summary>The Arms one recruit group takes when its training starts (R-ARMS-003; D-G6, Q-UNIT-3, #781). Required in the
/// GDD loop, &gt;= 0.</summary>
public int? ArmsPerRecruitGroup { get; set; }
+ /// <summary>The most foreign currency, in US$ millions, the player may convert into Money in one turn (R-MONEY-004; #813).
+ /// Required in the GDD loop, &gt;= 0.</summary>
+ public int? DollarsPerTurn { get; set; }
+ /// <summary>The most foreign currency, in US$ millions, the player may convert in the whole game (R-MONEY-004; #813).
+ /// Required in the GDD loop, &gt;= 0.</summary>
+ public int? DollarsTotal { get; set; }
+ /// <summary>IL millions of Money one US$ million of foreign currency converts into, by date (R-MONEY-004; #813): each
+ /// rate from its day on, the first on or before the game's start, the days in increasing order. Required in the GDD
+ /// loop, each rate finite and &gt;= 0. Read through <see cref="IlPerDollarOn"/>.</summary>
+ public List<DollarRate> IlPerDollar { get; set; } = new List<DollarRate>();
+
+ /// <summary>The rate of <see cref="IlPerDollar"/> in force on <paramref name="date"/>: the last one from on or before it.</summary>
+ public double IlPerDollarOn(DateTime date) => IlPerDollar.Last(x => x.From <= date).Rate;
/// <summary>IL millions per Israeli military formation per turn, not per strength point (R-UNIT-010; Q-UNIT-3).</summary>
public double? MilitaryUpkeepPerTurn { get; set; }
/// <summary>Turns served as a recruit before promotion to veteran_soldier (R-UNIT-004; Q-UNIT-2).</summary>
@@ -886,6 +899,15 @@ namespace Statecraft.Sim
public int? TrainingArms { get; set; }
}
+ /// <summary>One dated exchange rate of mvp.il_per_dollar (R-MONEY-004): IL millions per US$ million from this day (inclusive).
+ /// <see cref="Status"/> is "sourced": the rates are history, not design values (DesignValuesTests skips them).</summary>
+ public sealed class DollarRate
+ {
+ public DateTime From { get; set; }
+ public double Rate { get; set; }
+ public string Status { get; set; } = "";
+ }
+
/// <summary>One stretch of a budget line's ownership (rules.yaml budget_owners): from this day (inclusive) the office owns the line.</summary>
public sealed class BudgetOwnerTerm
{
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index e3f176685..15fe4a5ee 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -1330,6 +1330,19 @@ namespace Statecraft.Sim
if (!(m.ArmsPrice >= 0 && IsFinite(m.ArmsPrice.Value))) throw new ContentException(file, "mvp.arms_price", "must be a finite number >= 0");
if (m.ArmsPerRecruitGroup == null) throw new ContentException(file, "mvp.arms_per_recruit_group", "required when eras.yaml systems.loop is gdd");
if (m.ArmsPerRecruitGroup < 0) throw new ContentException(file, "mvp.arms_per_recruit_group", "must be >= 0");
+ // R-MONEY-004: required, so a missing key never makes the lever free, unlimited or worthless.
+ if (m.DollarsPerTurn == null) throw new ContentException(file, "mvp.dollars_per_turn", "required when eras.yaml systems.loop is gdd");
+ if (m.DollarsPerTurn < 0) throw new ContentException(file, "mvp.dollars_per_turn", "must be >= 0");
+ if (m.DollarsTotal == null) throw new ContentException(file, "mvp.dollars_total", "required when eras.yaml systems.loop is gdd");
+ if (m.DollarsTotal < 0) throw new ContentException(file, "mvp.dollars_total", "must be >= 0");
+ if (m.IlPerDollar.Count == 0) throw new ContentException(file, "mvp.il_per_dollar", "required when eras.yaml systems.loop is gdd (at least one dated rate)");
+ for (int i = 0; i < m.IlPerDollar.Count; i++)
+ {
+ var x = m.IlPerDollar[i]; var at = FormattableString.Invariant($"mvp.il_per_dollar[{i}]");
+ if (!(x.Rate >= 0 && IsFinite(x.Rate))) throw new ContentException(file, at + ".rate", "must be a finite number >= 0");
+ if (i == 0 && x.From > r.Start) throw new ContentException(file, at + ".from", "the first rate must start on or before the start, so every turn has one");
+ if (i > 0 && x.From <= m.IlPerDollar[i - 1].From) throw new ContentException(file, at + ".from", "must be after the previous rate's day");
+ }
// R-UNIT-010, R-UNIT-004: omitted values must not silently make upkeep free or promotion immediate.
if (m.MilitaryUpkeepPerTurn == null) throw new ContentException(file, "mvp.military_upkeep_per_turn", "required when eras.yaml systems.loop is gdd");
if (!(m.MilitaryUpkeepPerTurn >= 0 && IsFinite(m.MilitaryUpkeepPerTurn.Value))) throw new ContentException(file, "mvp.military_upkeep_per_turn", "must be a finite number >= 0");
diff --git a/sim/Statecraft.Sim/EconomySystem.cs b/sim/Statecraft.Sim/EconomySystem.cs
index f859cbdcd..7573f3d82 100644
--- a/sim/Statecraft.Sim/EconomySystem.cs
+++ b/sim/Statecraft.Sim/EconomySystem.cs
@@ -8,6 +8,14 @@ namespace Statecraft.Sim
{
public const string FxCrisis = "fx_crisis";
+ /// <summary>The command kind that converts foreign currency into Money (R-MONEY-004).</summary>
+ public const string ConvertDollarsKind = "convert_dollars";
+ 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";
+ public const string RefusedDollarsTotal = "That would pass the total of dollars that may be converted";
+ public const string RefusedDollarsReserves = "There are not enough dollars in the reserves";
+
public static void Init(Content c, GameState s)
{
s.Treasury = c.Rules.TreasuryStart;
@@ -84,6 +92,46 @@ namespace Statecraft.Sim
s.Treasury = 0;
}
+ /// <summary>R-MONEY-004 (#813; owner, 2 November 2026: "Spend the dollars (Recommended)"): during the war (rung 4 or 5)
+ /// <paramref name="amount"/> US$ millions of foreign currency leave the reserves and amount times the mvp.il_per_dollar rate in
+ /// force on the turn's date, in IL millions, joins the Treasury, so the turn's deficit borrows that much less (R-MONEY-003). Refused, state untouched,
+ /// below $1m, outside the war (<paramref name="startRung"/>, the rung the turn started at, below 4), past
+ /// mvp.dollars_per_turn with <paramref name="thisTurn"/> (this turn's earlier conversions), past mvp.dollars_total, or
+ /// below 0 reserves. Step has already refused it in the legacy loop.</summary>
+ public static string? ConvertDollars(Content c, GameState s, int amount, int thisTurn, int startRung, List<Cause> why)
+ {
+ var refused = DollarsRefusal(c, s, amount, thisTurn, startRung);
+ if (refused != null) return refused;
+ var money = amount * c.RulesAt(s.Date).Mvp!.IlPerDollarOn(s.Date);
+ s.FxReserves -= amount;
+ s.Treasury += money;
+ s.DollarsConverted += amount;
+ why.Add(new Cause("economy", "treasury", money,
+ $"Converted {PlayerText.Money(c, "fx_reserves", amount)} of foreign currency into Money: {PlayerText.MoneyChange(c, "treasury", money)}",
+ key: CauseKeys.DollarsConverted, args: new[] { CauseKeys.Number(amount) }));
+ return null;
+ }
+
+ /// <summary>R-MONEY-004's refusal of <paramref name="amount"/> in <paramref name="s"/>, after <paramref name="thisTurn"/>
+ /// dollars converted earlier in the same turn, or null when it would be carried out. The war is
+ /// <paramref name="startRung"/>, the rung the turn started at (an event's set_rung earlier in the turn does not change
+ /// it), else the state's rung, which is the turn's start before End turn. ConvertDollars refuses on it, and the Defence
+ /// screen says it before End turn.</summary>
+ 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 ((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;
+ if (s.FxReserves - amount < 0) return RefusedDollarsReserves;
+ return null;
+ }
+
+ /// <summary>The lowest rung of the war (R-MONEY-004): the rungs 4 and 5 of the #813 measurement, 15 May 1948 to 15
+ /// March 1949 in the historical run.</summary>
+ public const int WarRung = 4;
+
/// <summary>R-MONEY-002: pays civilian-place upkeep in step 7, prorated by the turn's share of a year.</summary>
public static void PayCivilianUpkeep(Content c, GameState s, MvpRules r, double yearFraction, List<Cause> why)
{
diff --git a/sim/Statecraft.Sim/GameState.cs b/sim/Statecraft.Sim/GameState.cs
index 5e7034116..0d8f57a18 100644
--- a/sim/Statecraft.Sim/GameState.cs
+++ b/sim/Statecraft.Sim/GameState.cs
@@ -122,6 +122,9 @@ namespace Statecraft.Sim
public int ExhaustedTurns;
/// <summary>The national Arms stock (R-ARMS-001; D-G6): one Arms is the equipment package for one 1,000-person recruit group. Never below 0.</summary>
public int Arms;
+ /// <summary>The foreign currency converted into Money so far, in US$ millions (R-MONEY-004, #813): never more than
+ /// mvp.dollars_total.</summary>
+ public int DollarsConverted;
/// <summary>The enemy prisoners held, in population units, by the side of the unit that surrendered (R-POW-001; impact
/// plan section 4.3). Only a surrender in combat adds to it; only a front's exchange card takes from it (R-POW-004).</summary>
public SortedDictionary<string, int> PrisonersHeld = new SortedDictionary<string, int>(StringComparer.Ordinal);
@@ -276,6 +279,7 @@ namespace Statecraft.Sim
}
if (ExhaustedTurns != 0) { Sep(); Nl(); sb.Append("exhausted=").Append(ExhaustedTurns.ToString(CultureInfo.InvariantCulture)); }
if (Arms != 0) { Sep(); Nl(); sb.Append("arms=").Append(Arms.ToString(CultureInfo.InvariantCulture)); }
+ if (DollarsConverted != 0) { Sep(); Nl(); sb.Append("dollars=").Append(DollarsConverted.ToString(CultureInfo.InvariantCulture)); } // R-MONEY-004: only once converted
// Prisoners (R-POW-001 to R-POW-005): written only once a surrender has happened, so a run with none hashes as before.
IEnumerable<string> Counts(SortedDictionary<string, int> m) => m.Select(kv => kv.Key + "=" + kv.Value.ToString(CultureInfo.InvariantCulture));
if (PrisonersHeld.Count > 0) Section("pow", '{', '}', Counts(PrisonersHeld));
diff --git a/sim/Statecraft.Sim/SaveGame.cs b/sim/Statecraft.Sim/SaveGame.cs
index 1f19d8b62..228c723d9 100644
--- a/sim/Statecraft.Sim/SaveGame.cs
+++ b/sim/Statecraft.Sim/SaveGame.cs
@@ -39,7 +39,7 @@ namespace Statecraft.Sim
/// &lt;command&gt; ... policy ID LEVEL | budget OFFICE=SHARE,... | event ID OPTION | mobilize LEVEL |
/// security DELTA | appoint OFFICE PERSON | map ACTION Q R | work CITY ROLE N |
/// train CITY TRACK N | untrain COHORT | pioneer UNIT ACTION SITE | stop UNIT |
- /// project KIND CITY Q R | unproject PROJECT | arms N |
+ /// project KIND CITY Q R | unproject PROJECT | arms N | dollars N |
/// capture SETTLEMENT OUTCOME
/// open starts the turn in progress's committed command list; it comes after every turn
/// end &lt;hex&gt; GameState.Hash() after the last turn (checks the replay)
@@ -161,6 +161,7 @@ namespace Statecraft.Sim
CancelProject p => $"unproject {Int(p.Project)}",
Move m => $"move {Int(m.Unit)} {Int(m.Q)} {Int(m.R)}",
BuyArms a => $"arms {Int(a.Count)}",
+ ConvertDollars d => $"dollars {Int(d.Amount)}",
ResolveCapture r => $"capture {Esc(r.Settlement)} {Esc(r.Outcome)}",
EndOccupation e => $"endocc {Esc(e.Settlement)} {Esc(e.Outcome)}",
_ => throw new ArgumentException($"Cannot save command kind '{cmd.Kind}'", nameof(cmd)),
@@ -295,6 +296,7 @@ namespace Statecraft.Sim
case "unproject": Arity(2); return new CancelProject(I(f[1]));
case "move": Arity(4); return new Move(I(f[1]), I(f[2]), I(f[3]));
case "arms": Arity(2); return new BuyArms(I(f[1]));
+ case "dollars": Arity(2); return new ConvertDollars(I(f[1]));
case "capture": Arity(3); return new ResolveCapture(Str(f[1]), Str(f[2]));
case "endocc": Arity(3); return new EndOccupation(Str(f[1]), Str(f[2]));
default: throw new SaveException(line, $"unknown command '{f[0]}'");
diff --git a/sim/Statecraft.Sim/Scenario.cs b/sim/Statecraft.Sim/Scenario.cs
index 92ca5251c..4f2afeffc 100644
--- a/sim/Statecraft.Sim/Scenario.cs
+++ b/sim/Statecraft.Sim/Scenario.cs
@@ -70,7 +70,7 @@ namespace Statecraft.Sim
["unit_order"] = new[] { "unit", "order", "q", "r" }, // q and r: an attack's hex only (R-COMBAT-001)
["start_project"] = new[] { "project", "city", "q", "r" }, ["cancel_project"] = new[] { "project" },
["move"] = new[] { "unit", "q", "r" },
- ["buy_arms"] = new[] { "count" }, ["resolve_capture"] = new[] { "settlement", "outcome" },
+ ["buy_arms"] = new[] { "count" }, ["convert_dollars"] = new[] { "amount" }, ["resolve_capture"] = new[] { "settlement", "outcome" },
["end_occupation"] = new[] { "settlement", "outcome" },
};
@@ -110,6 +110,7 @@ namespace Statecraft.Sim
case "cancel_project": return new CancelProject(Whole(c, "project"));
case "move": return new Move(Whole(c, "unit"), Whole(c, "q"), Whole(c, "r"));
case "buy_arms": return new BuyArms(Whole(c, "count"));
+ case "convert_dollars": return new ConvertDollars(Whole(c, "amount"));
case "resolve_capture": return new ResolveCapture(Str(c, "settlement"), Str(c, "outcome"));
case "end_occupation": return new EndOccupation(Str(c, "settlement"), Str(c, "outcome"));
default: throw new InvalidDataException($"command kind '{kind}' has no builder");
@@ -156,7 +157,7 @@ namespace Statecraft.Sim
UnitOrder o => FormattableString.Invariant($"{o.Unit} {o.Order}") + (o.Q is int q && o.R is int r ? FormattableString.Invariant($" {q},{r}") : ""),
StartProject p => FormattableString.Invariant($"{p.ProjectKind} {p.City} {p.Q},{p.R}"), CancelProject p => p.Project.ToString(CultureInfo.InvariantCulture),
Move m => FormattableString.Invariant($"{m.Unit} {m.Q},{m.R}"),
- BuyArms a => a.Count.ToString(CultureInfo.InvariantCulture), ResolveCapture r => $"{r.Settlement} {r.Outcome}",
+ BuyArms a => a.Count.ToString(CultureInfo.InvariantCulture), ConvertDollars d => d.Amount.ToString(CultureInfo.InvariantCulture), ResolveCapture r => $"{r.Settlement} {r.Outcome}",
EndOccupation e => $"{e.Settlement} {e.Outcome}",
_ => c.Kind,
};
diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.cs
index 4f903bb3c..2ad243b38 100644
--- a/sim/Statecraft.Sim/Simulation.cs
+++ b/sim/Statecraft.Sim/Simulation.cs
@@ -133,15 +133,17 @@ namespace Statecraft.Sim
/// for End turn (spec 2026-10-23 section 3.2).</summary>
public static bool IsInstant(Command cmd) => cmd is Move || (cmd is UnitOrder o && o.Order != Demobilization.SendHome);
- /// <summary>The turn's orders in order: each pays Attention first; one that fails validation is refunded and
- /// rejected with its reason. Step, DelegatedTo and Preview share it, so every dry run sees what End Turn will.</summary>
+ /// <summary>The turn's orders in queue order, conversions before Arms purchases (ConversionsBeforeArms): each pays
+ /// Attention first; one that fails validation is refunded and rejected with its reason. Step, DelegatedTo and Preview
+ /// share it, so every dry run sees what End Turn will.</summary>
static void RunOrders(Content c, GameState s, IReadOnlyList<Command> commands, Dictionary<int, int> spent,
Dictionary<int, (int Q, int R)> attacked, List<Cause> why, List<Rejection> rejected)
{
if (c.IsGdd) Movement.ContinueRoutes(c, s, spent, why); // R-MOVE-009: the route step, before the turn's orders
if (c.IsGdd) SettlementControl.CaptureHeld(c, s, why);
- var priceRung = s.Rung; // every command this turn is priced at the rung the turn started at
- foreach (var cmd in commands)
+ var priceRung = s.Rung; // every command this turn is priced at the rung the turn started at (R-MONEY-004's war is that rung too)
+ var dollarsAtStart = s.DollarsConverted; // R-MONEY-004: the turn's limit counts every conversion order in it
+ foreach (var cmd in ConversionsBeforeArms(commands))
{
if (!AttentionSystem.IsCommandKind(cmd.Kind)) { rejected.Add(new Rejection(cmd, "That order is not known")); continue; }
// A GDD order has no price in the legacy rules: refuse it before charging (R-CITY-001).
@@ -153,20 +155,33 @@ namespace Statecraft.Sim
if (c.UsesAttention)
{
var before = s.Attention;
- error = AttentionSystem.TrySpend(c, s, cmd.Kind, priceRung) ?? Execute(c, s, cmd, spent, attacked, why);
+ error = AttentionSystem.TrySpend(c, s, cmd.Kind, priceRung) ?? Execute(c, s, cmd, spent, attacked, why, priceRung, dollarsAtStart);
if (error != null) s.Attention = before;
}
- else error = Execute(c, s, cmd, spent, attacked, why);
+ else error = Execute(c, s, cmd, spent, attacked, why, priceRung, dollarsAtStart);
if (error != null) rejected.Add(new Rejection(cmd, error));
if (c.IsGdd) SettlementControl.CaptureHeld(c, s, why); // R-CTRL-004: only where an order ends
}
}
+ /// <summary>The turn's orders in the order they run (#2206; R-ARMS-002, R-MONEY-004; owner, 2 November 2026:
+ /// "Conversion counts first (Recommended)"): queue order, except that the dollar conversions queued after the turn's
+ /// first Arms purchase run just before it, in their queue order, so a conversion's Money counts for the purchase
+ /// whatever the order of the clicks. Every other order keeps its place.</summary>
+ static IEnumerable<Command> ConversionsBeforeArms(IReadOnlyList<Command> commands)
+ {
+ var buy = -1;
+ for (int i = 0; i < commands.Count && buy < 0; i++) if (commands[i] is BuyArms) buy = i;
+ if (buy < 0) return commands;
+ var rest = commands.Skip(buy);
+ return commands.Take(buy).Concat(rest.Where(x => x is ConvertDollars)).Concat(rest.Where(x => !(x is ConvertDollars)));
+ }
+
/// <summary>Returns null when the command was carried out (a lost vote counts: it consumes the RNG draw and is
/// reported as a politics cause), or the reason it failed validation. A command that fails validation leaves
/// the state as it found it (attention is refunded by the caller).</summary>
static string? Execute(Content c, GameState s, Command cmd, Dictionary<int, int> spent,
- Dictionary<int, (int Q, int R)> attacked, List<Cause> why)
+ Dictionary<int, (int Q, int R)> attacked, List<Cause> why, int startRung, int dollarsAtStart)
{
switch (cmd)
{
@@ -249,6 +264,8 @@ namespace Statecraft.Sim
return Movement.Move(c, s, m.Unit, m.Q, m.R, spent, why);
case BuyArms a:
return Pools.BuyArms(c, s, a.Count, why);
+ case ConvertDollars d:
+ return EconomySystem.ConvertDollars(c, s, d.Amount, s.DollarsConverted - dollarsAtStart, startRung, why);
case ResolveCapture x:
return SettlementControl.Resolve(c, s, x.Settlement, x.Outcome, why);
case EndOccupation x:
diff --git a/unity/Assets/Scripts/UI/CauseText.cs b/unity/Assets/Scripts/UI/CauseText.cs
index bc796b1a0..5015ccace 100644
--- a/unity/Assets/Scripts/UI/CauseText.cs
+++ b/unity/Assets/Scripts/UI/CauseText.cs
@@ -87,7 +87,7 @@ namespace Statecraft.Game.UI
// #1682: these branches use captured ids, values and resident flags, never the live GameState.
static readonly HashSet<string> RemainingKeys = new HashSet<string>
{
- CauseKeys.WorkersAssigned, CauseKeys.WagesPaid, CauseKeys.ImmigrantsHoused, CauseKeys.HousingShortage, CauseKeys.ImmigrantsWaiting, CauseKeys.RecruitsVeteran, CauseKeys.CorridorStarted, CauseKeys.CorridorCancelled, CauseKeys.CorridorCompleted, CauseKeys.PioneersVeteran, CauseKeys.MapBorrowed, CauseKeys.MapBuilt, CauseKeys.LandWorkStarted, CauseKeys.SiteStarted, CauseKeys.SiteCancelled, CauseKeys.SiteCompleted, CauseKeys.ProjectStarted, CauseKeys.ProjectCancelled, CauseKeys.ProjectCompleted, CauseKeys.ArmsBought, CauseKeys.FoodHarvest, CauseKeys.FoodShortage, CauseKeys.FoodWithoutImports, CauseKeys.PrisonerFood, CauseKeys.PrisonerFoodShortage, CauseKeys.CraftsmenReturned, CauseKeys.CraftsmenReassigned, CauseKeys.PioneerReturned, CauseKeys.PioneersReassigned, CauseKeys.TrainingStarted, CauseKeys.TrainingArms, CauseKeys.TrainingCancelled, CauseKeys.TrainingArmsReturned, CauseKeys.ReplacementsStopped, CauseKeys.ReplacementsJoined, CauseKeys.MilitaryTrained, CauseKeys.PioneersTrained, CauseKeys.CraftsmenTrained, CauseKeys.Appointed, CauseKeys.Reshuffle, CauseKeys.AppointmentsEnded, CauseKeys.ApprovalStability, CauseKeys.CoalitionCollapsed, CauseKeys.LegislatureConvened, CauseKeys.GovernmentTookOffice, CauseKeys.CoalitionChanged, CauseKeys.EraEnded, CauseKeys.AdvisoryPolicyRejected, CauseKeys.PolicyRejected, CauseKeys.PolicySet, CauseKeys.AdvisoryBudgetRejected, CauseKeys.BudgetRejected, CauseKeys.PlaceCaptured, CauseKeys.EnemyRegained, CauseKeys.PlaceAnnexed, CauseKeys.PlaceWithdrawn, CauseKeys.PlaceDeported, CauseKeys.DeportEffect, CauseKeys.DeportCost, CauseKeys.OccupationStarted, CauseKeys.PendingBecameRaid, CauseKeys.OccupationLostUnit, CauseKeys.OccupationCountdown, CauseKeys.DepopulationSupport
+ CauseKeys.WorkersAssigned, CauseKeys.WagesPaid, CauseKeys.ImmigrantsHoused, CauseKeys.HousingShortage, CauseKeys.ImmigrantsWaiting, CauseKeys.RecruitsVeteran, CauseKeys.CorridorStarted, CauseKeys.CorridorCancelled, CauseKeys.CorridorCompleted, CauseKeys.PioneersVeteran, CauseKeys.MapBorrowed, CauseKeys.MapBuilt, CauseKeys.LandWorkStarted, CauseKeys.SiteStarted, CauseKeys.SiteCancelled, CauseKeys.SiteCompleted, CauseKeys.ProjectStarted, CauseKeys.ProjectCancelled, CauseKeys.ProjectCompleted, CauseKeys.ArmsBought, CauseKeys.DollarsConverted, CauseKeys.FoodHarvest, CauseKeys.FoodShortage, CauseKeys.FoodWithoutImports, CauseKeys.PrisonerFood, CauseKeys.PrisonerFoodShortage, CauseKeys.CraftsmenReturned, CauseKeys.CraftsmenReassigned, CauseKeys.PioneerReturned, CauseKeys.PioneersReassigned, CauseKeys.TrainingStarted, CauseKeys.TrainingArms, CauseKeys.TrainingCancelled, CauseKeys.TrainingArmsReturned, CauseKeys.ReplacementsStopped, CauseKeys.ReplacementsJoined, CauseKeys.MilitaryTrained, CauseKeys.PioneersTrained, CauseKeys.CraftsmenTrained, CauseKeys.Appointed, CauseKeys.Reshuffle, CauseKeys.AppointmentsEnded, CauseKeys.ApprovalStability, CauseKeys.CoalitionCollapsed, CauseKeys.LegislatureConvened, CauseKeys.GovernmentTookOffice, CauseKeys.CoalitionChanged, CauseKeys.EraEnded, CauseKeys.AdvisoryPolicyRejected, CauseKeys.PolicyRejected, CauseKeys.PolicySet, CauseKeys.AdvisoryBudgetRejected, CauseKeys.BudgetRejected, CauseKeys.PlaceCaptured, CauseKeys.EnemyRegained, CauseKeys.PlaceAnnexed, CauseKeys.PlaceWithdrawn, CauseKeys.PlaceDeported, CauseKeys.DeportEffect, CauseKeys.DeportCost, CauseKeys.OccupationStarted, CauseKeys.PendingBecameRaid, CauseKeys.OccupationLostUnit, CauseKeys.OccupationCountdown, CauseKeys.DepopulationSupport
};
static string Remaining(Cause cause, Content c, UiText text, IReadOnlyDictionary<string, string>? namesHe)
@@ -152,6 +152,8 @@ namespace Statecraft.Game.UI
return text.Format(key, Settlement(cause.Target), ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == A(0))));
case CauseKeys.ArmsBought:
return text.Format(key, cause.Delta, Money(c, "treasury", A(0)));
+ case CauseKeys.DollarsConverted:
+ return text.Format(key, Money(c, "fx_reserves", A(0)), PlayerText.MoneyChange(c, "treasury", cause.Delta));
case CauseKeys.FoodHarvest:
return text.Format(key, Site(A(0)), cause.Delta);
case CauseKeys.FoodShortage:
diff --git a/unity/Assets/Scripts/UI/DefencePresenter.cs b/unity/Assets/Scripts/UI/DefencePresenter.cs
index 2dda109e0..f23278bc9 100644
--- a/unity/Assets/Scripts/UI/DefencePresenter.cs
+++ b/unity/Assets/Scripts/UI/DefencePresenter.cs
@@ -23,6 +23,7 @@ namespace Statecraft.Game.UI
/// <summary>The leadership portrait box in logical pixels (Statecraft.uss .leader .card-portrait).</summary>
public static readonly UnityEngine.Vector2 LeaderPortrait = new UnityEngine.Vector2(190f, 200f);
readonly ArmsPurchasePresenter arms;
+ readonly DollarConversionPresenter dollars;
readonly VisualElement screen; readonly SimBridge bridge; readonly UiText text; readonly PortraitCatalog? portraits;
readonly Button escalate, deEscalate, mobUp, mobDown; readonly Action onEscalate, onDeEscalate, onMobUp, onMobDown;
@@ -39,6 +40,7 @@ namespace Statecraft.Game.UI
screen.Q<Label>("defence-title-prisoners").text = text["defence.section_prisoners"].ToUpperInvariant(); // #755, as Sections
deEscalate.text = text["defence.lower"]; escalate.text = text["defence.raise"];
arms = new ArmsPurchasePresenter(screen, bridge, text);
+ dollars = new DollarConversionPresenter(screen, bridge, text);
bridge.Changed += OnChanged;
ScreenNav.OnOpened(screen, () => { if (dirty) Render(); });
Render();
@@ -62,6 +64,7 @@ namespace Statecraft.Game.UI
public void Dispose()
{
arms.Dispose();
+ dollars.Dispose();
bridge.Changed -= OnChanged;
if (screen.userData is System.Action) screen.userData = null;
escalate.clicked -= onEscalate; deEscalate.clicked -= onDeEscalate; mobUp.clicked -= onMobUp; mobDown.clicked -= onMobDown;
diff --git a/unity/Assets/Scripts/UI/DollarConversionPresenter.cs b/unity/Assets/Scripts/UI/DollarConversionPresenter.cs
new file mode 100644
index 000000000..b5dac17a4
--- /dev/null
+++ b/unity/Assets/Scripts/UI/DollarConversionPresenter.cs
@@ -0,0 +1,113 @@
+#nullable enable
+using System;
+using Statecraft.Sim;
+using UnityEngine.UIElements;
+
+namespace Statecraft.Game.UI
+{
+ /// <summary>The Defence screen's dollar conversion (#813, R-MONEY-004; owner, 2 November 2026: "Spend the dollars
+ /// (Recommended)"): one replaceable ConvertDollars at End turn, as the Arms purchase. It shows the foreign-currency reserve
+ /// beside this order (the top bar's Foreign currency meter stays; owner, 2 November 2026: "Keep it"), and the sim's own
+ /// refusal before End turn. With a conversion queued, a new amount in the box replaces it at once, or withdraws it when the
+ /// sim refuses the amount ("Box shows queued order (Recommended)"); outside the war the panel stays visible but disabled,
+ /// with the reason ("Grey it with the reason (Recommended)"). The reserve and Money change only when the sim executes the
+ /// order.</summary>
+ public sealed class DollarConversionPresenter : IDisposable
+ {
+ readonly VisualElement panel;
+ readonly SimBridge bridge;
+ readonly UiText text;
+ readonly IntegerField amount;
+ readonly Button convert, withdraw;
+ readonly Action onConvert, onWithdraw;
+ readonly EventCallback<ChangeEvent<int>> onAmount;
+ readonly PressSource presses;
+
+ public DollarConversionPresenter(VisualElement root, SimBridge bridge, UiText text)
+ {
+ panel = root.Q("defence-dollars"); this.bridge = bridge; this.text = text;
+ amount = panel.Q<IntegerField>("dollars-amount");
+ convert = panel.Q<Button>("convert-dollars"); withdraw = panel.Q<Button>("withdraw-dollars");
+ amount.label = text["dollars.amount"];
+ panel.Q<Label>("dollars-title").text = text["dollars.title"];
+ panel.Q<Label>("dollars-cost").text = text["dollars.cost"];
+ convert.text = text["dollars.convert"]; withdraw.text = text["dollars.withdraw"];
+ onConvert = () =>
+ {
+ // An amount the sim already refuses is never queued: the panel keeps showing why (Render).
+ if (bridge.Content.IsGdd && bridge.State.GameOver == null
+ && EconomySystem.DollarsRefusal(bridge.Content, bridge.State, amount.value) != null) { Render(); return; }
+ var reason = bridge.Queue(new ConvertDollars(amount.value));
+ Render();
+ if (reason != null) panel.Q<Label>("dollars-refusal").text = reason;
+ };
+ presses = new PressSource(panel);
+ onWithdraw = () =>
+ {
+ var queued = bridge.QueuedLike(new ConvertDollars(1));
+ if (queued == null) return;
+ var keyboard = presses.ByKeyboard;
+ bridge.Withdraw(queued);
+ // Render has just disabled Withdraw, which had the focus. Keep the keyboard in the panel: Convert, else the amount.
+ if (keyboard) FocusReturn.ToOrWithin(convert, null, panel);
+ };
+ onAmount = _ =>
+ {
+ // The box is the queued order: a new amount replaces it at once, and one the sim refuses withdraws it, so the
+ // box, the Money line and what End turn converts always agree.
+ string? reason = null;
+ if (bridge.Content.IsGdd && bridge.State.GameOver == null
+ && bridge.QueuedLike(new ConvertDollars(1)) is ConvertDollars queued && queued.Amount != amount.value)
+ {
+ if (EconomySystem.DollarsRefusal(bridge.Content, bridge.State, amount.value) != null) bridge.Withdraw(queued);
+ else if ((reason = bridge.Queue(new ConvertDollars(amount.value))) != null) bridge.Withdraw(queued);
+ }
+ Render();
+ if (reason != null) panel.Q<Label>("dollars-refusal").text = reason;
+ };
+ convert.clicked += onConvert; withdraw.clicked += onWithdraw; amount.RegisterValueChangedCallback(onAmount);
+ bridge.Changed += Render;
+ // The amount starts at the month's limit, or at the order already queued this turn.
+ if (bridge.QueuedLike(new ConvertDollars(1)) is ConvertDollars old) amount.SetValueWithoutNotify(old.Amount);
+ else if (bridge.Content.IsGdd) amount.SetValueWithoutNotify(bridge.Content.RulesAt(bridge.State.Date).Mvp!.DollarsPerTurn!.Value);
+ Render();
+ }
+
+ public void Render()
+ {
+ var c = bridge.Content; var s = bridge.State;
+ panel.style.display = c.IsGdd ? DisplayStyle.Flex : DisplayStyle.None;
+ if (!c.IsGdd) return;
+ var m = c.RulesAt(s.Date).Mvp!;
+ // Outside the war (the rung the turn started at, as the sim judges it) the panel is greyed with the reason.
+ var war = s.Rung >= EconomySystem.WarRung;
+ panel.SetEnabled(war);
+ var order = new ConvertDollars(amount.value);
+ var queued = bridge.QueuedLike(order) as ConvertDollars;
+ panel.Q<Label>("dollars-reserves").text = text.Format("dollars.reserves", PlayerText.Money(c, "fx_reserves", s.FxReserves));
+ panel.Q<Label>("dollars-total").text = text.Format("dollars.total",
+ PlayerText.Money(c, "fx_reserves", s.DollarsConverted), PlayerText.Money(c, "fx_reserves", m.DollarsTotal!.Value));
+ // The rate in force on the turn's date, as EconomySystem.ConvertDollars uses it.
+ panel.Q<Label>("dollars-money").text = text.Format("dollars.money", PlayerText.Money(c, "treasury", Math.Max(0, amount.value) * m.IlPerDollarOn(s.Date)));
+ var attention = panel.Q<Label>("dollars-attention");
+ attention.style.display = c.UsesAttention ? DisplayStyle.Flex : DisplayStyle.None;
+ attention.text = c.UsesAttention ? text.Format("arms.attention", bridge.Price(order)!.Value, bridge.AttentionLeft!.Value) : "";
+ attention.pickingMode = c.UsesAttention ? PickingMode.Position : PickingMode.Ignore;
+ panel.Q<Label>("dollars-queued").text = queued == null ? "" : text.Format("dollars.queued", PlayerText.Money(c, "fx_reserves", queued.Amount));
+ convert.SetEnabled(s.GameOver == null && amount.value > 0);
+ withdraw.SetEnabled(s.GameOver == null && queued != null);
+ // The sim's own check (EconomySystem.DollarsRefusal) on the state as it is now: End turn refuses the same amount.
+ var refused = s.GameOver != null ? null : EconomySystem.DollarsRefusal(c, s, amount.value);
+ panel.Q<Label>("dollars-refusal").text = s.GameOver != null ? text["order.game_over"]
+ : !war ? text["dollars.wartime_only"]
+ : refused != null ? SimBridge.ReasonText(text, refused)
+ : !bridge.CanPay(order) ? text["dollars.no_attention"] : "";
+ }
+
+ public void Dispose()
+ {
+ bridge.Changed -= Render; presses.Dispose();
+ convert.clicked -= onConvert; withdraw.clicked -= onWithdraw; amount.UnregisterValueChangedCallback(onAmount);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/UI/DollarConversionPresenter.cs.meta b/unity/Assets/Scripts/UI/DollarConversionPresenter.cs.meta
new file mode 100644
index 000000000..eeae78558
--- /dev/null
+++ b/unity/Assets/Scripts/UI/DollarConversionPresenter.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 30c128e5fd8242dba8871273a1c51fa1
diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.cs
index 3ea78a20a..0475314d7 100644
--- a/unity/Assets/Scripts/UI/SimBridge.cs
+++ b/unity/Assets/Scripts/UI/SimBridge.cs
@@ -208,6 +208,8 @@ namespace Statecraft.Game.UI
case ResolveCapture _: return null;
// Answering the end of an occupation (#799): the sim refuses a place not awaiting the end with its own reason.
case EndOccupation _: return null;
+ // Converting dollars (#813, R-MONEY-004): no ids; the sim refuses the amount itself (EconomySystem.DollarsRefusal).
+ case ConvertDollars _: return null;
default: return text["order.invalid"];
}
}
@@ -219,6 +221,12 @@ namespace Statecraft.Game.UI
static readonly Dictionary<string, string> ReasonKeys = new Dictionary<string, string>
{
[Movement.MissingArtilleryMovement] = "unit.artillery_move_missing",
+ // #813 (R-MONEY-004): the dollar conversion's refusals.
+ [EconomySystem.RefusedDollarsMinimum] = "dollars.refused_minimum",
+ [EconomySystem.RefusedDollarsNotAtWar] = "dollars.refused_not_at_war",
+ [EconomySystem.RefusedDollarsMonthly] = "dollars.refused_monthly",
+ [EconomySystem.RefusedDollarsTotal] = "dollars.refused_total",
+ [EconomySystem.RefusedDollarsReserves] = "dollars.refused_reserves",
[Orders.RefusedUnknownOrder] = "unit.order_refused.unknown_order",
[Orders.RefusedNoUnit] = "unit.order_refused.no_unit",
[Orders.RefusedNotMilitary] = "unit.order_refused.not_military",
diff --git a/unity/Assets/Tests/EditMode/CauseTextTests.cs b/unity/Assets/Tests/EditMode/CauseTextTests.cs
index d7f50900d..e9761fd34 100644
--- a/unity/Assets/Tests/EditMode/CauseTextTests.cs
+++ b/unity/Assets/Tests/EditMode/CauseTextTests.cs
@@ -378,7 +378,7 @@ public class CauseTextTests
// including large counts, money rounding and Hebrew names. Actual producer metadata is gated in managed tests.
static Content RemainingFixture() => new Content
{
- Money = new List<MoneyAccount> { new MoneyAccount { Id = "treasury", Name = "Money", Prefix = "IL " }, new MoneyAccount { Id = "debt", Name = "Debt", Prefix = "IL " } },
+ Money = new List<MoneyAccount> { new MoneyAccount { Id = "treasury", Name = "Money", Prefix = "IL " }, new MoneyAccount { Id = "debt", Name = "Debt", Prefix = "IL " }, new MoneyAccount { Id = "fx_reserves", Name = "Foreign currency", Prefix = "$" } },
SettlementNames = new Dictionary<string, string> { ["town"] = "Town" },
Sites = new List<Site> { new Site { Id = "site", Name = "Site", NameHe = "אתר" } },
Corridors = new List<CorridorDef> { new CorridorDef { Id = "road", Name = "Road", NameHe = "דרך" } },
@@ -412,6 +412,7 @@ public class CauseTextTests
new Cause("draft", "town", -1, "Town: Housing was cancelled; the Money spent is not returned", key: CauseKeys.ProjectCancelled, args: new[] { "housing" }),
new Cause("draft", "town", 1, "Town: Housing was finished", key: CauseKeys.ProjectCompleted, args: new[] { "housing" }),
new Cause("draft", "arms", 2000000000, "Bought 2000000000 Arms, cost IL 1.3m", key: CauseKeys.ArmsBought, args: new[] { "1.25" }),
+ new Cause("draft", "treasury", 1.44, "Converted $4.0m of foreign currency into Money: IL +1.4m", key: CauseKeys.DollarsConverted, args: new[] { "4" }),
new Cause("draft", "food", 2000000000, "Site: the plowed land yielded 2000000000 units of Food", key: CauseKeys.FoodHarvest, args: new[] { "site" }),
new Cause("draft", "food", -2000000000, "Food ran out: 2000000000 of 2000000001 units of the month's need went unmet", key: CauseKeys.FoodShortage, args: new[] { "2000000001" }),
new Cause("draft", "food", -1, "No Food imported (foreign currency crisis): the stock fell to 2000000000 units", key: CauseKeys.FoodWithoutImports, args: new[] { "2000000000" }),
diff --git a/unity/Assets/Tests/EditMode/DollarConversionTests.cs b/unity/Assets/Tests/EditMode/DollarConversionTests.cs
new file mode 100644
index 000000000..2d57e0054
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/DollarConversionTests.cs
@@ -0,0 +1,222 @@
+#nullable enable
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.UIElements;
+
+/// <summary>R-MONEY-004, "Spend the dollars" (#813; owner, 2 November 2026: "Spend the dollars (Recommended)"): the Defence
+/// screen's conversion panel, beside the Arms purchase. It queues one ConvertDollars for End turn, shows the foreign-currency
+/// reserve beside the order (the top bar's meters are unchanged) and says the sim's refusal before End turn.</summary>
+public class DollarConversionTests
+{
+ static UiText Text(bool he) => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(he ? UiPaths.StringsHebrew : UiPaths.Strings).text);
+ static UiText En => Text(false);
+ static UiText He => Text(true);
+
+ static SimBridge Bridge(bool modern, bool he)
+ {
+ var dir = Paths.Content;
+ var c = ContentLoader.Load(rel =>
+ {
+ var path = System.IO.Path.Combine(dir, rel);
+ if (!System.IO.File.Exists(path)) return null;
+ var value = System.IO.File.ReadAllText(path);
+ return modern && rel == "eras.yaml" ? value.Replace("loop: gdd", "loop: gdd, ruleset: gdd-0.3") : value;
+ }, System.IO.Directory.GetFiles(System.IO.Path.Combine(dir, "events"), "*.yaml").Select(x => "events/" + System.IO.Path.GetFileName(x)));
+ var b = new SimBridge(GameSession.New(c, GoldenRun.Seed, Mode.Historical), Text(he));
+ if (modern)
+ {
+ foreach (var r in c.EraRules.Values.Append(c.Rules))
+ { r.AttentionCost.Clear(); r.AttentionPerTurn = double.NaN; }
+ b.State.Attention = double.NaN;
+ }
+ return b;
+ }
+
+ // R-MONEY-004: the panel lives in Defence and shows the reserve, the total converted against the cap and the Money the
+ // amount brings, in the content's own money format; the top bar gains nothing.
+ [TestCase(false, false)] [TestCase(false, true)]
+ [TestCase(true, false)] [TestCase(true, true)]
+ public void ThePanelShowsTheReserveAndTheMoneyItBrings(bool modern, bool he)
+ {
+ var b = Bridge(modern, he); var t = Text(he); var c = b.Content; var m = c.RulesAt(b.State.Date).Mvp!;
+ using var ui = new UiTestKit();
+ using var hud = new HudPresenter(ui.Root, b, t);
+ using var defence = new DefencePresenter(ui.Root, b, t);
+ var panel = ui.Q<VisualElement>("defence-dollars");
+ Assert.AreEqual(DisplayStyle.Flex, panel.style.display.value);
+ Assert.IsTrue(panel.Contains(ui.Q<Label>("dollars-reserves")));
+ Assert.AreEqual(t.Format("dollars.reserves", PlayerText.Money(c, "fx_reserves", b.State.FxReserves)), ui.Q<Label>("dollars-reserves").text);
+ Assert.AreEqual(t.Format("dollars.total", PlayerText.Money(c, "fx_reserves", 0), PlayerText.Money(c, "fx_reserves", m.DollarsTotal!.Value)),
+ ui.Q<Label>("dollars-total").text);
+ var amount = ui.Q<IntegerField>("dollars-amount");
+ Assert.AreEqual(m.DollarsPerTurn!.Value, amount.value, "the amount starts at the month's limit");
+ amount.value = 3;
+ Assert.AreEqual(t.Format("dollars.money", PlayerText.Money(c, "treasury", 3 * m.IlPerDollarOn(b.State.Date))), ui.Q<Label>("dollars-money").text);
+ CollectionAssert.AreEqual(new[] { "treasury", "immigration", "security", "support", "cohesion", "standing", "fx" }, HudModel.MeterIds,
+ "the top bar's meters are unchanged");
+ }
+
+ // R-MONEY-004: Convert queues one order (a second replaces it), the state is untouched until End turn, which converts.
+ [TestCase(false)] [TestCase(true)]
+ public void ConvertQueuesOneOrderAndEndTurnConverts(bool he)
+ {
+ var b = Bridge(false, he); var t = Text(he); var c = b.Content;
+ using var ui = new UiTestKit();
+ using var defence = new DefencePresenter(ui.Root, b, t);
+ var before = b.State.Hash();
+ // The reserve moves every turn (capital inflow, imports), so the conversion is measured against the turn with no order.
+ var fxAfter = Simulation.Step(c, b.TurnStart, System.Array.Empty<Command>()).State.FxReserves - 3;
+ var amount = ui.Q<IntegerField>("dollars-amount");
+ amount.value = 2; ui.Press("convert-dollars");
+ amount.value = 3; ui.Press("convert-dollars");
+ Assert.AreEqual(3, ((ConvertDollars)b.Queued.Single()).Amount);
+ Assert.AreEqual(before, b.State.Hash());
+ Assert.AreEqual(t.Format("dollars.queued", PlayerText.Money(c, "fx_reserves", 3)), ui.Q<Label>("dollars-queued").text);
+ ui.Press("withdraw-dollars");
+ Assert.IsEmpty(b.Queued);
+ ui.Press("convert-dollars");
+ b.EndTurn();
+ Assert.IsEmpty(b.Queued);
+ Assert.AreEqual(3, b.State.DollarsConverted);
+ Assert.IsTrue(b.Session.Last!.Why.Any(w => w.Key == CauseKeys.DollarsConverted));
+ Assert.AreEqual(t.Format("dollars.total", PlayerText.Money(c, "fx_reserves", 3), PlayerText.Money(c, "fx_reserves", c.RulesAt(b.State.Date).Mvp!.DollarsTotal!.Value)),
+ ui.Q<Label>("dollars-total").text);
+ Assert.AreEqual(t.Format("dollars.reserves", PlayerText.Money(c, "fx_reserves", b.State.FxReserves)), ui.Q<Label>("dollars-reserves").text);
+ Assert.AreEqual(fxAfter, b.State.FxReserves, 1e-9);
+ Assert.IsEmpty(ui.Q<Label>("dollars-queued").text);
+ }
+
+ // R-MONEY-004: the panel says, before End turn, the reason the sim would refuse the amount (EconomySystem's own check),
+ // in the player's language; Convert stays available so the refusal stays explainable.
+ [TestCase(false)] [TestCase(true)]
+ public void TheSimsRefusalIsShownBeforeEndTurn(bool he)
+ {
+ var b = Bridge(false, he); var t = Text(he);
+ using var ui = new UiTestKit();
+ using var defence = new DefencePresenter(ui.Root, b, t);
+ var amount = ui.Q<IntegerField>("dollars-amount");
+ var refusal = ui.Q<Label>("dollars-refusal");
+ amount.value = 4;
+ Assert.IsEmpty(refusal.text, "$4m in the war is allowed");
+ amount.value = 5;
+ Assert.AreEqual(t["dollars.refused_monthly"], refusal.text);
+ amount.value = 0;
+ Assert.AreEqual(t["dollars.refused_minimum"], refusal.text);
+ Assert.IsFalse(ui.Q<Button>("convert-dollars").enabledSelf);
+ b.State.DollarsConverted = 98;
+ amount.value = 3;
+ Assert.AreEqual(t["dollars.refused_total"], refusal.text);
+ b.State.DollarsConverted = 0; b.State.FxReserves = 2;
+ amount.value = 4; amount.value = 3;
+ Assert.AreEqual(t["dollars.refused_reserves"], refusal.text);
+ Assert.IsTrue(ui.Q<Button>("convert-dollars").enabledSelf, "a refusal remains explainable");
+ ui.Press("convert-dollars");
+ Assert.IsEmpty(b.Queued, "an amount the sim refuses is not queued");
+ Assert.AreEqual(t["dollars.refused_reserves"], refusal.text, "the refusal stays shown after Convert");
+ b.State.GameOver = "finished";
+ amount.value = 2;
+ Assert.AreEqual(t["order.game_over"], refusal.text);
+ Assert.IsFalse(ui.Q<Button>("convert-dollars").enabledSelf);
+ }
+
+ // R-MONEY-004 (owner, 2 November 2026: "Box shows queued order (Recommended)"): with a conversion queued, a new number
+ // in the box replaces it at once, so the box, the Money line and what End turn converts agree; the reserve and the total
+ // converted keep the turn's start until End turn. An amount the sim refuses clears the queue and shows the refusal.
+ [TestCase(false)] [TestCase(true)]
+ public void TypingANewAmountReplacesTheQueuedConversion(bool he)
+ {
+ var b = Bridge(false, he); var t = Text(he); var c = b.Content; var m = c.RulesAt(b.State.Date).Mvp!;
+ using var ui = new UiTestKit();
+ using var defence = new DefencePresenter(ui.Root, b, t);
+ var reserves = ui.Q<Label>("dollars-reserves").text; var total = ui.Q<Label>("dollars-total").text;
+ var amount = ui.Q<IntegerField>("dollars-amount");
+ amount.value = 4; ui.Press("convert-dollars");
+ Assert.AreEqual(4, ((ConvertDollars)b.Queued.Single()).Amount);
+ amount.value = 2;
+ Assert.AreEqual(2, ((ConvertDollars)b.Queued.Single()).Amount, "the box replaces the queued order");
+ Assert.AreEqual(t.Format("dollars.money", PlayerText.Money(c, "treasury", 2 * m.IlPerDollarOn(b.State.Date))), ui.Q<Label>("dollars-money").text);
+ Assert.AreEqual(t.Format("dollars.queued", PlayerText.Money(c, "fx_reserves", 2)), ui.Q<Label>("dollars-queued").text);
+ Assert.AreEqual(reserves, ui.Q<Label>("dollars-reserves").text, "the reserve keeps the turn's start");
+ Assert.AreEqual(total, ui.Q<Label>("dollars-total").text, "the total converted keeps the turn's start");
+ amount.value = 5;
+ Assert.IsEmpty(b.Queued, "an amount the sim refuses clears the queue");
+ Assert.AreEqual(t["dollars.refused_monthly"], ui.Q<Label>("dollars-refusal").text);
+ Assert.IsEmpty(ui.Q<Label>("dollars-queued").text);
+ }
+
+ // R-MONEY-004 (owner, 2 November 2026: "Grey it with the reason (Recommended)"): outside the war (a rung below 4) the
+ // panel stays visible but disabled, with one line saying conversion is for wartime only; in the war it is enabled again.
+ [TestCase(false)] [TestCase(true)]
+ public void OutsideTheWarThePanelIsGreyedWithTheReason(bool he)
+ {
+ var b = Bridge(false, he); var t = Text(he);
+ using var ui = new UiTestKit();
+ using var defence = new DefencePresenter(ui.Root, b, t);
+ var panel = ui.Q<VisualElement>("defence-dollars");
+ var amount = ui.Q<IntegerField>("dollars-amount");
+ b.State.Rung = 3;
+ amount.value = 4; amount.value = 3;
+ Assert.AreEqual(DisplayStyle.Flex, panel.style.display.value, "the panel stays visible");
+ Assert.IsFalse(panel.enabledSelf, "the panel is disabled");
+ Assert.IsFalse(ui.Q<Button>("convert-dollars").enabledInHierarchy);
+ Assert.AreEqual(t["dollars.wartime_only"], ui.Q<Label>("dollars-refusal").text);
+ ui.Press("convert-dollars");
+ Assert.IsEmpty(b.Queued);
+ b.State.Rung = 4;
+ amount.value = 4;
+ Assert.IsTrue(panel.enabledSelf);
+ Assert.IsEmpty(ui.Q<Label>("dollars-refusal").text);
+ }
+
+ // R-MONEY-004: the legacy loop has no conversion.
+ [Test]
+ public void TheLegacyLoopHidesThePanel()
+ {
+ var t = En;
+ var b = new SimBridge(GameSession.New(SimBridgeGddTests.LoadLegacy(), GoldenRun.Seed, Mode.Historical), t);
+ using var ui = new UiTestKit();
+ using var defence = new DefencePresenter(ui.Root, b, t);
+ Assert.AreEqual(DisplayStyle.None, ui.Q<VisualElement>("defence-dollars").style.display.value);
+ }
+
+ // R-MONEY-004: every refusal reaches the end-of-turn toast (SimBridge.ReasonText) as the sim's English, and in Hebrew
+ // with no Latin letters.
+ [Test]
+ public void EveryRefusalHasAStringInBothLanguages()
+ {
+ var refusals = typeof(EconomySystem).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)
+ .Where(f => f.IsLiteral && f.Name.StartsWith("RefusedDollars")).Select(f => (string)f.GetRawConstantValue()).ToList();
+ Assert.AreEqual(5, refusals.Count);
+ foreach (var reason in refusals)
+ {
+ Assert.AreEqual(reason, SimBridge.ReasonText(En, reason), "the English string is the sim's own");
+ var he = SimBridge.ReasonText(He, reason);
+ Assert.AreNotEqual(reason, he, "no Hebrew string for: " + reason);
+ StringAssert.IsMatch("[א-ת]", he, reason);
+ StringAssert.DoesNotMatch("[A-Za-z]", he, reason);
+ }
+ }
+
+ // R-MONEY-004: the cause line reads the same as the sim's English, and in Hebrew in the player's language: the dollars
+ // first, then the Money they brought, and no Latin letters outside those two figures.
+ [Test]
+ public void TheCauseLineIsWordedInBothLanguages()
+ {
+ var b = Bridge(false, false);
+ var line = Simulation.Step(b.Content, b.State, new Command[] { new ConvertDollars(4) }).Why.Single(w => w.Key == CauseKeys.DollarsConverted);
+ Assert.AreEqual(line.Message, CauseText.Line(line, b.Content, System.Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), En));
+ var he = CauseText.Line(line, b.Content, System.Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), He);
+ StringAssert.IsMatch("[א-ת]", he);
+ var dollars = PlayerText.Money(b.Content, "fx_reserves", 4);
+ var money = PlayerText.MoneyChange(b.Content, "treasury", 4 * b.Content.RulesAt(b.State.Date).Mvp!.IlPerDollarOn(b.State.Date));
+ Assert.AreEqual(money, PlayerText.MoneyChange(b.Content, "treasury", line.Delta), "the line's Delta is the IL the sim converted");
+ int at = he.IndexOf(dollars, System.StringComparison.Ordinal), il = he.IndexOf(money, System.StringComparison.Ordinal);
+ Assert.GreaterOrEqual(at, 0, he); Assert.Greater(il, at, he);
+ StringAssert.DoesNotMatch("[A-Za-z]", he.Replace(dollars, "").Replace(money, ""), he);
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/DollarConversionTests.cs.meta b/unity/Assets/Tests/EditMode/DollarConversionTests.cs.meta
new file mode 100644
index 000000000..653bfbe3f
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/DollarConversionTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: bf2da8a00db54329a825d5dd23009c00
diff --git a/unity/Assets/Tests/EditMode/PromoScreensTests.cs b/unity/Assets/Tests/EditMode/PromoScreensTests.cs
index 5c95bca34..bc188d4f4 100644
--- a/unity/Assets/Tests/EditMode/PromoScreensTests.cs
+++ b/unity/Assets/Tests/EditMode/PromoScreensTests.cs
@@ -490,6 +490,28 @@ public class PromoScreensTests
Assert.AreEqual(texts["arms-attention"], ui.Q<Label>("arms-attention").text);
Assert.AreEqual(C.UsesAttention ? DisplayStyle.Flex : DisplayStyle.None,
ui.Q<Label>("arms-attention").style.display.value);
+ // #813 (R-MONEY-004): the Dollars panel (GDD loop only): the sim's foreign-currency reserve, the dollars converted
+ // so far against mvp.dollars_total, and the Money the amount field's opening value (mvp.dollars_per_turn) brings
+ // at the il_per_dollar rate in force on the date (EconomySystem.ConvertDollars), with its Attention cost.
+ var m = C.RulesAt(s.Date).Mvp!;
+ var convert = new ConvertDollars(m.DollarsPerTurn!.Value);
+ texts["dollars-reserves"] = Text.Format("dollars.reserves", PlayerText.Money(C, "fx_reserves", s.FxReserves));
+ texts["dollars-total"] = Text.Format("dollars.total",
+ PlayerText.Money(C, "fx_reserves", s.DollarsConverted), PlayerText.Money(C, "fx_reserves", m.DollarsTotal!.Value));
+ // The amount field opens at the month's limit (DollarConversionPresenter) unless a ConvertDollars is queued; these dates have none.
+ Assert.IsNull(bridge.QueuedLike(convert), $"{where}: precondition: no dollar conversion is queued");
+ texts["dollars-amount"] = m.DollarsPerTurn.Value.ToString();
+ texts["dollars-money"] = Text.Format("dollars.money", PlayerText.Money(C, "treasury", m.DollarsPerTurn.Value * m.IlPerDollarOn(s.Date)));
+ texts["dollars-attention"] = C.UsesAttention ? Text.Format("arms.attention", bridge.Price(convert)!.Value, bridge.AttentionLeft!.Value) : "";
+ // Require the named figures, even if a missing/blank control would evade the digit inventory.
+ Assert.AreEqual(texts["dollars-reserves"], ui.Q<Label>("dollars-reserves").text);
+ Assert.AreEqual(texts["dollars-total"], ui.Q<Label>("dollars-total").text);
+ Assert.AreEqual(m.DollarsPerTurn.Value, ui.Q<IntegerField>("dollars-amount").value);
+ Assert.AreEqual(texts["dollars-money"], ui.Q<Label>("dollars-money").text);
+ Assert.AreEqual(texts["dollars-attention"], ui.Q<Label>("dollars-attention").text);
+ Assert.AreEqual(C.UsesAttention ? DisplayStyle.Flex : DisplayStyle.None,
+ ui.Q<Label>("dollars-attention").style.display.value);
+ Assert.AreEqual("", ui.Q<Label>("dollars-queued").text, $"{where}: nothing queued, no queued figure");
}
bars["mob-bar"] = (float)callUp; bars["defence-budget-bar"] = (float)s.Budget[DefencePresenter.BudgetLine];
foreach (var name in new[] { "screen-cabinet", "screen-defence" })
diff --git a/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs b/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs
index 61fb90361..ee520842e 100644
--- a/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs
+++ b/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs
@@ -40,6 +40,7 @@ public class SimBridgeGuardTests
[typeof(CancelProject)] = new CancelProject(1),
[typeof(Move)] = new Move(1, 2, 0),
[typeof(BuyArms)] = new BuyArms(0),
+ [typeof(ConvertDollars)] = new ConvertDollars(0),
[typeof(ResolveCapture)] = new ResolveCapture("town_a", "raid"),
[typeof(EndOccupation)] = new EndOccupation("town_a", "annex"),
};
@@ -57,8 +58,9 @@ public class SimBridgeGuardTests
}
/// <summary>The command types whose order is one per turn by design, so their key is their kind (SimBridge.Key's
- /// default): one budget, one call-up level, one security order, one Arms purchase (its count is the whole order).</summary>
- static readonly HashSet<Type> OnePerTurn = new HashSet<Type> { typeof(AllocateBudget), typeof(SetMobilization), typeof(SecurityOrder), typeof(BuyArms) };
+ /// default): one budget, one call-up level, one security order, one Arms purchase (its count is the whole order), one dollar conversion (R-MONEY-004: its amount is the
+ /// whole order).</summary>
+ static readonly HashSet<Type> OnePerTurn = new HashSet<Type> { typeof(AllocateBudget), typeof(SetMobilization), typeof(SecurityOrder), typeof(BuyArms), typeof(ConvertDollars) };
/// <summary>Every other command type has its own branch in SimBridge.Key, so its orders are not one per turn by accident
/// (a new type with a Validate branch and no Key branch would silently keep only the last order of the turn).</summary>
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 1b98b5bfb..be8a8d2ca 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -386,6 +386,23 @@
<ui:Label name="arms-refusal" class="wrap" />
<Statecraft.Game.UI.UiFrame shadow="false" />
</ui:VisualElement>
+ <!-- #813 (R-MONEY-004): converting foreign currency into Money during the war, with the one foreign-currency readout. -->
+ <ui:VisualElement name="defence-dollars" class="defence-panel">
+ <ui:Label name="dollars-title" class="section-title" />
+ <ui:Label name="dollars-reserves" class="wrap" />
+ <ui:Label name="dollars-cost" class="muted wrap" />
+ <ui:Label name="dollars-total" class="wrap" />
+ <ui:IntegerField name="dollars-amount" value="1" />
+ <ui:Label name="dollars-money" class="wrap" />
+ <ui:Label name="dollars-attention" class="wrap" />
+ <ui:VisualElement class="row arms-actions">
+ <ui:Button name="convert-dollars" />
+ <ui:Button name="withdraw-dollars" />
+ </ui:VisualElement>
+ <ui:Label name="dollars-queued" class="wrap" />
+ <ui:Label name="dollars-refusal" class="wrap" />
+ <Statecraft.Game.UI.UiFrame shadow="false" />
+ </ui:VisualElement>
<!-- #755: the prisoners held and returned and our soldiers held (R-POW-001, R-POW-004, R-POW-005), GDD loop only. -->
<ui:VisualElement name="defence-prisoners" class="defence-panel">
<ui:Label name="defence-title-prisoners" class="section-title" />
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index 5852115bb..e0e6ec46a 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -1247,6 +1247,11 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
.lang-he #arms-count { flex-direction: row-reverse; }
#arms-count .unity-base-field__input { background-color: var(--navy-deep); color: var(--ink); border-width: 1px; border-color: var(--gold-dim); }
#arms-count:focus .unity-base-field__input { border-color: var(--gold); }
+/* #813: the dollar conversion's amount, as the Arms count. */
+#dollars-amount { min-width: 0; flex-shrink: 1; }
+.lang-he #dollars-amount { flex-direction: row-reverse; }
+#dollars-amount .unity-base-field__input { background-color: var(--navy-deep); color: var(--ink); border-width: 1px; border-color: var(--gold-dim); }
+#dollars-amount:focus .unity-base-field__input { border-color: var(--gold); }
/* #530: a still opening in the existing event-card frame. Keep its actions outside the scrolling prose, so Skip
remains reachable in a short window. In the Hebrew UI the prose is opening.yaml's Hebrew, set from the right like the
rest of the Hebrew UI (owner, 1 Nov 2026); OpeningPresenter keeps .opening-source-en, left-aligned, only on what stays
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 5e29c8801..01f406bfd 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -1131,3 +1131,23 @@ opening.begin: "Continue to the map"
opening.return: "Return to the start screen"
opening.count: "Step {0} of {1}"
opening.preview: "Editor preview: draft text; human source checks pending."
+
+# #813 (R-MONEY-004; owner, 2 November 2026: "Spend the dollars (Recommended)"): the Defence screen's dollar conversion.
+# The refusals are EconomySystem's own words, shown in the end-of-turn toast.
+dollars.title: "Convert dollars"
+dollars.reserves: "Foreign currency: {0}"
+dollars.cost: "When foreign currency runs out, Food imports stop."
+dollars.total: "Converted so far: {0} of {1}"
+dollars.amount: "Dollars to convert, in millions"
+dollars.money: "Money this would bring: {0}"
+dollars.convert: "Convert dollars"
+dollars.withdraw: "Withdraw conversion"
+dollars.queued: "Dollars to convert: {0}, at End turn"
+dollars.wartime_only: "Converting dollars is for wartime only."
+dollars.no_attention: "Not enough Attention for this conversion. Withdraw another order or wait until next turn."
+dollars.refused_minimum: "Convert at least $1m"
+dollars.refused_not_at_war: "Dollars can be converted only during the war"
+dollars.refused_monthly: "That is more dollars than may be converted this month"
+dollars.refused_total: "That would pass the total of dollars that may be converted"
+dollars.refused_reserves: "There are not enough dollars in the reserves"
+why.cause.dollars_converted: "Converted {0} of foreign currency into Money: {1}"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index b50c4427e..87fdaf196 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -1250,3 +1250,23 @@ opening.begin: "המשך למפה"
opening.return: "חזרה למסך הפתיחה"
opening.count: "שלב {0} מתוך {1}"
opening.preview: "תצוגה מקדימה בעורך: טיוטה; בדיקת המקורות בידי אדם ממתינה."
+
+# #813 (R-MONEY-004): the Defence screen's dollar conversion. Agent-drafted Hebrew; every line below is
+# native-review-pending (#564).
+dollars.title: "המרת דולרים"
+dollars.reserves: "מטבע חוץ: {0}"
+dollars.cost: "כשמטבע החוץ אוזל, יבוא המזון נעצר."
+dollars.total: "הומר עד כה: {0} מתוך {1}"
+dollars.amount: "דולרים להמרה, במיליונים"
+dollars.money: "כסף שההמרה תוסיף: {0}"
+dollars.convert: "המרת דולרים"
+dollars.withdraw: "ביטול ההמרה"
+dollars.queued: "דולרים להמרה: {0}, בסיום התור"
+dollars.wartime_only: "המרת דולרים אפשרית רק בזמן מלחמה."
+dollars.no_attention: "אין די תשומת לב להמרה. יש לבטל הוראה אחרת או להמתין לתור הבא."
+dollars.refused_minimum: "יש להמיר לפחות מיליון דולר"
+dollars.refused_not_at_war: "אפשר להמיר דולרים רק בזמן המלחמה"
+dollars.refused_monthly: "זה יותר מהסכום שמותר להמיר החודש"
+dollars.refused_total: "ההמרה תעבור את הסכום הכולל שמותר להמיר"
+dollars.refused_reserves: "אין די דולרים ביתרות מטבע החוץ"
+why.cause.dollars_converted: "המרת מטבע חוץ לכסף: {0}; כסף: שינוי {1}"