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.

Operations carry out their sourced moves and attacks (sim side, #2544) (#2956)

Eyal Golan70c1e209aa43
diff --git a/changelog.d/c30-2544-op-attacks.md b/changelog.d/c30-2544-op-attacks.md
new file mode 100644
index 000000000..d1ec3aa45
--- /dev/null
+++ b/changelog.d/c30-2544-op-attacks.md
@@ -0,0 +1,6 @@
+- A military operation card can now order sourced attacks as well as moves (`unit_orders` rows with `order: attack`),
+ fought through the player's own attack under both rulesets; a refused action leaves the later ones to run, a
+ player's order to a unit in an operation cancels that operation's remaining orders, and the sim lists every action an
+ operation takes for the map and turn report to show (#2544, sim side; no card has an attack yet). Saves are now
+ written as save schema 6. A schema 5 save still loads; if its game now plays out differently, it loads with the
+ notice that some parts differ from the save, instead of being refused.
diff --git a/content/schema/event.schema.json b/content/schema/event.schema.json
index 451726222..28e1e2996 100644
--- a/content/schema/event.schema.json
+++ b/content/schema/event.schema.json
@@ -196,13 +196,14 @@
},
"unit_orders": {
"type": "array",
- "description": "R-ENEMY-005 (GDD loop, both gdd-0.1 and gdd-0.3): go-to orders for the unit of a map/units_1948.yaml row, toward one of that row's anchor hexes in map/unit_anchor_hexes.yaml, through the player's own go-to.",
+ "description": "R-ENEMY-005, R-ENEMY-008 (GDD loop, both gdd-0.1 and gdd-0.3): go-to or attack orders for the unit of a map/units_1948.yaml row, toward or on one of that row's anchor or order target hexes in map/unit_anchor_hexes.yaml, through the player's own go-to or attack.",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["unit", "q", "r"],
"properties": {
"unit": { "type": "string", "minLength": 1 },
+ "order": { "enum": ["go_to", "attack"], "description": "go_to when left out (R-ENEMY-008)." },
"q": { "type": "integer" },
"r": { "type": "integer" }
}
diff --git a/docs/GDD.md b/docs/GDD.md
index 9ee5b9cf2..24d993ceb 100644
--- a/docs/GDD.md
+++ b/docs/GDD.md
@@ -388,7 +388,7 @@ Later on 1 November 2026 the owner answered the questions the approved answers l
| Housing repair price | "Fixed price 0.5 Money + 1 work" | A repair costs 0.5 Money and 1 work and raises the city's housing condition by 10 percentage points. The price is a labelled design value ([#1700](https://github.com/eyalgolan/statecraft-israel/issues/1700#issuecomment-6554004118), [#1703](https://github.com/eyalgolan/statecraft-israel/issues/1703#issuecomment-6554005317)). |
| Historical starting farmer tiers | "Amir's 1:2:1 ratio per city (Recommended)"; the rounding rule: "all approved"; 7 November 2026, "Per host, 1/18/1 (Recommended)" | Each host's starting farmers are a quarter novice, half trained and a quarter veteran, a labelled design value. The split runs per host, not per census city, which gives 1 / 18 / 1 nationally across the 20 opening fields' hosts ([#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6704985642)). When a host's count is not a multiple of 4, the split uses the largest remainder with ties to trained (5 farmers: 1 / 3 / 1); at 2 more than a multiple of 4 the leftover unit ties between novice and veteran, and it goes to trained (6 farmers: 1 / 4 / 1; owner, 6 November 2026, "Trained: 1/4/1 (Recommended)", [#2465](https://github.com/eyalgolan/statecraft-israel/issues/2465#issuecomment-6676926351)), and every host's total stays exact ([#1717](https://github.com/eyalgolan/statecraft-israel/issues/1717#issuecomment-6554155751), [rounding](https://github.com/eyalgolan/statecraft-israel/issues/1717#issuecomment-6555212806)). Amir's 5 / 10 / 5 stays for Open mode (D2). |
| D5 places | Southern Coast: "Nir Am (Recommended)"; Negev: "Nirim, add it to the map (Recommended)"; for Nirim: "Optional (Recommended)", "Israeli at the start (Recommended)" and "Agent checks are enough" | Nir Am is the Southern Coast's opening housing place and Nirim, at its 1948 site at Dangur (today's Nir Yitzhak), is the Negev's. Nirim is an optional location, Israeli-held at the start. Agent checks of the sources replace D5's person's check for these places ([#2113](https://github.com/eyalgolan/statecraft-israel/issues/2113#issuecomment-6554685727), [#2136](https://github.com/eyalgolan/statecraft-israel/pull/2136)). |
-| Operation-card orders and start placement | 1 November: "military openrations must have unit orders"; Latrun: "Harel at Sha'ar HaGai (Recommended)"; Dani: "Kiryati to Ramle (Recommended)". #2543 (owner, 4 November 2026): "A military operation can only get underway if you have the required units in place (you cant fight in latrun in you dont have military units there)." For #2543 the owner chose the options labelled "In the same region", "Both rulesets (Recommended)" and, later, "Player must move them"; on a delegated card: "Postpone and explain to the user which units need to move where. Postpone until they are in the right area and if the operation is still relevant" (as recorded on #2543, 4 November 2026). | Every military-operation option has sourced unit orders and an authored set of existing regions. The agent-recorded #2543 scope says its ordered starting units must each be on a hex in one of those regions, with no pre-positioning or credit for starting regions. An unmet direct choice is refused unchanged. An unmet delegated choice is postponed with the required moves explained, consumes no draw, and is redrawn later; it lapses without a choice or effects when its window closes. Orders apply under `gdd-0.1` and `gdd-0.3` (R-ENEMY-005, R-ENEMY-007; [#2087](https://github.com/eyalgolan/statecraft-israel/pull/2087), #2543). |
+| Operation-card orders and start placement | 1 November: "military openrations must have unit orders"; Latrun: "Harel at Sha'ar HaGai (Recommended)"; Dani: "Kiryati to Ramle (Recommended)". #2543 (owner, 4 November 2026): "A military operation can only get underway if you have the required units in place (you cant fight in latrun in you dont have military units there)." For #2543 the owner chose the options labelled "In the same region", "Both rulesets (Recommended)" and, later, "Player must move them"; on a delegated card: "Postpone and explain to the user which units need to move where. Postpone until they are in the right area and if the operation is still relevant" (as recorded on #2543, 4 November 2026). #2544 (owner, 4 November 2026): "In addition, deciding on a military operation makes the units do what the operation describes (shown to the user all the moves, attacks etc)" and "Also if a user tries to cancel orders of a unit that is in an operation, a message would tell him that this will cancel the entire operation if he choses to do this"; for #2544 the owner chose the options labelled "Both rulesets (Recommended)", "Continue the rest (Recommended)" and "Only remaining orders (Recommended)". | Every military-operation option has sourced unit orders and an authored set of existing regions. The agent-recorded #2543 scope says its ordered starting units must each be on a hex in one of those regions, with no pre-positioning or credit for starting regions. An unmet direct choice is refused unchanged. An unmet delegated choice is postponed with the required moves explained, consumes no draw, and is redrawn later; it lapses without a choice or effects when its window closes. Orders apply under `gdd-0.1` and `gdd-0.3` (R-ENEMY-005, R-ENEMY-007; [#2087](https://github.com/eyalgolan/statecraft-israel/pull/2087), #2543). A decided operation's orders may also be sourced attacks, fought through the player's own attack in list order; a refused action leaves the later ones to run. A player's order that takes a unit off its operation's go-to cancels that operation's remaining orders, keeping the moves and fights already done (R-ENEMY-008, R-ENEMY-009; #2544). |
| Movement preview | "I am talking about an arrow showing which tiles the unit is going to move to. this needs to be for israeli units only" | Choosing where an Israeli unit moves shows an animated arrow over the tiles it will move through. Enemy units get no arrow ([#2134](https://github.com/eyalgolan/statecraft-israel/issues/2134)). |
| The 1949 armistice-lines overlay | "On by default (Recommended)" | The 1949 armistice-lines overlay shows in every run, with no URL flag; a release build draws only the lines the owner signed off ([#2195](https://github.com/eyalgolan/statecraft-israel/pull/2195#issuecomment-6565077805)). |
| The desktop Quit button | Hebrew label: "יציאה is right (Recommended)"; Settings placement: "Own row at the bottom (Recommended)" | Desktop builds show Quit on the start screen and in its own last row in Settings, labelled "יציאה" in Hebrew; the browser build hides it ([#2188](https://github.com/eyalgolan/statecraft-israel/pull/2188#issuecomment-6564490828)). |
diff --git a/docs/WRITING_EVENTS.md b/docs/WRITING_EVENTS.md
index 5c1dd07d8..3f0514829 100644
--- a/docs/WRITING_EVENTS.md
+++ b/docs/WRITING_EVENTS.md
@@ -254,7 +254,7 @@ Each option has:
| `grant_units` | no | GDD loop only. A list of `{ type, n, at }`: see "grant_units and city_effects". |
| `city_effects` | no | GDD loop only. A list of `{ city, field, delta }`: see "grant_units and city_effects". |
| `unlock_projects` | no | GDD loop only. A list of `projects.yaml` ids: see "grant_units and city_effects". |
-| `unit_orders` | no | GDD loop, both GDD identities. A list of `{ unit, q, r }`: see "unit_orders". |
+| `unit_orders` | no | GDD loop, both GDD identities. A list of `{ unit, order, q, r }` (`order`: `go_to`, the default, or `attack`): see "unit_orders". |
| `requires_unit_regions` | with `unit_orders` | A non-empty list of existing `regions.yaml` ids in any one of which every ordered unit must stand: see "unit_orders". |
| `debt_dollars` | no | Applied under gdd-0.3 only. US$ millions, more than 0, that the option also adds to Debt, in IL at the `mvp.il_per_dollar` rate in force on the event's date (R-EFX-009). |
| `alternative` | on every option that did not happen, in an event with a historical option | Who put it forward, on what record. See below. |
@@ -334,6 +334,13 @@ An event with a sensitive tag may carry no grant, no positive `city_effects` del
a comment. The order goes through the player's own go-to: one the player could not give changes nothing, and the
player is told so. The order ends on the `to` date of the anchor, or of the order target (the loader refuses a hex with none), and its march
goes round every enemy-held place but its hex.
+- `{ unit: golani, order: attack, q: -7, r: 24 }` makes the row's unit attack hex (`q`, `r`) when the option is decided
+ (R-ENEMY-008); `order` is `go_to` when left out. The hex is again one of the row's anchors or order targets, so add
+ an attack only where a source states it (cite it), never from the card's prose. It needs no `to` date. The attack is the
+ player's own: from where the unit stands after the rows before it (a row may move and then attack, once each), with its
+ checks; one the player could not make changes nothing, and the rows after it still run.
+- Two cards never send one row to the same hex: the operation a unit is in is found from its go-to, and a player's order
+ that takes a unit off it cancels the rest of that operation's orders (R-ENEMY-009).
- Every option with `unit_orders` also has `requires_unit_regions`. The required units are exactly the distinct rows in
`unit_orders`; before the option resolves, each row's starting unit must be on the board and on a hex in any listed
region (R-ENEMY-007). Cite the operation objective or target supporting every region in the option's comment.
diff --git a/docs/determinism.md b/docs/determinism.md
index 5abf2efb1..26cb5357e 100644
--- a/docs/determinism.md
+++ b/docs/determinism.md
@@ -53,7 +53,10 @@ The simulation must produce the same state, bit for bit, on .NET, Unity Mono and
## Combat draws
A player engagement draws `Combat.DrawsPerEngagement` (1) when its order runs in `RunOrders`, after the route step and any
-earlier committed order, before every waiting order. The enemy's engagements draw in resolver step 2, in ascending attacker id.
+earlier committed order, before every waiting order. An operation card's attack (R-ENEMY-008) draws the same way when the card
+is decided: in its option's list order when its choice runs in `RunOrders`, or, when the card is delegated, after that
+delegation's own draws (`EventSystem.Delegate` hands the stream to the attack and keeps its draw). The enemy's engagements
+draw in resolver step 2, in ascending attacker id.
## Golden playthroughs
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index aa2116137..0037200a0 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -82,15 +82,17 @@ R-CTRL-022: `DeportNeverDominates` (impact plan section 4.1 item 5; Q-TECH-4 as
## Saves
-R-SAVE-001: A save names the ruleset it was played under (`ruleset legacy` or `ruleset gdd-0.1`, save schema 2). A game refuses a save made under another ruleset. A schema 1 save has no ruleset line and is legacy, so the GDD game refuses it as made under earlier rules. The refusal carries a code (`older_rules`) the UI translates, and the sim's reason does not itself ask for a new game: the player reads that once (N4). GDD 0.3 has its own ruleset, `gdd-0.3`, first saved as schema 4 (#1687; owner ruling 26 October 2026: GDD 0.3 is built behind its own ruleset), while `legacy` and `gdd-0.1` saves were schema 3; every ruleset now writes schema 5 (R-SAVE-005). A gdd-0.3 game refuses a `legacy` or `gdd-0.1` save as made under earlier rules (`older_rules`), before any replay. No content selects `gdd-0.3` yet, so the live game is unchanged.
+R-SAVE-001: A save names the ruleset it was played under (`ruleset legacy` or `ruleset gdd-0.1`, save schema 2). A game refuses a save made under another ruleset. A schema 1 save has no ruleset line and is legacy, so the GDD game refuses it as made under earlier rules. The refusal carries a code (`older_rules`) the UI translates, and the sim's reason does not itself ask for a new game: the player reads that once (N4). GDD 0.3 has its own ruleset, `gdd-0.3`, first saved as schema 4 (#1687; owner ruling 26 October 2026: GDD 0.3 is built behind its own ruleset), while `legacy` and `gdd-0.1` saves were schema 3; every ruleset wrote schema 5 (R-SAVE-005) and now writes schema 6 (R-SAVE-006). A gdd-0.3 game refuses a `legacy` or `gdd-0.1` save as made under earlier rules (`older_rules`), before any replay. No content selects `gdd-0.3` yet, so the live game is unchanged.
R-SAVE-002: A save that names a ruleset this build does not know, or a newer save schema, was made by a newer version of the game and is refused with the code `newer_version` (N2). A `legacy` or `gdd-0.1` game refuses a `gdd-0.3` save the same way, A `gdd-0.3` save under schema 2 or 3, and a schema 4 save naming `legacy` or `gdd-0.1`, were never written by any build, so they are refused as damaged, with no code (#1687, #2605).
-R-SAVE-003: Save schema 3 adds the open turn: after the last `turn`, a line `open` and the turn in progress's committed orders (R-TURN-004), one a line (a waiting order there is refused: the save was edited); the `end` hash is still the state's after the last finished turn. Loading replays the turns, then commits the open orders again; one refused on the same content means the save is damaged (`SaveException`), and on other content the rest are dropped with the `replay_differs` warning. A schema 2 save has no open turn and loads as before (but see R-SAVE-004). A save older than schema 5 is R-SAVE-005's.
+R-SAVE-003: Save schema 3 adds the open turn: after the last `turn`, a line `open` and the turn in progress's committed orders (R-TURN-004), one a line (a waiting order there is refused: the save was edited); the `end` hash is still the state's after the last finished turn. Loading replays the turns, then commits the open orders again; one refused on the same content means the save is damaged (`SaveException`), and on other content the rest are dropped with the `replay_differs` warning. A schema 2 save has no open turn and loads as before (but see R-SAVE-004). A save older than schema 5 is R-SAVE-005's, and a schema 5 one R-SAVE-006's.
R-SAVE-004: A schema 2 save of the GDD game with a player attack (`order <unit> attack <q> <r>`) is refused with the code `older_rules` (R-SAVE-001): its attacks were standing orders, so it would replay differently (the owner, 23 October 2026: "Refuse with a clear message"). So is a schema 2 GDD save whose replay under the current rules does not end on its saved hash (instant capture, the full-points step). Other schema 2 saves load.
-R-SAVE-005: Since #2605 the state records the soft events the cap left waiting (R-EVT-001), so every ruleset writes schema 5. An older save of a valid schema for its ruleset (1 to 3 for `legacy`, 2 to 3 for `gdd-0.1`, 4 for `gdd-0.3`; schema 1 has no ruleset line, so it is `legacy`) still loads, and is written back as schema 5. #2536's exception for a finished game without its ending cards applies to such a save only. It was played under the earlier cap, so with the same content a replay that does not end on its saved hash, or an open-turn order the replay now refuses, is the rules' change, not damage: it loads with the `replay_differs` warning. R-SAVE-004's schema 2 refusals come first. A schema 5 save that does either on the same content is damaged (`SaveException`).
+R-SAVE-005: Since #2605 the state records the soft events the cap left waiting (R-EVT-001), so every ruleset writes schema 5. An older save of a valid schema for its ruleset (1 to 3 for `legacy`, 2 to 3 for `gdd-0.1`, 4 for `gdd-0.3`; schema 1 has no ruleset line, so it is `legacy`) still loads, and is written back in the current schema (R-SAVE-006). #2536's exception for a finished game without its ending cards applies to such a save only. It was played under the earlier cap, so with the same content a replay that does not end on its saved hash, or an open-turn order the replay now refuses, is the rules' change, not damage: it loads with the `replay_differs` warning. R-SAVE-004's schema 2 refusals come first. A schema 5 save is R-SAVE-006's.
+
+R-SAVE-006: Since #2544 a player's order to a unit in an operation cancels the operation's remaining orders for its other units (R-ENEMY-009), so every ruleset writes schema 6. A schema 5 save, of any ruleset, still loads and is written back as schema 6. It was played before that cancel, so with the same content a replay that does not end on its saved hash, or an open-turn order the replay now refuses, is the rules' change, not damage: it loads with the `replay_differs` warning. The exceptions for a missing ending card (#2536) and a missing lost marker (#2542) still apply only to saves older than schema 5, as before. A schema 6 save that does either on the same content is damaged (`SaveException`).
## Cities
@@ -372,12 +374,16 @@ R-ENEMY-003: An enemy unit off its script attacks the first neighbouring hex, in
R-ENEMY-004: No enemy unit arrives or grows in Phase 5 (Q-ENEMY-3): no turn adds an enemy unit, until a dated per-army figure is chosen under CONTENT_POLICY section 1.
-R-ENEMY-005: An option of an event may give go-to orders to units (`unit_orders`, Q-ENEMY-5): each names a `map/units_1948.yaml` row and a hex that must be one of that row's anchor hexes or order target hexes in `map/unit_anchor_hexes.yaml`, or the loader refuses it, naming the file and the field. Once R-ENEMY-007 permits the operation to start, each order in list order goes to the row's starting unit (R-UNIT-006: the unit with id i is the i-th starting force) through the player's own go-to (R-MOVE-009), with the movement points the turn's orders have already spent; a refused order changes nothing, as the player's does, and the turn's refusals list it as the player's refused orders are listed (`Orders.RefusedCardOrder`, shown in English and Hebrew). A card's order never takes the last Israeli military unit off an occupied place, occupied or awaiting its end (R-CTRL-013; owner, 2 November 2026, #2087: "Keep a garrison in Nazareth (Recommended)"): it is not given to that unit, and on any later turn of its march a card's order whose unit is now the last one there is taken away at the route step, the unit staying where it is; either way the turn's refusals list it with `Orders.RefusedLastGarrison`, as the other refused orders are listed. A second Israeli unit on the place lets the order go ahead, and the player's own go-to is never held back. Each unit is checked on its own, when its turn comes: in the option's list order when the card gives its orders, and in ascending unit id at the route step (R-MOVE-009). So of two Israeli units on one occupied place that both march on a card's orders, the one checked first goes, and the other, then the last one there, stays: at the route step the lower id goes and the higher id stays (`EnemyAITests.OfTwoUnitsOnACardsMarchTheHigherIdStays`). A held order is taken away, not kept for later: a unit that arrives on the place afterwards does not restart it. So when Horev is launched with Golani alone on an occupied Nazareth, Golani stays and the occupation goes on. Only sourced anchors receive orders (owner, 31 October 2026, #749: "Sourced anchors only"), and every military operation gives some (owner, 1 November 2026, #2087: "military operations must have unit orders"). A place an operation sent a unit to that is not one of its anchors is a row's `order_targets` entry (owner, 2 November 2026, #2087, option 1): sourced and dated as an anchor, read only by the cards' orders and `tools/unit_anchor_hexes.py`, never drawn and never a start; the loader refuses one with no `sources` or no `from`/`to` date. Kiryati's Ramle, Givati's Huleiqat, the Negev Brigade's Beersheba, Carmeli's Manara, the 7th Brigade's al-Malikiyya and Harel's Latrun police fort are order targets: `ten_days`'s historical option sends Kiryati to Ramle (Operation Dani; the owner's "Kiryati to Ramle", which replaced Yiftach's order to Lydda, as Yiftach has no unit on the board) and Carmeli to face the Syrian bridgehead at Mishmar HaYarden (Operation Brosh); `operation_yoav`'s sends the Negev Brigade to Beersheba and Givati to Huleiqat; `operation_hiram`'s sends Carmeli to Manara and the 7th Brigade to al-Malikiyya, which is refused while the ALA's unit holds that hex, as in the historical run; `operation_horev`'s sends Golani to the Julis camp; and `latrun_proposal`'s `press_offensive` sends Harel toward the Latrun police fort, the objective of Ben-Gurion's proposal of 26 September 1948 (owner, same day), refused while an enemy unit holds the fort. Kiryati's Ramle target is Ramla's capture target (-3, 24), not the (-4, 24) Ramla shares with Rehovot on the 4.4 km grid (owner, 2 November 2026, #2087: "Send it to Ramla's target"; `tools/unit_anchor_hexes.py`). Every other alternative option gives none until sources are found. The orders apply under both `gdd-0.1` and `gdd-0.3`; the legacy loop has no units and ignores them. Orders expire with the operation (the owner's answer 1 on #2087, 31 October 2026): a card's order ends on the `to` date of the anchor or order target it names, its window in `map/units_1948.yaml` (Carmeli's Brosh anchor to 19 July 1948, Kiryati's Ramle target to 16 August 1948, one turn past Operation Dani's end on 19 July, so the order takes Ramla on the 15 August turn and not Lod (owner, 2 November 2026, #2087: "Longer order: takes Ramla (Recommended)"), Givati's Huleiqat target to 1 November 1948, Harel's Latrun target to 22 December 1948, as its Sha'ar HaGai window, Golani's Julis anchor and the Negev Brigade's Beersheba target to 24 February 1949, the Egypt armistice, and Carmeli's Manara and the 7th Brigade's al-Malikiyya targets to 23 March 1949, the Lebanon armistice), and from the first turn on or after that day the unit stops where it stands (`card_order_ended`), arrived or not; the loader refuses an order to an anchor with no `to`. The anchor's dates, not the card's: the card's window is when the decision is open. A card's march goes round every enemy-held locality (R-MOVE-005, open target or not) but the hex it was sent to, so it never ends on, or captures, a place it was not sent to; a route that cannot go round is refused. The player's own go-to, which may end on an open target and capture it, is unchanged, and replaces a card's order. The four cards keep their review status (owner, same ruling: "Re-pin; you sign off").
+R-ENEMY-005: An option of an event may give go-to orders to units (`unit_orders`, Q-ENEMY-5; R-ENEMY-008 adds attack orders): each names a `map/units_1948.yaml` row and a hex that must be one of that row's anchor hexes or order target hexes in `map/unit_anchor_hexes.yaml`, or the loader refuses it, naming the file and the field. Once R-ENEMY-007 permits the operation to start, each order in list order goes to the row's starting unit (R-UNIT-006: the unit with id i is the i-th starting force) through the player's own go-to (R-MOVE-009), with the movement points the turn's orders have already spent; a refused order changes nothing, as the player's does, and the turn's refusals list it as the player's refused orders are listed (`Orders.RefusedCardOrder`, shown in English and Hebrew). A card's order never takes the last Israeli military unit off an occupied place, occupied or awaiting its end (R-CTRL-013; owner, 2 November 2026, #2087: "Keep a garrison in Nazareth (Recommended)"): it is not given to that unit, and on any later turn of its march a card's order whose unit is now the last one there is taken away at the route step, the unit staying where it is; either way the turn's refusals list it with `Orders.RefusedLastGarrison`, as the other refused orders are listed. A second Israeli unit on the place lets the order go ahead, and the player's own go-to is never held back. Each unit is checked on its own, when its turn comes: in the option's list order when the card gives its orders, and in ascending unit id at the route step (R-MOVE-009). So of two Israeli units on one occupied place that both march on a card's orders, the one checked first goes, and the other, then the last one there, stays: at the route step the lower id goes and the higher id stays (`EnemyAITests.OfTwoUnitsOnACardsMarchTheHigherIdStays`). A held order is taken away, not kept for later: a unit that arrives on the place afterwards does not restart it. So when Horev is launched with Golani alone on an occupied Nazareth, Golani stays and the occupation goes on. Only sourced anchors receive orders (owner, 31 October 2026, #749: "Sourced anchors only"), and every military operation gives some (owner, 1 November 2026, #2087: "military operations must have unit orders"). A place an operation sent a unit to that is not one of its anchors is a row's `order_targets` entry (owner, 2 November 2026, #2087, option 1): sourced and dated as an anchor, read only by the cards' orders and `tools/unit_anchor_hexes.py`, never drawn and never a start; the loader refuses one with no `sources` or no `from`/`to` date. Kiryati's Ramle, Givati's Huleiqat, the Negev Brigade's Beersheba, Carmeli's Manara, the 7th Brigade's al-Malikiyya and Harel's Latrun police fort are order targets: `ten_days`'s historical option sends Kiryati to Ramle (Operation Dani; the owner's "Kiryati to Ramle", which replaced Yiftach's order to Lydda, as Yiftach has no unit on the board) and Carmeli to face the Syrian bridgehead at Mishmar HaYarden (Operation Brosh); `operation_yoav`'s sends the Negev Brigade to Beersheba and Givati to Huleiqat; `operation_hiram`'s sends Carmeli to Manara and the 7th Brigade to al-Malikiyya, which is refused while the ALA's unit holds that hex, as in the historical run; `operation_horev`'s sends Golani to the Julis camp; and `latrun_proposal`'s `press_offensive` sends Harel toward the Latrun police fort, the objective of Ben-Gurion's proposal of 26 September 1948 (owner, same day), refused while an enemy unit holds the fort. Kiryati's Ramle target is Ramla's capture target (-3, 24), not the (-4, 24) Ramla shares with Rehovot on the 4.4 km grid (owner, 2 November 2026, #2087: "Send it to Ramla's target"; `tools/unit_anchor_hexes.py`). Every other alternative option gives none until sources are found. The orders apply under both `gdd-0.1` and `gdd-0.3`; the legacy loop has no units and ignores them. Orders expire with the operation (the owner's answer 1 on #2087, 31 October 2026): a card's order ends on the `to` date of the anchor or order target it names, its window in `map/units_1948.yaml` (Carmeli's Brosh anchor to 19 July 1948, Kiryati's Ramle target to 16 August 1948, one turn past Operation Dani's end on 19 July, so the order takes Ramla on the 15 August turn and not Lod (owner, 2 November 2026, #2087: "Longer order: takes Ramla (Recommended)"), Givati's Huleiqat target to 1 November 1948, Harel's Latrun target to 22 December 1948, as its Sha'ar HaGai window, Golani's Julis anchor and the Negev Brigade's Beersheba target to 24 February 1949, the Egypt armistice, and Carmeli's Manara and the 7th Brigade's al-Malikiyya targets to 23 March 1949, the Lebanon armistice), and from the first turn on or after that day the unit stops where it stands (`card_order_ended`), arrived or not; the loader refuses an order to an anchor with no `to`. The anchor's dates, not the card's: the card's window is when the decision is open. A card's march goes round every enemy-held locality (R-MOVE-005, open target or not) but the hex it was sent to, so it never ends on, or captures, a place it was not sent to; a route that cannot go round is refused. The player's own go-to, which may end on an open target and capture it, is unchanged, and replaces a card's order. The four cards keep their review status (owner, same ruling: "Re-pin; you sign off").
R-ENEMY-006: No enemy unit attacks inside a truce window (owner, 21 October 2026, #749): the first truce from 11 June to 8 July 1948 and the second from 18 July to 15 October 1948, half-open, the dates of `events/first_truce.yaml`, `events/second_truce.yaml`, `events/ten_days.yaml` and `events/operation_yoav.yaml` (the same windows as `map/control_hexes_1948_49.yaml`'s truce periods). A turn is in a truce when its middle day is (agent default): a monthly turn spans a truce's edge, and the middle puts it on the side that holds most of its days. So the turns of 15 June to 15 September 1948 are truce turns, and those of 15 May and 15 October 1948 are not. On a truce turn every enemy unit's standing attack ends first, whatever the unit then does (owner, #1263): it may still move on its script (R-ENEMY-002), and a unit off its script fortifies (R-ENEMY-003's else branch). The guard remains date-driven in every mode, whatever the truce cards' answers; #750 separately made accepted truce cards bind the player's attacks (R-COMBAT-009).
R-ENEMY-007: The owner, 4 November 2026 (#2543): "A military operation can only get underway if you have the required units in place (you cant fight in latrun in you dont have military units there)." For #2543 the owner chose the options labelled "In the same region", "Both rulesets (Recommended)" and, later, "Player must move them"; for a delegated card the owner's words, as recorded on #2543 on 4 November 2026, are "Postpone and explain to the user which units need to move where. Postpone until they are in the right area and if the operation is still relevant". Under the agent-recorded scope, every option with `unit_orders` has a non-empty `requires_unit_regions` list. Its required units are exactly the distinct starting-force rows in its `unit_orders`; each must still be on the board and stand on a hex in any one listed region when the option is decided. No starting position receives special credit and the sim does not pre-position a unit. The five requirements recorded in #2543 are: `ten_days.central_front`, Kiryati and Carmeli in `central_plain`, `jerusalem_hills` or `galilee`; `operation_yoav.stop_at_ceasefire`, Negev and Givati in `southern_coast` or `negev`; `operation_hiram.stop_at_ceasefire`, Carmeli and 7th Brigade in `galilee`; `operation_horev.launch`, Golani in `southern_coast` or `negev`; `latrun_proposal.press_offensive`, Harel in `central_plain` or `jerusalem_hills`. The owner's rulings of 7 November 2026 ("Add real orders", "Same units (Recommended)", "Same units as Central (Recommended)", "Keep the same targets (Recommended)", "Stop at al-Malikiyya (Recommended)") add three more, each with its units' sourced targets: `operation_yoav.push_to_hebron`, Givati to Bayt Jibrin (from 27 October 1948, the later of the sources' dates, "Second read, then later date (Recommended)") and Negev to Beersheba, in `southern_coast` or `negev`; `operation_hiram.advance_into_lebanon`, Carmeli to Manara and 7th Brigade to al-Malikiyya, in `galilee`, the crossing into Lebanon told by the card only; `ten_days.southern_front`, Kiryati and Carmeli, in `central_front`'s regions and to its targets, Ramle and the north, not a southern target. A direct unmet choice is refused before any state changes. If delegation draws an unmet operation option, the card remains pending, the turn report (its operations row) and the Why screen say which units must move to which regions, and the draw is rolled back. Since the owner's rulings of 7 November 2026 ("All five cards", "Wait, with a limit (Recommended)", "6 turns (Recommended)", "Keep the option (Recommended)"), the postponed card keeps that option and later delegations draw nothing (the state's `postponed{}` records the option and the turn and date of the first postponement); it is shown again on 6 turns (`mvp.operation_wait_turns`) and lapses at the end of the 6th, without a chosen option, effects or orders. A card never postponed lapses when its window closes, as before. A postponed card whose historical option needs no units takes that option at its next delegation, and its wait ends (Latrun: "Takes the vote, wait ends (Recommended)"). A postponed card lapses at once when a unit its option needs is no longer on the board ("Lapse at once (Recommended)"; a dated row is waited for until its day), and any pending operation lapses when its front's armistice is signed ("Signing wins (Recommended)"; `armistice_front`: Yoav and Horev egypt, Hiram lebanon, "Keep Lebanon (Recommended)", Ten Days and Latrun jordan, "Jordan signing (Recommended)"). While that front's armistice card is pending, the operation cannot be chosen and its delegation postpones it ("Decide armistice first (Recommended)"). Every lapse costs `mvp.operation_lapse_security` (-0.01) in Security, Horev's Hold ("All five -0.01 (Recommended)"). An operation that waited and launches while a truce the player accepted is in force costs `mvp.operation_truce_break_standing` (-0.10) in International Support, unless its own effects already cost it, as Latrun's offensive does ("Same as Latrun, -0.10 (Recommended)", the owner's follow-up on a late Ten Days). Its card orders end later by the time it waited ("Shift by the delay (Recommended)"; the coordinator's reading, from the first postponement to the launch). Unlike an ordinary card under R-EVT-001, an operation card never first appears once its window has closed, and the wait for a soft slot does not keep it past its window. A card with `follows` (Rhodes Talks, Sinai Withdrawal, Rafah Force Pressure) fires on the turn after its `requires` are met even when its own window has closed ("Follow the launch (Recommended)", "Shift with Sinai (Recommended)"), and a card with `armistice_front` never first fires after that front's armistice is signed, so these three drop if Egypt signs before they are shown ("They drop (Recommended)"). A card shown after its own window has closed (a late follow-up, or an operation shown again while it waits) shows its `late_text`, and in Hebrew its `late_text_he`: Rhodes Talks, Sinai Withdrawal, Rafah Force Pressure, Operation Yoav and Operation Hiram have one ("Dateless variants (Recommended)"; the texts, "All approved (Recommended)", 7 November 2026). Operation Horev's text now says Golani must reach the south first ("Reword it (Recommended)"). This applies under both GDD identities. All requirement and missing-row iteration is ordinal; immutable region geography is loaded under both identities, while regional population/control state remains `gdd-0.3` only. Under `gdd-0.1` the loader reads `regions.yaml`'s geography for this rule but no field host: the host rows (R-POP-004, #1717) and their checks stay exact `gdd-0.3`, as the opening field hosts' section says.
+R-ENEMY-008: The owner, 4 November 2026 (#2544): "In addition, deciding on a military operation makes the units do what the operation describes (shown to the user all the moves, attacks etc)." An option's `unit_orders` row may also be an attack: `{ unit, order: attack, q, r }` (`order` is `go_to` when left out). Its hex, like a go-to's, must be one of the row's anchor or order target hexes, so a card attacks only where a source puts its unit's fight (the maintainer's decision on #2544: only actions a card's cited sources state are implemented, and nothing is inferred from its prose); it needs no `to` date, as it is fought when the card is decided (the owner, 8 November 2026, answering the maintainer while #2956 was in review: "When card decided (Recommended)"); a target out of reach then is refused, and the unit does not wait to attack on arrival. A row may appear once as a go-to and once as an attack in one option, never twice as either. When the option is chosen or delegated and R-ENEMY-007 permits it, the rows run in list order: a go-to as R-ENEMY-005 gives it, and an attack through the player's own attack (`Combat.Strike`, R-COMBAT-001): the same checks and refusals (the hex in reach, an enemy unit on it, movement points left after the turn's earlier orders, no accepted truce in force under R-COMBAT-009, and the Arms under `gdd-0.1`), one engagement and one draw, and the attacker's points spent; the last-garrison rule is a go-to's only, as an attacker never leaves its hex. As the player's attack does, it ends the attacker's order, so list order matters: a row that goes to a hex and then attacks marches as far as its points allow, attacks, and its march ends there; a row that attacks and then goes to a hex keeps the go-to and marches from the next turn. A refused attack changes nothing and draws nothing, and the turn's refusals list it as a card's refused go-to is listed (`Orders.RefusedCardOrder`). When an action is refused, the owner chose the option labelled "Continue the rest (Recommended)": the later actions still run. The owner chose the option labelled "Both rulesets (Recommended)": this applies under `gdd-0.1` and `gdd-0.3`; the legacy loop has no units and ignores it. A delegated card's attack draws from the same stream as the delegation's own draws, after them, and the draw is kept. The sim lists every action an operation takes, in the order it ran, with its card, option, row, unit, order, hex and outcome (`OperationAction`: carried out, or refused with the player's own reason), on the turn's `StepResult` and `PreviewResult`, for the map and the turn report to show (#2544's later pull requests). No card has an attack row yet: each waits for a research note citing the attack (#2135).
+
+R-ENEMY-009: The owner, 4 November 2026 (#2544): "Also if a user tries to cancel orders of a unit that is in an operation, a message would tell him that this will cancel the entire operation if he choses to do this". A unit is in an operation while it carries out that card's go-to (R-ENEMY-005): the decided card whose option sends the unit's row to the hex it is going to (`EventSystem.OperationOf`; the loader refuses two cards that send one row to one hex, so the card is known). An order the sim accepts for such a unit that takes it off that go-to (a go-to of the player's own, an attack, fortify, hold or send home; a single move keeps the go-to) cancels the operation. When the player cancels a unit's orders in an operation, the owner chose the option labelled "Only remaining orders (Recommended)": only the orders still outstanding are cancelled, and the prompt says "remaining orders". Completed moves and combat stay. Every other unit still carrying the operation's go-to stops where it stands, with the line of an ended card order (`card_order_ended`; the owner, 8 November 2026, answering the maintainer while #2956 was in review: "Reuse existing line (Recommended)"), and the sim lists each of the operation's units, the ordered unit too, as withdrawn (`OperationAction`). A refused order cancels nothing. Another card's order that replaces a unit's card order moves the unit to that card's operation and cancels nothing (the owner, 8 November 2026, answering the maintainer while #2956 was in review: "1 + it can effect the success of the first op as it has less forces"). The first operation goes on without the unit: its remaining go-tos bring one unit fewer to their hexes. Its attacks were all fought when its card was decided, each by its unit alone (R-COMBAT-001, OQ-1), so none is left to weaken; the sim keeps no success or failure of an operation as a whole. Asked whether that is enough, the owner chose the option labelled "Units' fights are enough (Recommended)" (8 November 2026, recorded on #2956): a smaller operation is weaker only through its units' own fights and moves, with no new mechanic. The confirmation the player sees before such an order is #2544's user-interface pull request; the sim's cancel draws nothing and applies under both GDD identities.
+
## The war state
Phase 5 PR 11, first slice (#750; Q-WAR-1, Q-WAR-2 and Q-WAR-4, owner, 15 October 2026, #375: "Take all recommendations"; D-C4): the security rung stops being a player lever in the GDD loop and stays the value the war events set. The player's attacks in a truce (Q-WAR-3) are a later slice of #750.
diff --git a/sim/Statecraft.Sim.Tests/EnemyAITests.cs b/sim/Statecraft.Sim.Tests/EnemyAITests.cs
index 67fcaacf9..507604d1d 100644
--- a/sim/Statecraft.Sim.Tests/EnemyAITests.cs
+++ b/sim/Statecraft.Sim.Tests/EnemyAITests.cs
@@ -11,10 +11,10 @@ using Statecraft.Sim;
/// coastal plain, 10 people a population unit, two units of a side per hex and an attack ratio of 200.</summary>
public class EnemyAITests
{
- const string Types = Fixture.GddUnitTypes
+ internal const string Types = Fixture.GddUnitTypes
+ " - { id: soldier, kind: unit, side: israel, class: infantry, movement_points: 3 }\n"
+ " - { id: enemy, kind: unit, side: egypt, class: infantry, movement_points: 3 }\n";
- const string OperationRegions = "player_regions:\n"
+ internal const string OperationRegions = "player_regions:\n"
+ " - id: fixture_region\n capital_location: town_a\n member_hexes: [{ q: 0, r: 0 }, { q: 1, r: 0 }]\n"
+ " member_locations: [town_a]\n design_note: 'Operation requirement test region'\n"
+ " sources: ['test fixture: no historical claim']\n capital_approval: NEEDS-RESEARCH\n"
@@ -1672,7 +1672,7 @@ public class EnemyAITests
// combat.enemy_attack_ratio, 1.5:1 (150%); gdd-0.1 keeps mvp.enemy_attack_ratio_percent (the fixture's 200).
static Content Gdd03() => ContentLoader.Load(Fixture.Write(Gdd03Files()));
- static Dictionary<string, string> Gdd03Files()
+ internal static Dictionary<string, string> Gdd03Files()
{
var f = Fixture.Gdd(new Dictionary<string, string>
{
diff --git a/sim/Statecraft.Sim.Tests/GameSessionTurnTests.cs b/sim/Statecraft.Sim.Tests/GameSessionTurnTests.cs
index 517518fa7..f5139467d 100644
--- a/sim/Statecraft.Sim.Tests/GameSessionTurnTests.cs
+++ b/sim/Statecraft.Sim.Tests/GameSessionTurnTests.cs
@@ -121,28 +121,28 @@ public class GameSessionTurnTests
public void ASchema2SaveWithAnAttackIsRefusedAsOlderRules()
{
var session = Fresh();
- var text = session.Save.Write().Replace("statecraft-save 5", "statecraft-save 2")
+ var text = session.Save.Write().Replace("statecraft-save 6", "statecraft-save 2")
.Replace("end ", "turn\norder 0 attack 10 10\nend ");
var e = Assert.Throws<SaveException>(() => GameSession.Load(C, text, out _));
Assert.Equal(SaveException.OlderRules, e.Code);
}
// R-SAVE-004: "Other schema 2 saves load". A GDD save with no attack whose replay ends on its saved hash loads with no
- // warning, has the live game's hash, and is written back as schema 5 (R-SAVE-005).
+ // warning, has the live game's hash, and is written back in the current schema (R-SAVE-005).
[Fact]
public void AnOrdinarySchema2SaveLoads()
{
var session = Fresh();
session.Step(new Command[] { GoldenRun.SmokeMove(C, session.State), new BuyArms(1) });
session.Step(new Command[0]);
- var five = session.Save.Write();
- var two = five.Replace("statecraft-save 5\n", "statecraft-save 2\n");
+ var current = session.Save.Write();
+ var two = current.Replace("statecraft-save 6\n", "statecraft-save 2\n");
Assert.Equal(2, SaveGame.Parse(two).Version);
Assert.DoesNotContain(" attack ", two);
var loaded = GameSession.Load(C, two, out var warnings);
Assert.Empty(warnings);
Assert.Equal(session.State.Hash(), loaded.State.Hash());
- Assert.Equal(five, loaded.Save.Write());
+ Assert.Equal(current, loaded.Save.Write());
}
// R-SAVE-003: reloading keeps an attack's result; the same draw comes out.
@@ -183,19 +183,19 @@ public class GameSessionTurnTests
// R-SAVE-004: a schema 2 GDD save that does not replay to its saved hash gets the clear older-rules message. #2605: a
// schema 3 one was played before the soft-event cap kept left-out events waiting, so it loads with replay_differs; a
- // current (schema 5) one that does not is still damaged (no code).
+ // current (schema 6, R-SAVE-006) one that does not is still damaged (no code).
[Fact]
public void ASchema2SaveThatReplaysDifferentlyIsRefusedAsOlderRules()
{
static string WrongEnd(string text) { var end = text.Substring(text.LastIndexOf("end ", StringComparison.Ordinal) + 4, 64); return text.Replace("end " + end, "end " + new string('0', 64)); }
- var two = WrongEnd(Fresh().Save.Write().Replace("statecraft-save 5", "statecraft-save 2"));
+ var two = WrongEnd(Fresh().Save.Write().Replace("statecraft-save 6", "statecraft-save 2"));
Assert.Equal(SaveException.OlderRules, Assert.Throws<SaveException>(() => GameSession.Load(C, two, out _)).Code);
- var three = WrongEnd(Fresh().Save.Write().Replace("statecraft-save 5", "statecraft-save 3"));
+ var three = WrongEnd(Fresh().Save.Write().Replace("statecraft-save 6", "statecraft-save 3"));
GameSession.Load(C, three, out var warnings);
Assert.Equal(new[] { GameSession.ReplayDiffers }, warnings);
- var five = WrongEnd(Fresh().Save.Write());
- Assert.StartsWith("statecraft-save 5\n", five);
- Assert.Null(Assert.Throws<SaveException>(() => GameSession.Load(C, five, out _)).Code);
+ var six = WrongEnd(Fresh().Save.Write());
+ Assert.StartsWith("statecraft-save 6\n", six);
+ Assert.Null(Assert.Throws<SaveException>(() => GameSession.Load(C, six, out _)).Code);
}
// #2605: the same for a refused open-turn order. A schema 3 save's open turn follows a replay under the earlier soft-event
@@ -205,7 +205,26 @@ public class GameSessionTurnTests
{
var bad = Fresh().Save.Write().Replace("end ", "open\nmove 999 1 1\nend ");
Assert.Throws<SaveException>(() => GameSession.Load(C, bad, out _));
- GameSession.Load(C, bad.Replace("statecraft-save 5", "statecraft-save 3"), out var warnings);
+ GameSession.Load(C, bad.Replace("statecraft-save 6", "statecraft-save 3"), out var warnings);
+ Assert.Equal(new[] { GameSession.ReplayDiffers }, warnings);
+ }
+
+ // R-SAVE-006 (#2544): a schema 5 save was played before a player's order to a unit in an operation cancelled the
+ // operation's remaining orders for its other units (R-ENEMY-009), so a replay that ends elsewhere, or an open-turn
+ // order the replay now refuses, loads with replay_differs; a current (schema 6) save that does either is damage.
+ [Fact]
+ public void R_SAVE_006_ASchema5SaveThatReplaysDifferentlyLoadsWithReplayDiffers()
+ {
+ static string WrongEnd(string text) { var end = text.Substring(text.LastIndexOf("end ", StringComparison.Ordinal) + 4, 64); return text.Replace("end " + end, "end " + new string('0', 64)); }
+ var current = Fresh().Save.Write();
+ Assert.StartsWith("statecraft-save 6\n", current);
+ Assert.Null(Assert.Throws<SaveException>(() => GameSession.Load(C, WrongEnd(current), out _)).Code);
+ GameSession.Load(C, WrongEnd(current).Replace("statecraft-save 6\n", "statecraft-save 5\n"), out var warnings);
+ Assert.Equal(new[] { GameSession.ReplayDiffers }, warnings);
+
+ var bad = current.Replace("end ", "open\nmove 999 1 1\nend ");
+ Assert.Throws<SaveException>(() => GameSession.Load(C, bad, out _));
+ GameSession.Load(C, bad.Replace("statecraft-save 6\n", "statecraft-save 5\n"), out warnings);
Assert.Equal(new[] { GameSession.ReplayDiffers }, warnings);
}
}
diff --git a/sim/Statecraft.Sim.Tests/Gdd03ArmisticeQuietTests.cs b/sim/Statecraft.Sim.Tests/Gdd03ArmisticeQuietTests.cs
index 0975dbed0..246ed74fc 100644
--- a/sim/Statecraft.Sim.Tests/Gdd03ArmisticeQuietTests.cs
+++ b/sim/Statecraft.Sim.Tests/Gdd03ArmisticeQuietTests.cs
@@ -214,7 +214,7 @@ sources: [{ url: https://example.org/event, checked: 2026-10-18 }]
Assert.NotEmpty(engaged);
var text = game.Save.Write();
- Assert.StartsWith("statecraft-save 5", text);
+ Assert.StartsWith("statecraft-save 6", text);
var replay = GameSession.Load(c, text, out _);
Assert.Equal(game.Now.State.EngagedFronts.ToArray(), replay.Now.State.EngagedFronts.ToArray());
Assert.Equal(game.Now.State.Hash(), replay.Now.State.Hash());
diff --git a/sim/Statecraft.Sim.Tests/Gdd03SaveTests.cs b/sim/Statecraft.Sim.Tests/Gdd03SaveTests.cs
index b86ddd52b..857933ad7 100644
--- a/sim/Statecraft.Sim.Tests/Gdd03SaveTests.cs
+++ b/sim/Statecraft.Sim.Tests/Gdd03SaveTests.cs
@@ -1,18 +1,18 @@
using Statecraft.Sim;
-/// <summary>#1687, R-SAVE-001/002: a separate envelope, never a live-loop cutover. #2605: every ruleset now writes schema 5;
-/// gdd-0.3 wrote 4 before, legacy 1 to 3 and gdd-0.1 2 to 3.</summary>
+/// <summary>#1687, R-SAVE-001/002: a separate envelope, never a live-loop cutover. #2605: every ruleset wrote schema 5, and
+/// #2544 schema 6; gdd-0.3 wrote 4 before 5, legacy 1 to 3 and gdd-0.1 2 to 3.</summary>
public class Gdd03SaveTests
{
static string Text(int version, string ruleset) =>
$"statecraft-save {version}\ncontent {new string('a', 64)}\nseed 1\nmode Historical\nruleset {ruleset}\nend {new string('b', 64)}\n";
[Fact]
- public void Gdd03WritesSchemaFiveAndRoundTrips()
+ public void Gdd03WritesSchemaSixAndRoundTrips()
{
var save = new SaveGame(new string('a', 64), 1, Mode.Historical, "gdd-0.3", new string('b', 64));
- Assert.Equal(5, save.Version);
- Assert.StartsWith("statecraft-save 5\n", save.Write());
+ Assert.Equal(6, save.Version);
+ Assert.StartsWith("statecraft-save 6\n", save.Write());
Assert.Equal("gdd-0.3", SaveGame.Parse(save.Write()).Ruleset);
Assert.Equal(save.Write(), SaveGame.Parse(save.Write()).Write());
}
@@ -30,9 +30,9 @@ public class Gdd03SaveTests
[Theory]
[InlineData(4, "gdd-future")]
- [InlineData(6, "gdd-0.3")]
- [InlineData(6, "legacy")]
- [InlineData(6, "gdd-0.1")]
+ [InlineData(7, "gdd-0.3")]
+ [InlineData(7, "legacy")]
+ [InlineData(7, "gdd-0.1")]
public void UnknownRulesOrNewerSchemasAreRefused(int schema, string ruleset) =>
Assert.Equal(SaveException.NewerVersion, Assert.Throws<SaveException>(() => SaveGame.Parse(Text(schema, ruleset))).Code);
@@ -47,24 +47,28 @@ public class Gdd03SaveTests
[InlineData("legacy")]
[InlineData("gdd-0.1")]
[InlineData("gdd-0.3")]
- public void EveryRulesetWritesSchemaFive(string ruleset)
+ public void EveryRulesetWritesSchemaSix(string ruleset)
{
var save = new SaveGame(new string('a', 64), 1, Mode.Historical, ruleset, new string('b', 64));
- Assert.Equal(5, save.Version);
- Assert.StartsWith("statecraft-save 5\n", save.Write());
+ Assert.Equal(6, save.Version);
+ Assert.StartsWith("statecraft-save 6\n", save.Write());
}
- // R-SAVE-005 (#2605): the earlier schema of each ruleset still reads, keeps its version, and is written back as schema 5.
+ // R-SAVE-005 (#2605), R-SAVE-006 (#2544): each earlier schema of each ruleset still reads, keeps its version, and is
+ // written back as schema 6.
[Theory]
[InlineData(3, "legacy")]
[InlineData(3, "gdd-0.1")]
[InlineData(4, "gdd-0.3")]
- public void AnEarlierSchemaReadsAndIsWrittenBackAsFive(int schema, string ruleset)
+ [InlineData(5, "legacy")]
+ [InlineData(5, "gdd-0.1")]
+ [InlineData(5, "gdd-0.3")]
+ public void AnEarlierSchemaReadsAndIsWrittenBackAsSix(int schema, string ruleset)
{
var save = SaveGame.Parse(Text(schema, ruleset));
Assert.Equal(schema, save.Version);
Assert.Equal(ruleset, save.Ruleset);
- Assert.StartsWith("statecraft-save 5\n", save.Write());
+ Assert.StartsWith("statecraft-save 6\n", save.Write());
}
// R-SAVE-001/002: future gdd-0.3 callers must not replay the live rules' saves.
@@ -93,17 +97,18 @@ public class Gdd03SaveTests
[Theory]
[InlineData(4)]
[InlineData(5)]
+ [InlineData(6)]
public void Gdd03AcceptsItsOwnEnvelope(int schema) =>
Assert.Equal("gdd-0.3", SaveGame.Parse(Text(schema, "gdd-0.3"), SaveGame.Gdd03Ruleset).Ruleset);
[Theory]
[InlineData(4, "gdd-future")]
- [InlineData(6, "gdd-0.3")]
+ [InlineData(7, "gdd-0.3")]
public void Gdd03RefusesUnknownRulesAndFutureSchemas(int schema, string ruleset) =>
Assert.Equal(SaveException.NewerVersion, Assert.Throws<SaveException>(() => SaveGame.Parse(Text(schema, ruleset), SaveGame.Gdd03Ruleset)).Code);
// R-SAVE-005 (#2605): a schema 4 gdd-0.3 save through GameSession.Load, not only SaveGame.Parse. With its saved hash it
- // loads with no warning and is written back as schema 5. With a wrong end hash it was played under the earlier cap, so
+ // loads with no warning and is written back in the current schema. With a wrong end hash it was played under the earlier cap, so
// it loads with the replay_differs warning alone, not an exception.
[Fact]
public void ASchemaFourGdd03SaveLoadsThroughTheSession()
@@ -114,13 +119,13 @@ public class Gdd03SaveTests
var played = GameSession.New(c, 1, Mode.Historical);
played.Step(new Command[] { new BuyArms(1) });
played.Step(new Command[0]);
- var five = played.Save.Write();
- var four = five.Replace("statecraft-save 5\n", "statecraft-save 4\n");
+ var current = played.Save.Write();
+ var four = current.Replace("statecraft-save 6\n", "statecraft-save 4\n");
Assert.Equal(4, SaveGame.Parse(four).Version);
var loaded = GameSession.Load(c, four, out var warnings);
Assert.Empty(warnings);
Assert.Equal(played.State.Hash(), loaded.State.Hash());
- Assert.Equal(five, loaded.Save.Write());
+ Assert.Equal(current, loaded.Save.Write());
var wrongEnd = four.Replace("end " + played.State.Hash(), "end " + new string('0', 64));
Assert.NotEqual(four, wrongEnd);
diff --git a/sim/Statecraft.Sim.Tests/LastTurnObjectiveCardTests.cs b/sim/Statecraft.Sim.Tests/LastTurnObjectiveCardTests.cs
index 52fd0016a..90ceafbb9 100644
--- a/sim/Statecraft.Sim.Tests/LastTurnObjectiveCardTests.cs
+++ b/sim/Statecraft.Sim.Tests/LastTurnObjectiveCardTests.cs
@@ -297,8 +297,8 @@ public class LastTurnObjectiveCardTests
var newSave = g.Save.Write();
var endLine = "end " + g.State.Hash();
Assert.Contains(endLine + "\n", newSave);
- Assert.StartsWith("statecraft-save 5\n", newSave);
- return (c, newSave, newSave.Replace(endLine, "end " + old.Hash()).Replace("statecraft-save 5\n", "statecraft-save 3\n"));
+ Assert.StartsWith("statecraft-save 6\n", newSave);
+ return (c, newSave, newSave.Replace(endLine, "end " + old.Hash()).Replace("statecraft-save 6\n", "statecraft-save 3\n"));
}
// #2536: a game finished before the ending turn fired objective cards replays with its ending card added. That is the
@@ -328,14 +328,17 @@ public class LastTurnObjectiveCardTests
Assert.Throws<SaveException>(() => GameSession.Load(c, wrong, out _));
}
- // #2605 review: a current-schema save was written after #2536, so it always has its ending cards; one without them was
- // edited or damaged, and is refused like any other difference.
+ // #2605 review: a schema 5 or later save was written after #2536, so it always has its ending cards; a current one
+ // without them was edited or damaged, and is refused like any other difference. A schema 5 one (R-SAVE-006, #2544) is
+ // older rules, so it loads, but with replay_differs: the ending-card exception does not reach it.
[Fact]
public void ACurrentSchemaSaveWithoutItsEndingCardIsRefused()
{
var (c, _, oldSave) = FinishedWithAnEndingCard();
- var edited = oldSave.Replace("statecraft-save 3\n", "statecraft-save 5\n");
+ var edited = oldSave.Replace("statecraft-save 3\n", "statecraft-save 6\n");
Assert.Null(Assert.Throws<SaveException>(() => GameSession.Load(c, edited, out _)).Code);
+ GameSession.Load(c, oldSave.Replace("statecraft-save 3\n", "statecraft-save 5\n"), out var warnings);
+ Assert.Equal(new[] { GameSession.ReplayDiffers }, warnings);
}
// #2536: with other content the same save gives only content_changed, not replay_differs.
diff --git a/sim/Statecraft.Sim.Tests/NoAttentionTests.cs b/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
index b1b73bad4..a96b16867 100644
--- a/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
+++ b/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
@@ -140,7 +140,7 @@ public class NoAttentionTests
g.State.Units[99]=new Unit(99,"recruit",1,0,side:"israel",strength:1);g.State.NextId=100;
Assert.Null(g.Commit(new Move(99,2,0)));Assert.Equal(55,g.Now.State.Attention);
g.EndTurn(Array.Empty<Command>());Assert.Equal(55,g.State.Attention);
- var text=g.Save.Write();Assert.Equal(5,SaveGame.Parse(text,c.Ruleset).Version);
+ var text=g.Save.Write();Assert.Equal(6,SaveGame.Parse(text,c.Ruleset).Version);
// Use a fresh session without injected units for actual replay of an authored deferred command.
var clean=GameSession.New(c,1,Mode.Historical);clean.Step(new[]{new AssignWorkers("town_a","job",1)});
Assert.Equal(clean.State.Hash(),GameSession.Load(c,clean.Save.Write(),out _).State.Hash());
diff --git a/sim/Statecraft.Sim.Tests/NoShotArmsTests.cs b/sim/Statecraft.Sim.Tests/NoShotArmsTests.cs
index 5f09eed03..ae330caa9 100644
--- a/sim/Statecraft.Sim.Tests/NoShotArmsTests.cs
+++ b/sim/Statecraft.Sim.Tests/NoShotArmsTests.cs
@@ -311,7 +311,7 @@ public class NoShotArmsTests
public class NoShotArmsSessionTests
{
[Fact]
- public void AZeroStockInstantAttackReplaysInSchemaFiveAndIsNotRepeatedAtEndTurn()
+ public void AZeroStockInstantAttackReplaysInSchemaSixAndIsNotRepeatedAtEndTurn()
{
var root = RealContentTests.ContentRoot();
var c = ContentLoader.Load(rel =>
@@ -333,7 +333,7 @@ public class NoShotArmsSessionTests
Assert.Single(game.Now.Why, w => w.Key == WhyKeys.Engagement);
var text = game.Save.Write();
- Assert.StartsWith("statecraft-save 5", text);
+ Assert.StartsWith("statecraft-save 6", text);
var replay = GameSession.Load(c, text, out _);
Assert.Equal(game.Now.State.Hash(), replay.Now.State.Hash());
Assert.Single(replay.Committed);
diff --git a/sim/Statecraft.Sim.Tests/OperationActionsTests.cs b/sim/Statecraft.Sim.Tests/OperationActionsTests.cs
new file mode 100644
index 000000000..48bf95d6e
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/OperationActionsTests.cs
@@ -0,0 +1,277 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>#2544, R-ENEMY-008 and R-ENEMY-009: a military operation card carries out its moves and attacks, through the
+/// player's own orders, under both GDD identities; a refused action does not stop the later ones; a player's order to a unit
+/// the operation is moving cancels the operation's remaining orders; and the sim lists every action for the UI. A fixture of
+/// two brigade rows on MovementTests' 6 x 3 coastal plain (3 movement points, an enemy unit on (1, 1)). Fixture values, not
+/// history.</summary>
+public class OperationActionsTests
+{
+ // brig_a starts on (0, 0) and brig_b on (0, 1), both in the card's region. Each row's anchor 1 is a far hex a go-to takes
+ // two turns to reach; anchor 2, (1, 1), is the enemy's hex, the sourced target an attack row names.
+ const string Rows = "units:\n" + "- id: brig_a\n service: army\n side: israel\n status: draft\n"
+ + " strength: { value: 30, as_of: '1948-05-15' }\n anchors:\n"
+ + " - { place: Here, lon: 34.29, lat: 33.35, from: '1948-05-15', to: '1949-01-01' }\n"
+ + " - { place: There, lon: 34.30, lat: 33.35, from: '1948-05-15', to: '1949-01-01' }\n"
+ + " - { place: Target, lon: 34.31, lat: 33.35, from: '1948-05-15', to: '' }\n"
+ + "- id: brig_b\n service: army\n side: israel\n status: draft\n"
+ + " strength: { value: 30, as_of: '1948-05-15' }\n anchors:\n"
+ + " - { place: Here, lon: 34.29, lat: 33.36, from: '1948-05-15', to: '1949-01-01' }\n"
+ + " - { place: There, lon: 34.30, lat: 33.36, from: '1948-05-15', to: '1949-01-01' }\n"
+ + " - { place: Target, lon: 34.31, lat: 33.36, from: '1948-05-15', to: '' }\n";
+ const string Hexes = "anchors:\n"
+ + " - { id: brig_a, anchor: 0, q: 0, r: 0 }\n - { id: brig_a, anchor: 1, q: 5, r: 0 }\n - { id: brig_a, anchor: 2, q: 1, r: 1 }\n"
+ + " - { id: brig_b, anchor: 0, q: 0, r: 1 }\n - { id: brig_b, anchor: 1, q: 5, r: 2 }\n - { id: brig_b, anchor: 2, q: 1, r: 1 }\n";
+
+ static string Card(string id, string orders, string lines = "") =>
+ "id: " + id + "\ntitle: Fixture\ntext: Fixture.\nfrom: 1948-05-15\n" + lines + "options:\n"
+ + " - id: ok\n text: Accept\n historical: true\n requires_unit_regions: [fixture_region]\n"
+ + " unit_orders: [" + orders + "]\n"
+ + "sources: [{ url: \"https://example.org/event\", checked: 2026-10-18 }]\n";
+
+ static Content Load(bool gdd03, params (string Id, string Text)[] cards) => LoadIn(gdd03, "{ q: 0, r: 0 }, { q: 0, r: 1 }, { q: 1, r: 0 }", cards);
+
+ /// <summary>The fixture with the card's region made of <paramref name="hexes"/>.</summary>
+ static Content LoadIn(bool gdd03, string hexes, params (string Id, string Text)[] cards) => LoadOn(gdd03, MovementTests.Board(), hexes, cards);
+
+ /// <summary>The fixture on <paramref name="board"/>, with the card's region made of <paramref name="hexes"/>.</summary>
+ static Content LoadOn(bool gdd03, string board, string hexes, params (string Id, string Text)[] cards)
+ {
+ var files = gdd03 ? EnemyAITests.Gdd03Files() : Fixture.Gdd(new Dictionary<string, string>
+ {
+ ["unit_types.yaml"] = EnemyAITests.Types, ["corridors.yaml"] = "corridors: []\n",
+ });
+ files["map/hexes.json"] = board;
+ files["map/units_1948.yaml"] = Rows;
+ files["map/unit_anchor_hexes.yaml"] = Hexes;
+ files["regions.yaml"] = EnemyAITests.OperationRegions.Replace("{ q: 0, r: 0 }, { q: 1, r: 0 }]", hexes + "]");
+ files["map/locality_hexes.yaml"] = "localities: []\n";
+ return ContentLoader.Load(Fixture.Write(files, cards.ToDictionary(x => x.Id + ".yaml", x => x.Text)));
+ }
+
+ static Content Load(bool gdd03, string orders, string lines = "") => Load(gdd03, ("probe", Card("probe", orders, lines)));
+
+ /// <summary>A new game of <paramref name="c"/> with the probe card pending and an enemy unit of strength 5 on (1, 1).</summary>
+ static GameState Game(Content c)
+ {
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ s.Units.Add(9, new Unit(9, "enemy", 1, 1, side: "egypt", strength: 5));
+ s.NextId = Math.Max(s.NextId, 10);
+ if (!s.PendingEvents.Contains("probe")) s.PendingEvents.Add("probe");
+ return s;
+ }
+
+ static int Id(Content c, string row) => c.StartingForces.FindIndex(f => f.Row == row);
+
+ // R-ENEMY-008: an attack row is { unit, order: attack, q, r }; `order` defaults to go_to. Its hex is one of the row's own
+ // anchor or order target hexes, as a go-to's is (the maintainer's decision on #2544: only what a card's sources state),
+ // and needs no end date, since an attack is fought when the card is decided. A row may move and then attack, but not
+ // attack twice; any other order is refused.
+ [Fact]
+ public void TheLoaderReadsAttackRowsAndRefusesBadOnes()
+ {
+ var c = Load(false, "{ unit: brig_a, q: 5, r: 0 }, { unit: brig_a, order: attack, q: 1, r: 1 }");
+ var o = c.Events.Single(e => e.Id == "probe").Options.Single();
+ Assert.Equal(new[] { (Movement.GoTo, 5, 0), (Combat.Attack, 1, 1) }, o.UnitOrders.Select(x => (x.Order, x.Q, x.R)));
+
+ var bad = Assert.Throws<ContentException>(() => Load(false, "{ unit: brig_a, order: retreat, q: 1, r: 1 }"));
+ Assert.Equal("events[probe].options[ok].unit_orders[0].order", bad.Field);
+ Assert.Contains("go_to or attack", bad.Message);
+
+ var unsourced = Assert.Throws<ContentException>(() => Load(false, "{ unit: brig_a, order: attack, q: 2, r: 2 }"));
+ Assert.Equal("events[probe].options[ok].unit_orders[0]", unsourced.Field);
+ Assert.Contains("is not an anchor or an order target", unsourced.Message);
+
+ var twice = Assert.Throws<ContentException>(() => Load(false, "{ unit: brig_a, order: attack, q: 1, r: 1 }, { unit: brig_a, order: attack, q: 1, r: 1 }"));
+ Assert.Equal("events[probe].options[ok].unit_orders[1].unit", twice.Field);
+ Assert.Contains("duplicate operation unit row", twice.Message);
+ }
+
+ // R-ENEMY-009: the operation a unit is in is found from the card's go-to row, so two cards may not send the same row to
+ // the same hex: the loader refuses the second.
+ [Fact]
+ public void TwoCardsMayNotSendOneRowToOneHex()
+ {
+ var e = Assert.Throws<ContentException>(() => Load(false,
+ ("probe", Card("probe", "{ unit: brig_a, q: 5, r: 0 }")), ("probe_two", Card("probe_two", "{ unit: brig_a, q: 5, r: 0 }"))));
+ Assert.Equal(("events/probe_two.yaml", "events[probe_two].options[ok].unit_orders[0]"), (e.File, e.Field));
+ Assert.Contains("events[probe] already sends 'brig_a' to hex q=5 r=0", e.Message);
+ }
+
+ // R-ENEMY-008 (owner, 4 November 2026: "deciding on a military operation makes the units do what the operation describes";
+ // "Both rulesets (Recommended)"): the chosen card's go-to and attack run in list order under gdd-0.1 and gdd-0.3. The
+ // attack is the player's instant attack (Combat.Strike): one engagement, one draw, the attacker's points spent. Each
+ // action is listed, carried out, for the UI to replay.
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void AChosenOperationCarriesOutItsMovesAndAttacks(bool gdd03)
+ {
+ var c = Load(gdd03, "{ unit: brig_a, q: 5, r: 0 }, { unit: brig_b, order: attack, q: 1, r: 1 }");
+ int a = Id(c, "brig_a"), b = Id(c, "brig_b");
+ var s = Game(c);
+ var r = Simulation.Preview(c, s, new Command[] { new ChooseEventOption("probe", "ok") });
+
+ Assert.Empty(r.Rejected);
+ // The go-to is the player's own: the unit moves as far as the player's go-to would take it this turn.
+ var own = Simulation.Preview(c, s, new Command[] { new UnitOrder(a, Movement.GoTo, 5, 0) }).State.Units[a];
+ Assert.NotEqual((0, 0), (own.Q, own.R));
+ Assert.Equal((own.Q, own.R, Movement.GoTo, "5,0"), (r.State.Units[a].Q, r.State.Units[a].R, r.State.Units[a].Order, r.State.Units[a].OrderTarget));
+ Assert.Contains(r.Why, x => x.Key == WhyKeys.Engagement);
+ Assert.NotEqual(s.RngState, r.State.RngState); // the one engagement drew
+ Assert.Equal(Movement.Points(c, r.State.Units[b]), r.Spent[b]);
+ Assert.True(r.Attacked.ContainsKey(b));
+ Assert.Equal(new[]
+ {
+ ("probe", "ok", 0, "brig_a", (int?)a, Movement.GoTo, 5, 0, OperationAction.CarriedOut, (string?)null),
+ ("probe", "ok", 1, "brig_b", (int?)b, Combat.Attack, 1, 1, OperationAction.CarriedOut, (string?)null),
+ }, r.OperationActions.Select(x => (x.EventId, x.OptionId, x.Index, x.Row, x.Unit, x.Order, x.Q, x.R, x.Outcome, x.Reason)));
+ }
+
+ // R-ENEMY-008 (owner on #2544: "Continue the rest (Recommended)"): a refused attack changes nothing and draws nothing. It is
+ // rejected as a card's refused go-to is (Orders.RefusedCardOrder) and listed with the player's own reason; the actions
+ // after it still run.
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void ARefusedAttackDoesNotStopTheLaterActions(bool gdd03)
+ {
+ var c = Load(gdd03, "{ unit: brig_a, order: attack, q: 1, r: 1 }, { unit: brig_b, q: 5, r: 2 }");
+ int a = Id(c, "brig_a"), b = Id(c, "brig_b");
+ var s = Game(c);
+ var r = Simulation.Preview(c, s, new Command[] { new ChooseEventOption("probe", "ok") });
+
+ var refused = Assert.Single(r.Rejected);
+ Assert.Equal((a, Combat.Attack, (int?)1, (int?)1, Orders.RefusedCardOrder),
+ (((UnitOrder)refused.Command).Unit, ((UnitOrder)refused.Command).Order, ((UnitOrder)refused.Command).Q, ((UnitOrder)refused.Command).R, refused.Reason));
+ Assert.Equal((0, 0, ""), (r.State.Units[a].Q, r.State.Units[a].R, r.State.Units[a].Order));
+ Assert.Equal(s.RngState, r.State.RngState);
+ Assert.Equal(s.Units[9].Strength, r.State.Units[9].Strength);
+ Assert.Equal((Movement.GoTo, "5,2"), (r.State.Units[b].Order, r.State.Units[b].OrderTarget));
+ Assert.Equal(new[] { (a, OperationAction.Refusal, Combat.RefusedNotAdjacent), (b, OperationAction.CarriedOut, (string?)null) },
+ r.OperationActions.Select(x => (x.Unit!.Value, x.Outcome, x.Reason)));
+ }
+
+ // R-ENEMY-008: a delegated card's attack draws exactly as the chosen card's does. Red first: Delegate kept its own copy of
+ // the RNG and wrote it back at the end, so the engagement's draw was lost and the next draw repeated it.
+ [Fact]
+ public void ADelegatedAttackKeepsItsDraw()
+ {
+ var c = Load(false, "{ unit: brig_b, order: attack, q: 1, r: 1 }", "anchor: hard\n");
+ var chosen = Game(c);
+ var delegated = chosen.Clone();
+ var before = chosen.RngState;
+ Assert.Null(EventSystem.Choose(c, chosen, "probe", "ok", new List<Cause>()));
+ var actions = new List<OperationAction>();
+ EventSystem.Delegate(c, delegated, new List<Cause>(), actions: actions);
+
+ Assert.NotEqual(before, chosen.RngState);
+ Assert.Equal(chosen.RngState, delegated.RngState);
+ Assert.Equal(chosen.Hash(), delegated.Hash());
+ Assert.Equal(OperationAction.CarriedOut, Assert.Single(actions).Outcome);
+ }
+
+ // R-ENEMY-009 (owner, 4 November 2026: "if a user tries to cancel orders of a unit that is in an operation, a message would
+ // tell him that this will cancel the entire operation"; on #2544: "Only remaining orders (Recommended)"): a player's order
+ // that takes a unit off its operation order cancels the operation's remaining orders. Every other unit of the operation
+ // stops where it stands; what was done stays (the moves made). A refused order cancels nothing.
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void APlayersOrderToAUnitInTheOperationCancelsItsRemainingOrders(bool gdd03)
+ {
+ var c = Load(gdd03, "{ unit: brig_a, q: 5, r: 0 }, { unit: brig_b, q: 5, r: 2 }");
+ int a = Id(c, "brig_a"), b = Id(c, "brig_b");
+ var s = Game(c);
+ var chosen = Simulation.Preview(c, s, new Command[] { new ChooseEventOption("probe", "ok") }).State;
+ Assert.Equal(new[] { a, b }, EventSystem.OperationUnits(c, chosen, "probe"));
+ Assert.Equal("probe", EventSystem.OperationOf(c, chosen, a));
+ var moved = (chosen.Units[b].Q, chosen.Units[b].R);
+ Assert.NotEqual((0, 1), moved);
+
+ // A refused order (brig_a has no points left to attack with) leaves the operation as it was.
+ var kept = Simulation.Preview(c, s, new Command[] { new ChooseEventOption("probe", "ok"), new UnitOrder(a, Combat.Attack, 1, 1) });
+ Assert.Single(kept.Rejected);
+ Assert.Equal(new[] { a, b }, EventSystem.OperationUnits(c, kept.State, "probe"));
+ Assert.DoesNotContain(kept.OperationActions, x => x.Outcome == OperationAction.Withdrawn);
+
+ var r = Simulation.Preview(c, s, new Command[] { new ChooseEventOption("probe", "ok"), new UnitOrder(a, Orders.Fortify) });
+ Assert.Empty(r.Rejected);
+ Assert.Equal(Orders.Fortifying, r.State.Units[a].Order);
+ Assert.Equal((moved.Item1, moved.Item2, "", ""), (r.State.Units[b].Q, r.State.Units[b].R, r.State.Units[b].Order, r.State.Units[b].OrderTarget));
+ Assert.False(r.State.CardOrders.ContainsKey(b));
+ Assert.Empty(EventSystem.OperationUnits(c, r.State, "probe"));
+ Assert.Null(EventSystem.OperationOf(c, r.State, a));
+ Assert.Contains(r.Why, x => x.Key == WhyKeys.CardOrderEnded && x.Args.SequenceEqual(new[] { "5,2" }));
+ Assert.Equal(new[] { ("probe", 0, a, Movement.GoTo, 5, 0), ("probe", 1, b, Movement.GoTo, 5, 2) },
+ r.OperationActions.Where(x => x.Outcome == OperationAction.Withdrawn).Select(x => (x.EventId, x.Index, x.Unit!.Value, x.Order, x.Q, x.R)));
+ Assert.DoesNotContain(r.Why, x => x.Key == WhyKeys.CardOrderEnded && x.Args.SequenceEqual(new[] { "5,0" })); // the player's order is brig_a's line
+ Assert.Equal(chosen.Units[a].Q, r.State.Units[a].Q); // the moves made stay
+ }
+ // R-ENEMY-009 (owner, 8 November 2026, answering the maintainer while #2956 was in review: "1 + it can effect the success of the first op as it has less forces"):
+ // another card's order that takes a unit of an operation moves the unit to that card's operation and cancels nothing; the
+ // first operation goes on with one unit fewer. Not red first: this pins the behaviour PR 1 already had when the owner ruled.
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void AnotherCardTakesAUnitAndTheFirstOperationGoesOnWithoutIt(bool gdd03)
+ {
+ // The region is the whole board, so brig_b, already on its way, is still in place for the second card (R-ENEMY-007).
+ var board = string.Join(", ", Enumerable.Range(0, 6).SelectMany(q => Enumerable.Range(0, 3).Select(r => $"{{ q: {q}, r: {r} }}")));
+ var c = LoadIn(gdd03, board, ("probe", Card("probe", "{ unit: brig_a, q: 5, r: 0 }, { unit: brig_b, q: 5, r: 2 }")),
+ ("other", Card("other", "{ unit: brig_b, q: 0, r: 1 }")));
+ int a = Id(c, "brig_a"), b = Id(c, "brig_b");
+ var s = Game(c);
+ if (!s.PendingEvents.Contains("other")) s.PendingEvents.Add("other");
+ s.Attention = 99; // two cards decided in one turn; the Attention price is not under test
+ var first = Simulation.Preview(c, s, new Command[] { new ChooseEventOption("probe", "ok") });
+ Assert.Equal(new[] { a, b }, EventSystem.OperationUnits(c, first.State, "probe"));
+
+ var r = Simulation.Preview(c, s, new Command[] { new ChooseEventOption("probe", "ok"), new ChooseEventOption("other", "ok") });
+ Assert.Empty(r.Rejected.Select(x => x.Reason));
+ Assert.Equal(new[] { a }, EventSystem.OperationUnits(c, r.State, "probe"));
+ Assert.NotEqual("5,2", r.State.Units[b].OrderTarget);
+ Assert.Contains(r.OperationActions, x => (x.EventId, x.Unit, x.Outcome) == ("other", (int?)b, OperationAction.CarriedOut));
+ Assert.Equal(first.State.Units[a].OrderTarget, r.State.Units[a].OrderTarget); // brig_a still carries the first card's go-to
+ Assert.Equal((first.State.Units[a].Q, first.State.Units[a].R), (r.State.Units[a].Q, r.State.Units[a].R));
+ Assert.DoesNotContain(r.OperationActions, x => x.Outcome == OperationAction.Withdrawn);
+ Assert.DoesNotContain(r.Why, x => x.Key == WhyKeys.CardOrderEnded);
+ }
+
+ // R-ENEMY-008: an operation's attack is the player's own attack (Combat.Strike, R-COMBAT-001), so it ends the attacker's
+ // order, as the player's attack does. A row that goes to a hex and then attacks marches as far as its points allow, attacks
+ // with the point left, and its march ends there; a row that attacks first and then goes to a hex keeps the go-to and
+ // marches from the next turn. The list order is the order of the actions. A brigade has 3 points under gdd-0.1 and 2
+ // under gdd-0.3 (military.move_infantry), so the hills (cost 2) are put on q = 3 or q = 2: either way brig_a's go-to east
+ // stops next to the enemy on (1, 1), on (2, 0) or (1, 0), with 1 point left.
+ [Theory]
+ [InlineData(false, 3)]
+ [InlineData(true, 2)]
+ public void AnAttackEndsTheAttackersGoToAndAGoToAfterItStands(bool gdd03, int hills)
+ {
+ var board = MovementTests.Board((hills, 0, "hills"), (hills, 1, "hills"), (hills, 2, "hills"));
+ const string region = "{ q: 0, r: 0 }, { q: 0, r: 1 }, { q: 1, r: 0 }";
+ var c = LoadOn(gdd03, board, region, ("probe", Card("probe",
+ "{ unit: brig_a, q: 5, r: 0 }, { unit: brig_a, order: attack, q: 1, r: 1 }, "
+ + "{ unit: brig_b, order: attack, q: 1, r: 1 }, { unit: brig_b, q: 5, r: 2 }")));
+ int a = Id(c, "brig_a"), b = Id(c, "brig_b");
+ var s = Game(c);
+
+ var marched = Simulation.Preview(c, s, new Command[] { new UnitOrder(a, Movement.GoTo, 5, 0) });
+ Assert.Equal((hills - 1, 0, Movement.GoTo), (marched.State.Units[a].Q, marched.State.Units[a].R, marched.State.Units[a].Order));
+ Assert.Equal(1, Movement.PointsLeft(c, marched.State, a, marched.Spent));
+
+ var r = Simulation.Preview(c, s, new Command[] { new ChooseEventOption("probe", "ok") });
+ Assert.Empty(r.Rejected);
+ Assert.All(r.OperationActions, x => Assert.Equal(OperationAction.CarriedOut, x.Outcome));
+ Assert.Equal(4, r.OperationActions.Count);
+ Assert.Equal((hills - 1, 0, "", ""), (r.State.Units[a].Q, r.State.Units[a].R, r.State.Units[a].Order, r.State.Units[a].OrderTarget));
+ Assert.Equal((0, 1, Movement.GoTo, "5,2"), (r.State.Units[b].Q, r.State.Units[b].R, r.State.Units[b].Order, r.State.Units[b].OrderTarget));
+ Assert.True(r.Attacked.ContainsKey(a));
+ Assert.True(r.Attacked.ContainsKey(b));
+ Assert.Equal(new[] { b }, EventSystem.OperationUnits(c, r.State, "probe"));
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/PopulationLedgerTests.cs b/sim/Statecraft.Sim.Tests/PopulationLedgerTests.cs
index 596c45895..a29289379 100644
--- a/sim/Statecraft.Sim.Tests/PopulationLedgerTests.cs
+++ b/sim/Statecraft.Sim.Tests/PopulationLedgerTests.cs
@@ -132,7 +132,7 @@ public class PopulationLedgerTests
}
// R-POP-001, R-POP-003, R-LOOP-002, R-CITY-001, R-CITY-008: old identities neither gain state nor accept helpers. Their
- // saves differ from gdd-0.3's only by the ruleset line (every ruleset writes schema 5 since #2605).
+ // saves differ from gdd-0.3's only by the ruleset line (every ruleset writes schema 6 since #2544).
[Theory] [InlineData("legacy")] [InlineData("gdd-0.1")]
public void OldIdentitiesKeepCanonicalTextAndSaveBytes(string identity)
{
@@ -141,7 +141,7 @@ public class PopulationLedgerTests
Assert.Throws<InvalidOperationException>(()=>s.PopulationLedger.RegisterArrival("ship",0,Person()));
Assert.Equal(before,s.Describe()); Assert.Equal(before,s.Clone().Describe());
var save = new SaveGame(new string('a',64),1,Mode.Historical,identity,new string('b',64));
- Assert.Equal($"statecraft-save 5\ncontent {new string('a',64)}\nseed 1\nmode Historical\nruleset {identity}\nend {new string('b',64)}\n",save.Write());
+ Assert.Equal($"statecraft-save 6\ncontent {new string('a',64)}\nseed 1\nmode Historical\nruleset {identity}\nend {new string('b',64)}\n",save.Write());
}
// R-POP-001, R-LOOP-005: no numeric fallback from the old common scale or Deferred start.army.
diff --git a/sim/Statecraft.Sim.Tests/RulesetSelectorTests.cs b/sim/Statecraft.Sim.Tests/RulesetSelectorTests.cs
index 748d73e80..0c5595ee8 100644
--- a/sim/Statecraft.Sim.Tests/RulesetSelectorTests.cs
+++ b/sim/Statecraft.Sim.Tests/RulesetSelectorTests.cs
@@ -94,9 +94,9 @@ public class RulesetSelectorTests
}
[Theory]
- [InlineData("legacy", null, "legacy", 5)]
- [InlineData("gdd", null, "gdd-0.1", 5)]
- [InlineData("gdd", "gdd-0.3", "gdd-0.3", 5)]
+ [InlineData("legacy", null, "legacy", 6)]
+ [InlineData("gdd", null, "gdd-0.1", 6)]
+ [InlineData("gdd", "gdd-0.3", "gdd-0.3", 6)]
public void SessionAndSaveCarrySelectedIdentity(string loop, string? selector, string expected, int schema)
{
var c = Load(loop, selector);
diff --git a/sim/Statecraft.Sim.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
index a3fc18550..035088743 100644
--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs
+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
@@ -58,10 +58,10 @@ public class SaveGameTests
var save = new SaveGame(new string('a', 64), 7, Mode.Historical, SaveGame.GddRuleset, new string('b', 64));
save.SetOpen(new Command[] { new Move(1, 2, 3), new UnitOrder(1, Orders.Hold) });
var text = save.Write();
- Assert.StartsWith("statecraft-save 5\n", text);
+ Assert.StartsWith("statecraft-save 6\n", text);
Assert.Contains("open\nmove 1 2 3\norder 1 hold\nend ", text);
var back = SaveGame.Parse(text);
- Assert.Equal(5, back.Version);
+ Assert.Equal(6, back.Version);
Assert.Equal(new[] { "move", "unit_order" }, back.Open.Select(x => x.Kind));
}
@@ -221,7 +221,7 @@ public class SaveGameTests
var c = Fixture1();
var text = Played(c).Save.Write();
var lines = text.Split('\n');
- Assert.Equal("statecraft-save 5", lines[0]);
+ Assert.Equal("statecraft-save 6", lines[0]);
Assert.Equal("content " + c.Hash, lines[1]);
Assert.Equal("seed 99", lines[2]);
Assert.Equal("mode Historical", lines[3]);
@@ -267,7 +267,7 @@ public class SaveGameTests
}
[Theory]
- [InlineData("statecraft-save 6", 1, "line 1: save schema version 6 is newer than this game (5)")]
+ [InlineData("statecraft-save 7", 1, "line 1: save schema version 7 is newer than this game (6)")]
[InlineData("statecraft-save 4", 1, "line 1: no version of the game wrote a legacy save in schema 4")]
[InlineData("statecraft-save x", 1, "line 1: bad schema version")]
[InlineData("chess-save 1", 1, "line 1: expected 'statecraft-save'")]
@@ -366,7 +366,7 @@ public class SaveGameTests
Assert.Throws<ArgumentNullException>(() => g.Step(new Command[] { new Appoint(null!, "pm_one") }));
Assert.Throws<ArgumentNullException>(() => g.Step(new Command[] { new MapAction(null!, 1, 1) }));
Assert.Empty(g.Save.Turns); // nothing half-recorded
- Assert.StartsWith("statecraft-save 5\n", g.Save.Write());
+ Assert.StartsWith("statecraft-save 6\n", g.Save.Write());
}
[Fact]
@@ -625,7 +625,7 @@ public class SaveGameTests
[Theory]
[InlineData("statecraft-save 0", "unknown save schema version 0")]
- [InlineData("statecraft-save 6", "save schema version 6 is newer than this game (5)")]
+ [InlineData("statecraft-save 7", "save schema version 7 is newer than this game (6)")]
[InlineData("statecraft-save -1", "bad schema version")]
public void SchemaVersionsOutsideOneAreRefused(string first, string message)
{
@@ -653,7 +653,7 @@ public class SaveGameTests
var g = GameSession.New(Fixture1(), 1, Mode.Historical);
Assert.Throws<ArgumentException>(() => g.Step(new Command[] { new Foreign() }));
g.Step(new Command[0]);
- Assert.StartsWith("statecraft-save 5\n", g.Save.Write());
+ Assert.StartsWith("statecraft-save 6\n", g.Save.Write());
Assert.Single(g.Save.Turns);
}
@@ -693,7 +693,7 @@ public class SaveGameTests
var g = GameSession.New(c, 1, Mode.Historical);
g.Step(HistoricalAI.Commands(c, g.State));
var text = g.Save.Write();
- Assert.StartsWith("statecraft-save 5\n", text);
+ Assert.StartsWith("statecraft-save 6\n", text);
Assert.Contains("\nruleset gdd-0.1\n", text);
Assert.Equal("gdd-0.1", SaveGame.Parse(text).Ruleset);
Assert.Equal(g.State.Hash(), GameSession.Load(c, text, out var warnings).State.Hash());
@@ -706,10 +706,10 @@ public class SaveGameTests
{
var c = Fixture1();
var g = Played(c);
- var v1 = g.Save.Write().Replace("statecraft-save 5\n", "statecraft-save 1\n").Replace("ruleset legacy\n", "");
+ var v1 = g.Save.Write().Replace("statecraft-save 6\n", "statecraft-save 1\n").Replace("ruleset legacy\n", "");
Assert.Equal("legacy", SaveGame.Parse(v1).Ruleset);
Assert.Equal(g.State.Hash(), GameSession.Load(c, v1, out _).State.Hash());
- Assert.StartsWith("statecraft-save 5\n", SaveGame.Parse(v1).Write()); // written back as the current schema
+ Assert.StartsWith("statecraft-save 6\n", SaveGame.Parse(v1).Write()); // written back as the current schema
Assert.Contains("\nruleset legacy\n", SaveGame.Parse(v1).Write());
}
@@ -726,7 +726,7 @@ public class SaveGameTests
Assert.Equal(SaveException.OlderRules, ex.Code);
Assert.Equal("This save was made with an earlier version of the game's rules.", ex.Message);
Assert.DoesNotContain("new game", ex.Message);
- var v1 = g.Save.Write().Replace("statecraft-save 5\n", "statecraft-save 1\n").Replace("ruleset legacy\n", "");
+ var v1 = g.Save.Write().Replace("statecraft-save 6\n", "statecraft-save 1\n").Replace("ruleset legacy\n", "");
var ex1 = Assert.Throws<SaveException>(() => GameSession.Load(real, v1, out _));
Assert.Equal((ex.Code, ex.Message), (ex1.Code, ex1.Message));
}
@@ -744,8 +744,8 @@ public class SaveGameTests
Assert.Contains("This save was made with a newer version of the game", ex.Message);
Assert.DoesNotContain("new game", ex.Message);
Assert.Equal(SaveException.NewerVersion, Assert.Throws<SaveException>(() => GameSession.Load(real, text, out _)).Code);
- var schema6 = text.Replace("statecraft-save 5\n", "statecraft-save 6\n");
- Assert.Equal(SaveException.NewerVersion, Assert.Throws<SaveException>(() => SaveGame.Parse(schema6)).Code);
+ var schema7 = text.Replace("statecraft-save 6\n", "statecraft-save 7\n");
+ Assert.Equal(SaveException.NewerVersion, Assert.Throws<SaveException>(() => SaveGame.Parse(schema7)).Code);
}
// R-SAVE-001
diff --git a/sim/Statecraft.Sim/Commands.cs b/sim/Statecraft.Sim/Commands.cs
index 5e992eeb1..a452d9569 100644
--- a/sim/Statecraft.Sim/Commands.cs
+++ b/sim/Statecraft.Sim/Commands.cs
@@ -222,12 +222,37 @@ namespace Statecraft.Sim
public Rejection(Command command, string reason) { Command = command; Reason = reason; }
}
+ /// <summary>#2544, R-ENEMY-008, R-ENEMY-009: one action of a military operation card, in the order the sim took it, for
+ /// the UI to show: the option's unit_orders row <see cref="Index"/> (map/units_1948.yaml row <see cref="Row"/>, the unit
+ /// <see cref="Unit"/>), its order (go_to or attack) and hex, and what came of it: <see cref="CarriedOut"/>, <see cref="Refusal"/>
+ /// with the player's refusal <see cref="Reason"/>, or <see cref="Withdrawn"/> when a player's order to a unit in the
+ /// operation cancelled the order before it was done.</summary>
+ public sealed class OperationAction
+ {
+ // Not named Refused*: that prefix marks a player-facing refusal reason, which must have a Hebrew string (#2707,
+ // HebrewUiTests.EveryNamedSimRefusalHasAHebrewString); an outcome is not one.
+ public const string CarriedOut = "carried_out", Refusal = "refused", Withdrawn = "withdrawn";
+ public string EventId { get; } public string OptionId { get; } public int Index { get; } public string Row { get; }
+ public int? Unit { get; } public string Order { get; } public int Q { get; } public int R { get; }
+ public string Outcome { get; } public string? Reason { get; }
+ public OperationAction(string eventId, string optionId, int index, string row, int? unit, string order, int q, int r,
+ string outcome, string? reason = null)
+ {
+ EventId = eventId; OptionId = optionId; Index = index; Row = row; Unit = unit; Order = order; Q = q; R = r;
+ Outcome = outcome; Reason = reason;
+ }
+ }
+
public sealed class StepResult
{
public GameState State { get; }
public IReadOnlyList<Cause> Why { get; }
public IReadOnlyList<Rejection> Rejected { get; }
- public StepResult(GameState state, IReadOnlyList<Cause> why, IReadOnlyList<Rejection> rejected) { State = state; Why = why; Rejected = rejected; }
+ /// <summary>The operation cards' actions this turn (R-ENEMY-008, R-ENEMY-009), in the order they ran.</summary>
+ public IReadOnlyList<OperationAction> OperationActions { get; }
+ public StepResult(GameState state, IReadOnlyList<Cause> why, IReadOnlyList<Rejection> rejected,
+ IReadOnlyList<OperationAction>? operationActions = null)
+ { State = state; Why = why; Rejected = rejected; OperationActions = operationActions ?? Array.Empty<OperationAction>(); }
}
/// <summary>A player's accepted attack this turn, captured before combat changes or removes its front-bearing target.</summary>
@@ -253,9 +278,14 @@ namespace Statecraft.Sim
public IReadOnlyDictionary<int, AttackRecord> Attacked { get; }
public IReadOnlyList<Cause> Why { get; }
public IReadOnlyList<Rejection> Rejected { get; }
+ /// <summary>The operation cards' actions the orders took (R-ENEMY-008, R-ENEMY-009), in the order they ran.</summary>
+ public IReadOnlyList<OperationAction> OperationActions { get; }
public PreviewResult(GameState state, IReadOnlyDictionary<int, int> spent, IReadOnlyDictionary<int, AttackRecord> attacked,
- IReadOnlyList<Cause> why, IReadOnlyList<Rejection> rejected)
- { State = state; Spent = spent; Attacked = attacked; Why = why; Rejected = rejected; }
+ IReadOnlyList<Cause> why, IReadOnlyList<Rejection> rejected, IReadOnlyList<OperationAction>? operationActions = null)
+ {
+ State = state; Spent = spent; Attacked = attacked; Why = why; Rejected = rejected;
+ OperationActions = operationActions ?? Array.Empty<OperationAction>();
+ }
}
/// <summary>Checks that every text an order carries can be saved: a null id or a lone surrogate would make the save
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index dc102e8b9..018ae0ade 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -1130,11 +1130,13 @@ namespace Statecraft.Sim
public string At { get; set; } = "";
}
- /// <summary>An option's go-to order (R-ENEMY-005) for the unit of the map/units_1948.yaml row <see cref="Unit"/>, toward
- /// hex (<see cref="Q"/>, <see cref="R"/>), which must be one of that row's anchor or order target hexes (map/unit_anchor_hexes.yaml).</summary>
+ /// <summary>An option's order for the unit of the map/units_1948.yaml row <see cref="Unit"/>: a go-to (R-ENEMY-005) toward,
+ /// or an attack (R-ENEMY-008) on, hex (<see cref="Q"/>, <see cref="R"/>), which must be one of that row's anchor or order
+ /// target hexes (map/unit_anchor_hexes.yaml). <see cref="Order"/> is go_to unless the card says attack.</summary>
public sealed class UnitOrderEffect
{
public string Unit { get; set; } = "";
+ public string Order { get; set; } = Movement.GoTo;
public int Q { get => q ?? 0; set => q = value; }
public int R { get => r ?? 0; set => r = value; }
[YamlIgnore] public bool QGiven => q.HasValue;
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index d11f7b20a..0f7716fee 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -446,7 +446,7 @@ namespace Statecraft.Sim
// options: [{ id, text, historical, recommended, effects: [{ target, delta }], set_rung, set_policy,
// grant_units: [{ type, n, at }], city_effects: [{ city, field, delta }],
// unlock_projects: [<projects.yaml id of a locked kind>],
- // unit_orders: [{ unit, q, r }] (R-ENEMY-005) }]
+ // unit_orders: [{ unit, order, q, r }] (R-ENEMY-005; order go_to or attack, R-ENEMY-008) }]
// sources: [{ url, checked }], status
// objective the objective (objectives.yaml) whose completion card this is: it fires only once
// that objective is recorded, and has exactly one option
diff --git a/sim/Statecraft.Sim/EventRules.cs b/sim/Statecraft.Sim/EventRules.cs
index 5861def55..dc6484e77 100644
--- a/sim/Statecraft.Sim/EventRules.cs
+++ b/sim/Statecraft.Sim/EventRules.cs
@@ -177,10 +177,36 @@ namespace Statecraft.Sim
CheckStructured(c, e, o, e.Tags.Any(SensitiveTags.Contains), field => $"events[{e.Id}].{field}");
CheckOrders(c, e, o, field => $"events[{e.Id}].{field}");
}
+ CheckOperationHexes(c);
}
- /// <summary>R-ENEMY-005 (Q-ENEMY-5): an option's go-to orders name a map/units_1948.yaml row and one of that row's own
- /// anchor or order target hexes, so a card never sends a unit to a position no source gives it (owner, 31 October 2026,
+ /// <summary>R-ENEMY-009: the operation a unit is in is the card whose decided option sent its row to the hex it is going
+ /// to (<see cref="EventSystem.OperationOf"/>), so no two cards send one row to one hex. The options of one card may: only
+ /// one of them is decided. GDD only, as <see cref="CheckOrders"/>'s hex checks are.</summary>
+ static void CheckOperationHexes(Content c)
+ {
+ if (!c.IsGdd) return;
+ var sent = new Dictionary<(string Row, int Q, int R), string>();
+ foreach (var e in c.Events)
+ {
+ var mine = new HashSet<(string Row, int Q, int R)>();
+ foreach (var o in e.Options)
+ for (int i = 0; i < o.UnitOrders.Count; i++)
+ {
+ var x = o.UnitOrders[i];
+ if (x.Order != Movement.GoTo) continue;
+ var key = (x.Unit, x.Q, x.R);
+ if (sent.TryGetValue(key, out var other) && other != e.Id)
+ throw new ContentException(e.File, FormattableString.Invariant($"events[{e.Id}].options[{o.Id}].unit_orders[{i}]"),
+ FormattableString.Invariant($"events[{other}] already sends '{x.Unit}' to hex q={x.Q} r={x.R}: a unit's operation is found from its order (R-ENEMY-009)"));
+ mine.Add(key);
+ }
+ foreach (var key in mine) sent[key] = e.Id;
+ }
+ }
+
+ /// <summary>R-ENEMY-005 (Q-ENEMY-5), R-ENEMY-008: an option's go-to and attack orders name a map/units_1948.yaml row and
+ /// one of that row's own anchor or order target hexes, so a card never sends a unit to a position no source gives it (owner, 31 October 2026,
/// #749: sourced anchors only; 2 November 2026, #2087: order targets, option 1). They are checked and applied under
/// both GDD identities. R-ENEMY-007 also requires every operation option to author its allowed player regions. The legacy loop reads the
/// same real cards but no units file, so it has nothing to check them against and no unit to order.</summary>
@@ -193,6 +219,8 @@ namespace Statecraft.Sim
if (x.Unit.Trim() == "") throw new ContentException(e.File, at + ".unit", "required");
if (!x.QGiven) throw new ContentException(e.File, at + ".q", "required");
if (!x.RGiven) throw new ContentException(e.File, at + ".r", "required");
+ if (x.Order != Movement.GoTo && x.Order != Combat.Attack) // R-ENEMY-008
+ throw new ContentException(e.File, at + ".order", $"'{x.Order}' is not an operation order: go_to or attack");
}
if (!c.IsGdd) return;
var requirementField = F(FormattableString.Invariant($"options[{o.Id}].requires_unit_regions"));
@@ -212,19 +240,21 @@ namespace Statecraft.Sim
if (!regions.Add(id)) throw new ContentException(e.File, at, "duplicate region id");
if (!c.PlayerRegions.Regions.ContainsKey(id)) throw new ContentException(e.File, at, $"unknown player region '{id}' ({PlayerRegionCatalogue.FileName})");
}
- var rows = new HashSet<string>(StringComparer.Ordinal);
+ // R-ENEMY-008: a row may move and then attack, so a row may appear once per order.
+ var rows = new HashSet<(string Row, string Order)>();
for (int i = 0; i < o.UnitOrders.Count; i++)
{
var x = o.UnitOrders[i];
var at = F(FormattableString.Invariant($"options[{o.Id}].unit_orders[{i}]"));
- if (!rows.Add(x.Unit)) throw new ContentException(e.File, at + ".unit", "duplicate operation unit row");
+ if (!rows.Add((x.Unit, x.Order))) throw new ContentException(e.File, at + ".unit", "duplicate operation unit row");
if (!c.UnitAnchorHexes.Keys.Any(k => k.Row == x.Unit))
throw new ContentException(e.File, at + ".unit", $"unknown unit row '{x.Unit}' ({StartingForces.FileName})");
if (!c.UnitAnchorHexes.Any(k => k.Key.Row == x.Unit && k.Value == (x.Q, x.R))
&& !c.UnitOrderTargets.Any(k => k.Key.Row == x.Unit && (k.Value.Q, k.Value.R) == (x.Q, x.R)))
throw new ContentException(e.File, at, FormattableString.Invariant($"hex q={x.Q} r={x.R} is not an anchor or an order target of '{x.Unit}' in {StartingForces.HexesFileName}"));
- // The order ends with its anchor's window (the owner's answer 1 on #2087), so the anchor needs an end.
- if (EventSystem.OrderEnds(c, x) == null)
+ // The order ends with its anchor's window (the owner's answer 1 on #2087), so the anchor needs an end. An attack
+ // is fought when the card is decided (R-ENEMY-008) and outlasts nothing.
+ if (x.Order == Movement.GoTo && EventSystem.OrderEnds(c, x) == null)
throw new ContentException(e.File, at, FormattableString.Invariant($"the anchor of '{x.Unit}' on hex q={x.Q} r={x.R} has no 'to' date in {StartingForces.FileName}"));
}
}
diff --git a/sim/Statecraft.Sim/EventSystem.cs b/sim/Statecraft.Sim/EventSystem.cs
index a5f4556ab..ec8749492 100644
--- a/sim/Statecraft.Sim/EventSystem.cs
+++ b/sim/Statecraft.Sim/EventSystem.cs
@@ -153,10 +153,56 @@ namespace Statecraft.Sim
return new OperationRequirementStatus(required, missing);
}
+ /// <summary>R-ENEMY-009: the decided operation card whose go-to order unit <paramref name="unitId"/> is carrying out, or
+ /// null. The operation binds the unit while the card's go-to stands (Movement.GiveGoTo's card order): the card is the one
+ /// whose decided option sends the unit's map/units_1948.yaml row to the hex the unit is going to, which the loader keeps
+ /// unique (EventRules.CheckOperationHexes). Pure: no state or RNG change.</summary>
+ public static string? OperationOf(Content c, GameState s, int unitId)
+ {
+ if (!c.IsGdd || !s.CardOrders.ContainsKey(unitId) || !s.Units.TryGetValue(unitId, out var u) || u.Order != Movement.GoTo
+ || unitId < 0 || unitId >= c.StartingForces.Count) // the unit with id i is the i-th force (R-UNIT-006)
+ return null;
+ var force = c.StartingForces[unitId];
+ if (u.Side != force.Side || u.Type != force.Type) return null;
+ foreach (var e in c.Events)
+ if (s.ChosenOptions.TryGetValue(e.Id, out var chosen) && e.Options.FirstOrDefault(o => o.Id == chosen) is EventOption option
+ && option.UnitOrders.Any(x => x.Order == Movement.GoTo && x.Unit == force.Row && Hex(x.Q, x.R) == u.OrderTarget))
+ return e.Id;
+ return null;
+ }
+
+ /// <summary>R-ENEMY-009: the units, in ascending id, still carrying out operation card <paramref name="eventId"/>'s
+ /// orders (<see cref="OperationOf"/>): the units a player's order to any one of them would stop. Pure.</summary>
+ public static IReadOnlyList<int> OperationUnits(Content c, GameState s, string eventId) =>
+ s.CardOrders.Keys.Where(id => OperationOf(c, s, id) == eventId).ToList();
+
+ /// <summary>R-ENEMY-009 (owner, 4 November 2026; on #2544, "Only remaining orders (Recommended)"): a player's order took a
+ /// unit of operation <paramref name="eventId"/> off its order, so the operation's remaining orders are cancelled. Each
+ /// unit of <paramref name="bound"/> (the operation's units before that order) still carrying the card's go-to stops where
+ /// it stands, with the line of an ended card order; the moves made and the fights fought stay. Every one of them,
+ /// the ordered unit too, is listed as withdrawn. No RNG.</summary>
+ internal static void CancelOperation(Content c, GameState s, string eventId, IReadOnlyList<int> bound, List<Cause> why, List<OperationAction>? actions)
+ {
+ var option = Get(c, eventId).Options.First(o => o.Id == s.ChosenOptions[eventId]);
+ foreach (var id in bound)
+ {
+ var row = c.StartingForces[id].Row;
+ var i = option.UnitOrders.FindIndex(x => x.Order == Movement.GoTo && x.Unit == row);
+ var x = option.UnitOrders[i];
+ if (OperationOf(c, s, id) == eventId) Movement.Withdraw(s, id, why);
+ actions?.Add(new OperationAction(eventId, option.Id, i, row, id, Movement.GoTo, x.Q, x.R, OperationAction.Withdrawn));
+ }
+ }
+
+ static string Hex(int q, int r) => FormattableString.Invariant($"{q},{r}");
+
/// <summary>Returns null on success, or the reason the choice was rejected. <paramref name="spent"/> is the movement
/// points the turn's orders have spent so far, which an option's unit orders share (R-ENEMY-005).
- /// A refused unit order goes into <paramref name="rejected"/>, as the player's refused orders do.</summary>
- public static string? Choose(Content c, GameState s, string eventId, string optionId, List<Cause> why, Dictionary<int, int>? spent = null, List<Rejection>? rejected = null)
+ /// A refused unit order goes into <paramref name="rejected"/>, as the player's refused orders do, and each of the option's
+ /// unit orders into <paramref name="actions"/> (R-ENEMY-008). An attack is recorded in <paramref name="attacked"/>, as
+ /// the player's is.</summary>
+ public static string? Choose(Content c, GameState s, string eventId, string optionId, List<Cause> why, Dictionary<int, int>? spent = null, List<Rejection>? rejected = null,
+ List<OperationAction>? actions = null, Dictionary<int, AttackRecord>? attacked = null)
{
PopulationLedger.RefuseAggregate(s);
if (!s.PendingEvents.Contains(eventId)) return "That event is not waiting for a decision";
@@ -164,12 +210,13 @@ namespace Statecraft.Sim
if (option == null) return "That event has no such option";
if (ArmisticeBlock(c, s, Get(c, eventId), option) is string block) return block;
if (!OperationStatus(c, s, option).Met) return RefusedOperationUnitsNotInPlace;
- Resolve(c, s, eventId, option, "chosen", why, spent: spent, rejected: rejected);
+ Resolve(c, s, eventId, option, "chosen", why, spent: spent, rejected: rejected, actions: actions, attacked: attacked);
return null;
}
/// <param name="share">The share of each numeric effect that applies: 1, except for a disloyal minister's delegation (R-EVT-003).</param>
- static void Resolve(Content c, GameState s, string eventId, EventOption o, string how, List<Cause> why, double share = 1.0, bool delegated = false, Person? minister = null, Dictionary<int, int>? spent = null, List<Rejection>? rejected = null)
+ static void Resolve(Content c, GameState s, string eventId, EventOption o, string how, List<Cause> why, double share = 1.0, bool delegated = false, Person? minister = null, Dictionary<int, int>? spent = null, List<Rejection>? rejected = null,
+ List<OperationAction>? actions = null, Dictionary<int, AttackRecord>? attacked = null)
{
s.PendingEvents.Remove(eventId);
// R-ENEMY-007: a decided card waits no more. Q4 (owner, 7 November 2026: "Shift by the delay (Recommended)"): a card
@@ -279,21 +326,31 @@ namespace Statecraft.Sim
// R-EFX-008: after the city effects. A kind already unlocked stays so, with no second cause.
foreach (var kind in o.UnlockProjects)
if (s.UnlockedProjects.Add(kind)) why.Add(new Cause("events", kind, 1, $"{Unlocked(c, kind)} ({title})", key: CauseKeys.EventUnlock, args: Context(title, localizedTitle)));
- // R-ENEMY-005 (Q-ENEMY-5): the option's go-to orders, through the player's own go-to and its checks, in list order.
- // A refused order changes nothing, as the player's does, and is reported as the player's are (Rejected); a row with
- // no unit on the board orders nobody. R-ENEMY-007 applies the orders under both GDD identities once every required
- // unit is in place. The owner's answer 1 on #2087: the order ends with the operation (OrderEnds), and
+ // R-ENEMY-005 (Q-ENEMY-5), R-ENEMY-008: the option's go-to and attack orders, through the player's own go-to and
+ // attack (Combat.Strike: the turn's movement points, one engagement, one draw) and their checks, in list order (the
+ // owner, 4 November 2026: "deciding on a military operation makes the units do what the operation describes").
+ // A refused order changes nothing, as the player's does, and is reported as the player's are (Rejected), with the
+ // card's reason; the orders after it still run (on #2544: "Continue the rest (Recommended)"). Each order is listed
+ // in `actions` with the player's own reason. A row with no unit on the board orders nobody. R-ENEMY-007 applies the
+ // orders under both GDD identities once every required unit is in place. The owner's answer 1 on #2087: a go-to
+ // ends with the operation (OrderEnds), and
// its march goes round every enemy-held place but the one it was sent to (Movement.Search). The owner's ruling of
// 2 November 2026 on #2087 ("Keep a garrison in Nazareth (Recommended)"): the order never takes the last Israeli unit
// off an occupied place (R-CTRL-013), so it is not given to that unit, and the refusal says why.
- foreach (var x in o.UnitOrders)
+ var points = spent ?? new Dictionary<int, int>();
+ for (int i = 0; i < o.UnitOrders.Count; i++)
{
+ var x = o.UnitOrders[i];
int id = c.StartingForces.FindIndex(f => f.Row == x.Unit); // the unit with id i is the i-th force (R-UNIT-006)
if (id < 0 || !s.Units.TryGetValue(id, out var u) || u.Side != c.StartingForces[id].Side || u.Type != c.StartingForces[id].Type) continue;
- var refused = SettlementControl.LastGarrison(c, s, u) ? Orders.RefusedLastGarrison
- : Movement.GiveGoTo(c, s, id, x.Q, x.R, spent ?? new Dictionary<int, int>(), why, OrderEnds(c, x) + delay) != null ? Orders.RefusedCardOrder
- : null;
- if (refused != null) rejected?.Add(new Rejection(new UnitOrder(id, Movement.GoTo, x.Q, x.R), refused));
+ // An attacker never leaves its hex (R-COMBAT-001), so the last-garrison rule is a go-to's alone.
+ var reason = x.Order == Combat.Attack ? Combat.Strike(c, s, id, x.Q, x.R, points, attacked ?? new Dictionary<int, AttackRecord>(), why)
+ : SettlementControl.LastGarrison(c, s, u) ? Orders.RefusedLastGarrison
+ : Movement.GiveGoTo(c, s, id, x.Q, x.R, points, why, OrderEnds(c, x) + delay);
+ if (reason != null)
+ rejected?.Add(new Rejection(new UnitOrder(id, x.Order, x.Q, x.R), reason == Orders.RefusedLastGarrison ? reason : Orders.RefusedCardOrder));
+ actions?.Add(new OperationAction(eventId, o.Id, i, x.Unit, id, x.Order, x.Q, x.R,
+ reason == null ? OperationAction.CarriedOut : OperationAction.Refusal, reason));
}
foreach (var kv in o.SetPolicy.Where(k => s.Policies.ContainsKey(k.Key)).OrderBy(k => k.Key, StringComparer.Ordinal))
{
@@ -457,7 +514,8 @@ namespace Statecraft.Sim
/// In the GDD loop a drawn option of a minister whose loyalty is below the floor applies only disloyal_effect_share of
/// each numeric effect (R-EVT-003; #107, owner, 18 October 2026). Why: loyalty decides how hard a minister works for a
/// decision he was left to make, competence which decision he makes; anchors and objective cards stay whole.</summary>
- public static void Delegate(Content c, GameState s, List<Cause> why, Dictionary<int, int>? spent = null, List<Rejection>? rejected = null)
+ public static void Delegate(Content c, GameState s, List<Cause> why, Dictionary<int, int>? spent = null, List<Rejection>? rejected = null,
+ List<OperationAction>? actions = null, Dictionary<int, AttackRecord>? attacked = null)
{
PopulationLedger.RefuseAggregate(s);
var rng = new Rng(s.RngState);
@@ -469,7 +527,9 @@ namespace Statecraft.Sim
var minister = DelegatedTo(c, s, e);
if (e.Objective != "" || e.Prisoners != "" || e.Deported != "") // R-POW-004, R-EVT-007: an exchange card or a Deport card, like an objective's, has one option and draws nothing
{
- Resolve(c, s, id, e.Options[0], $"delegated to {minister?.Name ?? "the cabinet"}", why, delegated: true, minister: minister, spent: spent, rejected: rejected);
+ s.RngState = rng.State; // an operation's attack draws from the state (R-ENEMY-008), so hand it the stream and take it back
+ Resolve(c, s, id, e.Options[0], $"delegated to {minister?.Name ?? "the cabinet"}", why, delegated: true, minister: minister, spent: spent, rejected: rejected, actions: actions, attacked: attacked);
+ rng.State = s.RngState;
continue;
}
var beforeDraw = rng.State;
@@ -507,7 +567,9 @@ namespace Statecraft.Sim
why.Add(OperationCause(c, s, e, status.Missing, CauseKeys.OperationPostponed));
continue;
}
- Resolve(c, s, id, option, how, why, share, delegated: true, minister: minister, spent: spent, rejected: rejected);
+ s.RngState = rng.State; // as above: the attack's draw follows the minister's and is kept
+ Resolve(c, s, id, option, how, why, share, delegated: true, minister: minister, spent: spent, rejected: rejected, actions: actions, attacked: attacked);
+ rng.State = s.RngState;
}
s.RngState = rng.State;
}
diff --git a/sim/Statecraft.Sim/GameSession.cs b/sim/Statecraft.Sim/GameSession.cs
index d4cbedc1f..5538a3846 100644
--- a/sim/Statecraft.Sim/GameSession.cs
+++ b/sim/Statecraft.Sim/GameSession.cs
@@ -83,9 +83,11 @@ namespace Statecraft.Sim
/// warning (spec section 7), and a second warning if the replay then differs from the saved game. The warnings are
/// kinds (<see cref="ContentChanged"/>, <see cref="ReplayDiffers"/>), not display text: the UI says each in the
/// player's language, as it does SaveException.Code (#637). A finished game whose replay differs only by the ending
- /// turn's objective cards (#2536) is not a difference: it loads with no warning. A save older than schema 5 was played
- /// before the soft-event cap kept a left-out event waiting (#2605), so with the same content a different replay is
- /// the rules' change, not damage: it loads with <see cref="ReplayDiffers"/>.</summary>
+ /// turn's objective cards (#2536) is not a difference: it loads with no warning. A save older than the current schema
+ /// was played under earlier rules (before schema 5, the soft-event cap did not keep a left-out event waiting, #2605;
+ /// before schema 6, a player's order to a unit in an operation did not cancel the operation's remaining orders,
+ /// #2544), so with the same content a different replay is the rules' change, not damage: it loads with
+ /// <see cref="ReplayDiffers"/>.</summary>
public static GameSession Load(Content c, string saveText, out IReadOnlyList<string> warnings)
{
if (c == null) throw new ArgumentNullException(nameof(c));
@@ -98,7 +100,7 @@ namespace Statecraft.Sim
var list = new List<string>();
bool sameContent = saved.ContentHash == c.Hash;
if (!sameContent) list.Add(ContentChanged);
- // #2605: only a current-schema save with the same content must replay exactly; an older one may differ.
+ // #2605, #2544: only a current-schema save with the same content must replay exactly; an older one may differ.
bool mustMatch = sameContent && saved.Version >= SaveGame.SchemaVersion;
var session = New(c, saved.Seed, saved.Mode);
int turnNo = 0;
@@ -107,13 +109,13 @@ namespace Statecraft.Sim
catch (Exception e) { throw new SaveException(FormattableString.Invariant($"turn {turnNo + 1}: {e.Message}"), e); }
// #2536: a game finished before the ending turn fired objective cards replays with those cards added, and only
// them: the same game, so it loads as saved, with no warning, and shows its ending card(s).
- // Only an older save can be from before #2536: a current-schema save always has its ending cards (#2605 review).
+ // Only a save older than schema 5 can be from before #2536: a later one always has its ending cards (#2605 review).
// #2542: a save made before stayed losses left a marker replays with only those markers added. It is the same
// game, so accept that exact same-content difference; every other replay mismatch keeps the existing handling.
- // Only an older save can be from before the markers: a current-schema save always has them, so one without them
- // was edited (Codex review of 47da9b207).
- if (session.State.Hash() != saved.FinalHash && !(saved.Version < SaveGame.SchemaVersion && OnlyEndingCardsAdded(c, session.State, saved.FinalHash))
- && !(saved.Version < SaveGame.SchemaVersion && sameContent && OnlyLostMarkersAdded(session.State, saved.FinalHash)))
+ // Only a save older than schema 5 can be from before the markers: a later one always has them, so one without them
+ // was edited (Codex review of 47da9b207). Both stay at schema 5 when the schema moves on (#2544).
+ if (session.State.Hash() != saved.FinalHash && !(saved.Version < SaveGame.SoftEventCapSchemaVersion && OnlyEndingCardsAdded(c, session.State, saved.FinalHash))
+ && !(saved.Version < SaveGame.SoftEventCapSchemaVersion && sameContent && OnlyLostMarkersAdded(session.State, saved.FinalHash)))
{
if (saved.Version < 3 && saved.Ruleset == SaveGame.GddRuleset)
throw new SaveException(0, "This save was made with an earlier version of the game's rules.", SaveException.OlderRules);
diff --git a/sim/Statecraft.Sim/Movement.cs b/sim/Statecraft.Sim/Movement.cs
index 1fc1dba26..e24b486d4 100644
--- a/sim/Statecraft.Sim/Movement.cs
+++ b/sim/Statecraft.Sim/Movement.cs
@@ -171,6 +171,15 @@ namespace Statecraft.Sim
why.Add(UnitLines.Line(key, line, new[] { u }, hex));
}
+ /// <summary>R-ENEMY-009: an operation's remaining go-to for unit <paramref name="id"/> is cancelled (EventSystem.CancelOperation):
+ /// the unit stops where it stands, with the line of a card order that has ended.</summary>
+ internal static void Withdraw(GameState s, int id, List<Cause> why)
+ {
+ var u = s.Units[id];
+ var hex = u.OrderTarget;
+ Stop(s, u, WhyKeys.CardOrderEnded, $"Unit {id} stopped: the operation's order to hex {hex} has ended", hex, why);
+ }
+
/// <summary>Takes the unit's go-to away where it stands.</summary>
static void Clear(GameState s, Unit u)
{
diff --git a/sim/Statecraft.Sim/SaveGame.cs b/sim/Statecraft.Sim/SaveGame.cs
index fc87f9dd3..33b358abd 100644
--- a/sim/Statecraft.Sim/SaveGame.cs
+++ b/sim/Statecraft.Sim/SaveGame.cs
@@ -30,7 +30,8 @@ namespace Statecraft.Sim
/// <summary>
/// A save is seed + command log + content hash + schema version (spec section 3); loading replays it. Text format,
/// one item per line:
- /// statecraft-save 5 every ruleset (#2605); earlier: 3 for legacy and gdd-0.1, 4 for gdd-0.3, 1 with no ruleset line (legacy)
+ /// statecraft-save 6 every ruleset (#2544); earlier: 5 for every ruleset (#2605), before that 3 for legacy and
+ /// gdd-0.1, 4 for gdd-0.3, 1 with no ruleset line (legacy)
/// content &lt;hex&gt; Content.Hash of the content it was played with
/// seed &lt;ulong&gt; / mode Historical
/// ruleset legacy|gdd-0.1|gdd-0.3 the rules it was played under (Content.Ruleset); another ruleset refuses it (R-SAVE-001),
@@ -47,10 +48,15 @@ namespace Statecraft.Sim
/// </summary>
public sealed class SaveGame
{
- /// <summary>The schema every new save is written in, whatever its ruleset (#2605: the state now records the soft events
- /// the cap left waiting, so a replay of an older save can end elsewhere; GameSession.Load says so instead of refusing).</summary>
- public const int SchemaVersion = 5;
- /// <summary>The last schema written before <see cref="SchemaVersion"/>: legacy and gdd-0.1 wrote 3, gdd-0.3 wrote 4 (#1687).</summary>
+ /// <summary>The schema every new save is written in, whatever its ruleset. #2605 made it 5 (the state records the soft
+ /// events the cap left waiting); #2544 made it 6 (a player's order to a unit in an operation cancels the operation's
+ /// remaining orders, R-ENEMY-009). Either way a replay of an older save can end elsewhere, and GameSession.Load says so
+ /// instead of refusing (R-SAVE-005, R-SAVE-006).</summary>
+ public const int SchemaVersion = 6;
+ /// <summary>The schema #2605 introduced and every ruleset wrote until <see cref="SchemaVersion"/>. A save in it or later
+ /// always has its ending cards (#2536) and lost markers (#2542), so GameSession.Load allows those differences only below it.</summary>
+ public const int SoftEventCapSchemaVersion = 5;
+ /// <summary>The last schema written before <see cref="SoftEventCapSchemaVersion"/>: legacy and gdd-0.1 wrote 3, gdd-0.3 wrote 4 (#1687).</summary>
const int LegacyPreviousSchemaVersion = 3, Gdd03PreviousSchemaVersion = 4;
/// <summary>The ruleset of the legacy loop (Content.Ruleset).</summary>
public const string LegacyRuleset = "legacy";
@@ -209,10 +215,10 @@ namespace Statecraft.Sim
throw new SaveException(5, $"This save was made with a newer version of the game (ruleset '{ruleset}').", SaveException.NewerVersion);
first = 5;
}
- // #1687, #2605, R-SAVE-001/002: before schema 5, schema 4 belonged only to the isolated gdd-0.3 envelope, legacy
- // wrote 1 to 3 and gdd-0.1 2 to 3 (schema 1 has no ruleset line, so it is legacy). No build wrote another pairing,
- // so such a save was edited: damage, not older or newer rules.
- if (version < SchemaVersion && (ruleset == Gdd03Ruleset ? version != Gdd03PreviousSchemaVersion : version > LegacyPreviousSchemaVersion))
+ // #1687, #2605, R-SAVE-001/002: every ruleset wrote schema 5 (#2605) and now 6 (#2544). Before schema 5, schema 4
+ // belonged only to the isolated gdd-0.3 envelope, legacy wrote 1 to 3 and gdd-0.1 2 to 3 (schema 1 has no ruleset
+ // line, so it is legacy). No build wrote another pairing, so such a save was edited: damage, not older or newer rules.
+ if (version < SoftEventCapSchemaVersion && (ruleset == Gdd03Ruleset ? version != Gdd03PreviousSchemaVersion : version > LegacyPreviousSchemaVersion))
throw new SaveException(1, FormattableString.Invariant($"no version of the game wrote a {ruleset} save in schema {version}"));
// Check compatibility before replay, including gdd-0.1 -> gdd-0.3 as earlier rules.
if (expectedRuleset != null && ruleset != expectedRuleset)
diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.cs
index 96d6ca080..d74b0c170 100644
--- a/sim/Statecraft.Sim/Simulation.cs
+++ b/sim/Statecraft.Sim/Simulation.cs
@@ -58,8 +58,11 @@ namespace Statecraft.Sim
}
var spent = new Dictionary<int, int>();
- RunOrders(c, s, commands, spent, new Dictionary<int, AttackRecord>(), why, rejected);
- EventSystem.Delegate(c, s, why, spent, rejected); // a delegated card's unit orders share the turn's movement (R-ENEMY-005)
+ var attacked = new Dictionary<int, AttackRecord>();
+ var actions = new List<OperationAction>();
+ RunOrders(c, s, commands, spent, attacked, why, rejected, actions);
+ // A delegated card's unit orders share the turn's movement and attacks (R-ENEMY-005, R-ENEMY-008).
+ EventSystem.Delegate(c, s, why, spent, rejected, actions, attacked);
var len = SecuritySystem.TurnLengthFor(c, s.Date, s.Rung);
// The next era's start, or the game's end (the last era's end, or mvp.end in the GDD loop, R-LOOP-004), is a
@@ -94,7 +97,7 @@ namespace Statecraft.Sim
// A game that just ended raises no new events, but the unfired cards of recorded objectives (R-LOOP-004, R-OBJ-003;
// the owner's choice "Show the card (Recommended)", 4 November 2026, #2536).
EventSystem.Trigger(c, s, why, turnStart, endingTurn: s.GameOver != null);
- return new StepResult(s, why, rejected);
+ return new StepResult(s, why, rejected, actions);
}
/// <summary>The date the turn starting on <paramref name="s"/>'s date ends on: its turn length from the war state,
@@ -137,10 +140,11 @@ namespace Statecraft.Sim
var s = state.Clone();
var why = new List<Cause>(); var rejected = new List<Rejection>(); var spent = new Dictionary<int, int>();
var attacked = new Dictionary<int, AttackRecord>();
+ var actions = new List<OperationAction>();
if (s.GameOver != null)
foreach (var cmd in commands) rejected.Add(new Rejection(cmd, $"The game is over: {PlayerText.GameOver(s.GameOver)}"));
- else RunOrders(c, s, commands, spent, attacked, why, rejected);
- return new PreviewResult(s, spent, attacked, why, rejected);
+ else RunOrders(c, s, commands, spent, attacked, why, rejected, actions);
+ return new PreviewResult(s, spent, attacked, why, rejected, actions);
}
/// <summary>A move, a go-to, an attack, fortify or hold takes effect at once; Send home and every other order waits
@@ -151,7 +155,8 @@ namespace Statecraft.Sim
/// 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, AttackRecord> attacked, List<Cause> why, List<Rejection> rejected)
+ Dictionary<int, AttackRecord> attacked, List<Cause> why, List<Rejection> rejected,
+ List<OperationAction>? actions = null)
{
if (c.IsGdd) Movement.ContinueRoutes(c, s, spent, why, rejected); // R-MOVE-009: the route step, before the turn's orders
if (c.IsGdd) SettlementControl.CaptureHeld(c, s, why);
@@ -169,10 +174,10 @@ 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, priceRung, dollarsAtStart, rejected);
+ error = AttentionSystem.TrySpend(c, s, cmd.Kind, priceRung) ?? Execute(c, s, cmd, spent, attacked, why, priceRung, dollarsAtStart, rejected, actions);
if (error != null) s.Attention = before;
}
- else error = Execute(c, s, cmd, spent, attacked, why, priceRung, dollarsAtStart, rejected);
+ else error = Execute(c, s, cmd, spent, attacked, why, priceRung, dollarsAtStart, rejected, actions);
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
}
@@ -196,7 +201,7 @@ namespace Statecraft.Sim
/// 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, AttackRecord> attacked, List<Cause> why, int startRung, int dollarsAtStart,
- List<Rejection> rejected)
+ List<Rejection> rejected, List<OperationAction>? actions)
{
switch (cmd)
{
@@ -238,7 +243,7 @@ namespace Statecraft.Sim
return null;
}
case ChooseEventOption e:
- return EventSystem.Choose(c, s, e.EventId, e.OptionId, why, spent, rejected); // a refused unit order is rejected on its own (R-ENEMY-005)
+ return EventSystem.Choose(c, s, e.EventId, e.OptionId, why, spent, rejected, actions, attacked); // a refused unit order is rejected on its own (R-ENEMY-005)
case SetMobilization m:
return SecuritySystem.SetMobilization(c, s, m.Level, why);
case Appoint a:
@@ -264,13 +269,16 @@ namespace Statecraft.Sim
case StopWork w:
return Projects.Stop(c, s, w.Unit, why);
case UnitOrder o:
- if (o.Order == Movement.GoTo) return Movement.GiveGoTo(c, s, o.Unit, o.Q, o.R, spent, why);
- if (o.Order == Combat.Attack) return Combat.Strike(c, s, o.Unit, o.Q, o.R, spent, attacked, why);
- if (o.Q != null || o.R != null) return Orders.RefusedNamesNoHex;
- if (o.Order == Qualification.ReturnOrder) return Qualification.Return(c, s, o.Unit, why);
- return o.Order == Demobilization.SendHome
- ? Demobilization.Give(c, s, o.Unit, attacked, why)
- : Orders.Give(c, s, o.Unit, o.Order, why);
+ {
+ // R-ENEMY-009 (owner, 4 November 2026; on #2544, "Only remaining orders (Recommended)"): an order that takes a
+ // unit off its operation's go-to cancels the operation's remaining orders. A refused order cancels nothing.
+ var operation = EventSystem.OperationOf(c, s, o.Unit);
+ var bound = operation == null ? null : EventSystem.OperationUnits(c, s, operation);
+ var error = GiveUnitOrder(c, s, o, spent, attacked, why);
+ if (error == null && operation != null && EventSystem.OperationOf(c, s, o.Unit) != operation)
+ EventSystem.CancelOperation(c, s, operation, bound!, why, actions);
+ return error;
+ }
case StartProject p:
return Projects.StartCity(c, s, p.ProjectKind, p.City, p.Q, p.R, why);
case CancelProject p:
@@ -294,6 +302,17 @@ namespace Statecraft.Sim
}
}
+ static string? GiveUnitOrder(Content c, GameState s, UnitOrder o, Dictionary<int, int> spent, Dictionary<int, AttackRecord> attacked, List<Cause> why)
+ {
+ if (o.Order == Movement.GoTo) return Movement.GiveGoTo(c, s, o.Unit, o.Q, o.R, spent, why);
+ if (o.Order == Combat.Attack) return Combat.Strike(c, s, o.Unit, o.Q, o.R, spent, attacked, why);
+ if (o.Q != null || o.R != null) return Orders.RefusedNamesNoHex;
+ if (o.Order == Qualification.ReturnOrder) return Qualification.Return(c, s, o.Unit, why);
+ return o.Order == Demobilization.SendHome
+ ? Demobilization.Give(c, s, o.Unit, attacked, why)
+ : Orders.Give(c, s, o.Unit, o.Order, why);
+ }
+
/// <summary>True in an era whose legislature is an assembly (eras.yaml systems.legislature): its vote is held but does not bind.</summary>
static bool Advisory(Content c, GameState s) => c.SystemsAt(s.Date).Legislature == EraSystems.Assembly;