A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Military replacements: Reinforce refills damaged formations with trained recruits that cost Arms (Fixes #1510) (#1524)
Beribed61e9d1521
diff --git a/changelog.d/1510.md b/changelog.d/1510.mdnew file mode 100644index 000000000..5d839ac57--- /dev/null+++ b/changelog.d/1510.md@@ -0,0 +1,4 @@+- Replacements: a damaged formation standing in a friendly city can take trained replacements from its civilians+ without work (`Reinforce`, R-TRAIN-004). Each group pays its course's Money and Arms, the unit refills up to the+ strength it had before its first loss, a veteran stays a veteran, and the replacements are cancelled if the unit is+ lost or leaves the city. The unit card offers Reinforce (Fixes #1510).diff --git a/content/rules.yaml b/content/rules.yamlindex f23b5d33a..f49cfb120 100644--- a/content/rules.yaml+++ b/content/rules.yaml@@ -15,6 +15,7 @@ attention_cost:assign_workers: 0.5 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6)train: 1 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6)cancel_training: 0.5 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6)+ reinforce: 1 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6; owner, 24 October 2026, #1510: "1, like Train")pioneer_work: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free)stop_work: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free)unit_order: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free; R-ORDER-001, #746)diff --git a/docs/GDD.md b/docs/GDD.mdindex ad78e5c4e..04354fb51 100644--- a/docs/GDD.md+++ b/docs/GDD.md@@ -51,7 +51,7 @@ The player can choose ministers. TBD: minister roles, available candidates, appo| Resource or parameter | Role | Still to define ||---|---|---|| Money | Funds development and other paid actions. Craftsmen earn more money. | Income per job, construction costs and upkeep. |-| Arms | Available military equipment. | Decided, D-G6: "From events (sourced arms deals) and Money. Training and attacks consume it" ([impact plan §5](superpowers/specs/2026-10-12-gdd-v0.1-impact-and-plan.md)). The four numbers asked on #856 and #781 are set (owner, 18 October 2026, #781: "Approve as drafted"), labelled design values in `rules.yaml`: one Arms is the equipment package for one 1,000-person recruit group, 12 Arms on 15 May 1948, IL 1m an Arms, 1 a recruit group, and 1 Attention for the buy order whatever the quantity (R-ARMS-001 to R-ARMS-003). Whether replacements consume it is open. **Then decided (owner, 23 Oct 2026, "Replacements cost Arms"; [#1510](https://github.com/eyalgolan/statecraft-israel/issues/1510#issuecomment-6372356139)):** trained recruits can refill a damaged formation, and each replacement group consumes Arms as recruit training does (R-ARMS-003); the rule is built under #1510. |+| Arms | Available military equipment. | Decided, D-G6: "From events (sourced arms deals) and Money. Training and attacks consume it" ([impact plan §5](superpowers/specs/2026-10-12-gdd-v0.1-impact-and-plan.md)). The four numbers asked on #856 and #781 are set (owner, 18 October 2026, #781: "Approve as drafted"), labelled design values in `rules.yaml`: one Arms is the equipment package for one 1,000-person recruit group, 12 Arms on 15 May 1948, IL 1m an Arms, 1 a recruit group, and 1 Attention for the buy order whatever the quantity (R-ARMS-001 to R-ARMS-003). Whether replacements consume it is open. **Then decided (owner, 23 Oct 2026, "Replacements cost Arms"; [#1510](https://github.com/eyalgolan/statecraft-israel/issues/1510#issuecomment-6372356139)):** trained recruits can refill a damaged formation, and each replacement group consumes Arms as recruit training does (R-ARMS-003); built under #1510 as R-TRAIN-004. || Food | Available food supply. | Production, imports, consumption and storage; stockpile or supply capacity. || Social cohesion (לכידות חברתית) | National parameter describing cohesion in society. Proposed influences include housing, employment and shortages. | Scale, thresholds and gameplay effects; effects of military decisions and events. || International Support | National parameter describing support from other countries. Proposed influences include military decisions and events. | Scale, thresholds and gameplay effects. |diff --git a/docs/gdd/military-combat.md b/docs/gdd/military-combat.mdindex 1419b5f62..e61261630 100644--- a/docs/gdd/military-combat.md+++ b/docs/gdd/military-combat.md@@ -13,7 +13,7 @@ On 15 May 1948, with the Provisional government declared, the player takes comma- Orders are free and spend no Attention (`D-A6`). The standing orders are Move (תנועה), Go-to, Fortify (ביצור), Hold (החזקה) and Attack (התקפה) (`Q-UI-2`, decided 15 October 2026 [S7]; owner, 23 October 2026, #1402 and #1398: "Approve, start building"). Fortify takes one turn, costs nothing, and grants a defence bonus (value: open (owner)); the bonus is lost the moment the unit moves (`Q-HOLD-1`, decided 15 October 2026 [S7]). Hold can be given only on the player's own hex and grants no interception; its effect is a value: open (owner) (`Q-HOLD-2`, decided 15 October 2026 [S7]).- Movement costs integer movement points per unit type against an integer cost per biome; lakes and the sea are impassable (`Q-MOVE-1`, decided 15 October 2026 [S3]). A unit with all its movement points may always enter one neighbouring land hex, whatever its cost; after spending points, it needs the full cost of the next hex (owner, 23 October 2026, #1402 and #1398: "No, strict like Civ VI" and "Approve, start building"). A built corridor road lowers its hex's movement cost, since roads mattered (`D-G2`; `Q-MOVE-2`, decided 15 October 2026 [S3]). A stacking limit caps units of a side per hex; entering a hex an enemy unit holds is an attack (`Q-MOVE-3`, decided 15 October 2026 [S3]). There is no zone of control: a unit may enter any land hex it can pay for (`Q-MOVE-4`, decided 15 October 2026 [S3]). A unit may not enter an enemy-held locality: entering would be a capture action, and the MVP records no rule for civilians under capture, so this is refused until Phase six (`Q-CIV-1`, the owner's pick, 15 October 2026 [S4]). There is no transport or embarkation (`Q-MOVE-5`, decided 15 October 2026 [S3]).- Combat follows the GDD: a deterministic table on the strength ratio, plus one RNG draw per engagement (`Q-COMBAT-1`, decided 15 October 2026 [S3]). A unit attacks an adjacent enemy unit. A player's attack is one unit alone, fought the moment it is ordered; the enemy's attacks from several directions on one hex add their strengths; the defender's biome and fortify state modify the ratio (`Q-COMBAT-2`, decided 15 October 2026 [S3]; owner, 23 October 2026, #1402 and #1398: "Instant, like Civ", "One unit per attack, Civ" and "Approve, start building"). Outcomes take losses from the table by population units; a losing defender retreats one hex; at strength zero a unit is removed; a defender with no retreat hex surrenders; the attacker does not advance into the empty hex in the MVP (`Q-COMBAT-3`, decided 15 October 2026 [S3]). Combat acts on combatant units only: enemy units on a hex with a locality's residents may be attacked, with no effect on the residents, and artillery is not excluded (`Q-CIV-2`, the owner's pick, 15 October 2026 [S4]; R-COMBAT-005; CONTENT_POLICY §4).-- Recruits arrive only through `Train` at a military camp (`docs/gdd/training.md` [S11]). Artillery and the armoured car become `Train` tracks at a military camp: a crew of civilians, plus an Arms and Money cost as design values; event grants are left to Phase seven (`Q-ARTY-3`, decided 15 October 2026 [S3]; `D-H2`). Training a recruit costs Arms (a design value); an attack spends Arms per attacking unit, and a shortfall refuses with a reason (`D-G6`; `Q-UNIT-3` and `Q-COMBAT-4`, decided 15 October 2026 [S3]). There is no Arms upkeep; a unit costs Money upkeep each month (a design value) (`Q-UNIT-3`).+- Recruits arrive only through `Train` at a military camp (`docs/gdd/training.md` [S11]). Artillery and the armoured car become `Train` tracks at a military camp: a crew of civilians, plus an Arms and Money cost as design values; event grants are left to Phase seven (`Q-ARTY-3`, decided 15 October 2026 [S3]; `D-H2`). Training a recruit costs Arms (a design value); an attack spends Arms per attacking unit, and a shortfall refuses with a reason (`D-G6`; `Q-UNIT-3` and `Q-COMBAT-4`, decided 15 October 2026 [S3]). There is no Arms upkeep; a unit costs Money upkeep each month (a design value) (`Q-UNIT-3`). A damaged formation standing in a friendly city can be refilled with trained replacements from that city's civilians, each group paying its course's Money and Arms, up to the strength the formation started with; a veteran stays a veteran, and the replacements are cancelled if the unit is lost or leaves the city [S17] (`R-TRAIN-004`).- The player's artillery fires alone at an enemy unit within its range; it never holds ground, and firing it spends Arms (`Q-ARTY-1`, decided 15 October 2026 [S3]; owner, 23 October 2026, #1402 and #1398: "One unit per attack, Civ" and "Approve, start building"). The armoured car carries more movement points and its own combat factor (`Q-ARTY-2`, decided 15 October 2026 [S3]). Artillery's on-screen name is Artillery (ארטילריה) until a sourced gun type arrives (`Q-ARTY-4`, decided 15 October 2026 [S3]); which vehicles and guns are modelled stays open (`Q-ART-2`).- Enemy forces act in the first resolver step after the player's orders (impact spec §2.3 [S8]; owner, 23 October 2026, #1402 and #1398: "Approve, start building"). In Historical mode they follow a script from two-source positions at 15 May and 11 June 1948 [S9], then act on simple goals; in Open mode goals only (`Q-ENEMY-1`, decided 15 October 2026 [S3]). A goal is: hold a fortified position, or attack an adjacent enemy unit when the strength ratio meets a threshold; no RNG (`Q-ENEMY-2`, decided 15 October 2026 [S3]). Enemy armies receive no reinforcements until a dated per-army figure is sourced (`Q-ENEMY-3`, decided 15 October 2026 [S3]). Enemy units need no supply (`Q-ENEMY-4`, decided 15 October 2026 [S3]). The four operation cards, `ten_days`, `operation_yoav`, `operation_hiram`, `operation_horev`, give orders to units already on the board, and that resets their sensitivity review; which units, whose, and which orders: value: open (owner) (`Q-ENEMY-5`, the owner's pick, 15 October 2026 [S4]).- The war state is what war events set; in the GDD game loop the security order and call-up are refused with their reason (`Q-WAR-1`, decided 15 October 2026 [S3]; `D-C4`). The clock that forced war after fifty-two weeks from March 1948 is retired (`Q-WAR-2`, decided 15 October 2026 [S3]). During a truce attacks are refused with "a truce is in force"; movement is allowed. The refusal lasts from the first_truce acceptance until the turn covering 8 July 1948, and from the second_truce acceptance until the turn covering 15 October 1948 — the dates the fighting resumed in the MFA chronology [S10] (`Q-WAR-3`, decided 15 October 2026 [S3]). The `set_rung` command keeps acting outside the GDD loop (`Q-WAR-4`, decided 15 October 2026 [S3]). A war loss is enemy units holding a player's GDD city hex at the end of a turn (`Q-WAR-5`, decided 15 October 2026 [S3]); Phase 7 turns it into the defeat ending.@@ -64,6 +64,7 @@ On 15 May 1948, with the Provisional government declared, the player takes comma- [S14] Internal map-authoring requirements and terrain-decision boundary, docs/gdd/map-editor.md- [S15] [Owner decision on the Umm Rashrash bonus](https://github.com/eyalgolan/statecraft-israel/issues/1007#issuecomment-6254333758), 18 October 2026, checked 2026-10-18.- [S16] [Owner decision on the terrain catalogue](https://github.com/eyalgolan/statecraft-israel/issues/1512#issuecomment-6372356819), 23 October 2026, checked 2026-10-23.+- [S17] Owner decisions on replacements, 23 October 2026, checked 2026-10-23: ["Replacements cost Arms"](https://github.com/eyalgolan/statecraft-israel/issues/1510#issuecomment-6372356139) and "Default (Recommended)" on which units, veterans and a lost target (#1510).## Open questionsdiff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 53388cdbe..6395d0f78 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -124,11 +124,13 @@ R-PROJ-005: A specialised project is allowed only in a city that has its resourcTraining is step 4 of the turn in the approved order (§2.3, D-A6): it runs before production. One military camp and one Hakhshara exist in Tel Aviv at the start, a labelled design assumption (D-D5); pioneers build more at camp sites (R-CAMP-001).-R-TRAIN-001: `Train(city, track, n)` takes `n` of the city's civilians without a job into a cohort that trains as `track` (a unit type with a `facility`: `recruit`, `artillery` and `armoured_car` in a military camp (R-UNIT-008), `halutz` in a Hakhshara, `craftsman` at industry, R-CRAFT-001) for the type's `training_turns`, counting the turn it was ordered in. The Treasury pays `n * training_cost` at once. When the Treasury holds less, the shortfall is borrowed, as for map actions: it is added to the debt and the Treasury stops at 0 (owner decision "Allow borrowing", 15 October 2026). The trainees leave the civilians at once; the cohort takes the next id, which units share. It is refused, with the state unchanged and the Attention refunded, when the city or track is unknown, `n` is below 1, the city lacks the facility, or it has fewer civilians without a job. A city has a facility when `cities.yaml` gives it one at the start or a camp site of that kind built for it is in the state (R-CAMP-001). The legacy loop refuses it before charging Attention.+R-TRAIN-001: `Train(city, track, n)` takes `n` of the city's civilians without a job into a cohort that trains as `track` (a unit type with a `facility`: `recruit`, `artillery` and `armoured_car` in a military camp (R-UNIT-008), `halutz` in a Hakhshara, `craftsman` at industry, R-CRAFT-001) for the type's `training_turns`, counting the turn it was ordered in. The Treasury pays `n * training_cost` at once. When the Treasury holds less, the shortfall is borrowed, as for map actions: it is added to the debt and the Treasury stops at 0 (owner decision "Allow borrowing", 15 October 2026). The trainees leave the civilians at once; the cohort takes the next id, which units share. It is refused, with the state unchanged and the Attention refunded, when the city or track is unknown, `n` is below 1, the city lacks the facility, or it has fewer civilians without a job. A city has a facility when `cities.yaml` gives it one at the start or a camp site of that kind built for it is in the state (R-CAMP-001). The legacy loop refuses it before charging Attention. `Reinforce` (R-TRAIN-004) starts a cohort by the same rules, aimed at a unit.-R-TRAIN-002: `CancelTraining(cohort)` returns the cohort's people to its city as civilians without a job and refunds none of the Money paid (D-A3); a recruit cohort's Arms go back to the pool (R-ARMS-003). A cohort that does not exist, or has finished, is refused with the state unchanged.+R-TRAIN-002: `CancelTraining(cohort)` returns the cohort's people to its city as civilians without a job and refunds none of the Money paid (D-A3); a recruit cohort's Arms go back to the pool (R-ARMS-003). A cohort that does not exist, or has finished, is refused with the state unchanged. Replacements (R-TRAIN-004) cancel the same way.-R-TRAIN-003: Each turn, in ascending id, every cohort has one turn less to go. A cohort that reaches 0 ends: a recruit cohort becomes one military unit with its count as strength (R-UNIT-003), and so does a gun or armoured car cohort, of its own type (R-UNIT-008), craftsmen join the city's count (R-CRAFT-001), and halutzim become one movable unit per group. Units appear at the city's settlement hex, taking the next ids in turn. New recruit completions never fill `City.Recruits`; its old canonical field is retained, and saves still replay their command log. Cohorts are written into the state hash only when there are some.+R-TRAIN-003: Each turn, in ascending id, every cohort has one turn less to go. A cohort that reaches 0 ends: a recruit cohort becomes one military unit with its count as strength (R-UNIT-003), and so does a gun or armoured car cohort, of its own type (R-UNIT-008), craftsmen join the city's count (R-CRAFT-001), and halutzim become one movable unit per group. Units appear at the city's settlement hex, taking the next ids in turn. New recruit completions never fill `City.Recruits`; its old canonical field is retained, and saves still replay their command log. Cohorts are written into the state hash only when there are some. A cohort aimed at a unit ends as R-TRAIN-004 says instead.++R-TRAIN-004: `Reinforce(unit, city, n)` (#1510; owner, 23 October 2026: "Replacements cost Arms", https://github.com/eyalgolan/statecraft-israel/issues/1510#issuecomment-6372356139, and "Default (Recommended)") refills a damaged formation of the player's with trained replacements. The unit must be a military unit of the player's side standing on `city`'s settlement hex. Its course is the trained type of the unit's side and class (a type with a `facility`): the recruit's basic training for a recruit or a veteran soldier, the guns' and the armoured cars' own for artillery and armoured cars (R-UNIT-008); a type no course trains (any enemy type) takes none. The cohort then follows R-TRAIN-001: the city's facility, `n` of its civilians without a job, `n * training_cost` with borrowing (R-MONEY-003), and the Arms of R-ARMS-003 for that course; it carries the unit's id, written into the state hash (`|unit=<id>`) only when set. The cap is the strength the unit had before its first loss, `Unit.Full`: combat stores it on a player's unit at its first loss (R-COMBAT-003) and clears it when replacements bring the unit back to it, and it is written into the state hash (`|full=<n>`) only when set, so a unit that has lost nobody, and every enemy unit, hashes as before. The order is refused, the state and Attention unchanged, for an unknown unit ("There is no such unit"), a unit with no side or an enemy unit (R-ORDER-001's wording), an unknown city, a unit off the city's hex ("Unit N is not in <city>"), a type no course trains ("Unit N cannot take replacements"), a unit with nothing to refill ("Unit N has no losses to replace") and `n` past the cap less the unit's strength and the replacements already training for it ("Unit N can take K more groups"), then for R-TRAIN-001's and R-ARMS-003's reasons. A queued `Reinforce` takes its city's civilians as a queued `Train` does (R-CITY-001). In step 4, before a turn is counted, replacements whose unit has left the state (destroyed, captured, sent home) or stands off the city's hex are cancelled as R-TRAIN-002 cancels a cohort: people and Arms back, the Money spent, with a Why line. A cohort that finishes adds its count to the unit's strength and makes no unit and takes no id; the unit keeps its type, service, order and home (a veteran stays a veteran, R-UNIT-004). The people join the unit's home city's housing (R-HOUSE-003). `attention_cost.reinforce` is 1, Train's cost, a design value (owner, 24 October 2026: "1, like Train (Recommended)", https://github.com/eyalgolan/statecraft-israel/issues/1510#issuecomment-6375591436). The save line is `reinforce <unit> <city> <n>` and the scenario form `{ kind: reinforce, unit, city, count }`.## Craftsmen@@ -178,7 +180,7 @@ R-UNIT-001: A military unit is a group at formation scale, one token per formatiR-UNIT-002: A unit's side, strength, order and order target are written into the state hash only when they are not at their default ("" or 0), after its service (R-LOOP-002's rule). Its housing home city is also written when nonempty (`|home=<city>`); an empty home adds nothing, preserving earlier units' canonical text. A halutz unit's canonical text remains unchanged when its home is empty.-R-UNIT-003: A finished recruit cohort becomes exactly one Israeli infantry formation at its city's settlement hex, with `Strength` equal to the cohort's `Count` in population units, service 0 and the next id (Q-UNIT-1, Q-UNIT-4; owner, 15 October 2026). The cohort leaves the state: nobody is lost or duplicated. Its reserved Arms are neither charged again nor refunded on completion (R-ARMS-003).+R-UNIT-003: A finished recruit cohort becomes exactly one Israeli infantry formation at its city's settlement hex, with `Strength` equal to the cohort's `Count` in population units, service 0 and the next id (Q-UNIT-1, Q-UNIT-4; owner, 15 October 2026). The cohort leaves the state: nobody is lost or duplicated. Its reserved Arms are neither charged again nor refunded on completion (R-ARMS-003). A cohort aimed at a unit adds to that unit instead of making a new one (R-TRAIN-004).R-UNIT-004: Each Israeli recruit formation already in play before step 4 gains one service turn; a cohort graduating in step 4 starts serving on the next turn. At `veteran_soldier_service` it becomes `veteran_soldier`, keeping id, hex, service, side, strength and standing order, with a Why cause. Veterans stop accumulating service. Combat gives no extra service, and Phase 5 adds no return to civilian life (Q-UNIT-2, Q-UNIT-6; owner, 15 October 2026). The owner-accepted initial threshold is 6 turns, a labelled design value under Q-GEN-1, not a historical period (19 October 2026, https://github.com/eyalgolan/statecraft-israel/pull/1130#issuecomment-6269103829). The loader requires it to be at least 1 and requires the Israeli veteran infantry type when recruits exist.@@ -246,11 +248,11 @@ R-COMBAT-001: `UnitOrder(unit, attack, q, r)` makes one of the player's militaryR-COMBAT-002: Resolver step 2 resolves the enemy's attacks in ascending attacker id: the lowest-id unit with an attack not yet in an engagement leads one, with every enemy unit attacking the same hex. A player's attack is fought when its order runs (R-COMBAT-001), as one engagement with that unit alone and one draw. Each unit's strength is first multiplied by its type's `combat_percent` (R-COMBAT-007, R-COMBAT-008). The attackers' strengths are summed; each defender's strength is multiplied by its order's defence percent (`Orders.DefencePercent`: fortify 125, R-ORDER-002) and by `mvp.combat_terrain_percent` for its hex's biome (real values: hills 125, mountains 150, every other land biome 100). The ratio is attack over defence in whole percent, rounded down, in integers only; the row of `mvp.combat_table` is the last whose `min_ratio_percent` it reaches (real rows: below 1:2, 1:2, 1:1, 2:1, 3:1). Each engagement draws exactly one RNG value, a face of the row (six in the real table), whatever its outcome; a step 2 with no engagement draws nothing (docs/determinism.md, "Combat draws"). `Combat.Preview(c, s, unit, q, r)` gives the ratio and row the UI shows (Q-UI-1; spec §2.6), counting that unit alone for a player's attack.-R-COMBAT-003: The face gives the population units each side loses and whether the defenders retreat. Losses fall one unit at a time on the side's strongest unit in the engagement (a tie on the lower id; the attackers' losses spare their artillery, R-COMBAT-007); a unit at 0 is destroyed and leaves the state, and its id is never reused (`NextId` does not move). When the face says retreat, each defender left, in id order, moves one hex to the first neighbour in the fixed order (R-MOVE-002) that is land, holds no unit of the other side, has room for its side under `mvp.stack_limit`, and, for a player's unit, is not an enemy-held locality (R-MOVE-005). A defender with no such hex surrenders and leaves the state: the only way a unit is captured (impact plan §4.3 item 1; its people are counted as prisoners or as the player's soldiers held, R-POW-001, R-POW-005). The attackers never advance into the hex (Q-COMBAT-3).+R-COMBAT-003: The face gives the population units each side loses and whether the defenders retreat. Losses fall one unit at a time on the side's strongest unit in the engagement (a tie on the lower id; the attackers' losses spare their artillery, R-COMBAT-007); a unit at 0 is destroyed and leaves the state, and its id is never reused (`NextId` does not move). When the face says retreat, each defender left, in id order, moves one hex to the first neighbour in the fixed order (R-MOVE-002) that is land, holds no unit of the other side, has room for its side under `mvp.stack_limit`, and, for a player's unit, is not an enemy-held locality (R-MOVE-005). A defender with no such hex surrenders and leaves the state: the only way a unit is captured (impact plan §4.3 item 1; its people are counted as prisoners or as the player's soldiers held, R-POW-001, R-POW-005). The attackers never advance into the hex (Q-COMBAT-3). A player's unit's first loss stores the strength it had as its `Full`; only replacements (R-TRAIN-004) restore lost strength.R-COMBAT-004: Each of the player's units pays `mvp.arms_per_attack` (real value 1; artillery pays its `arms_per_fire` instead, R-COMBAT-007) from the Arms stock when the attack is given; an attack the stock cannot pay for is refused. Enemy units pay nothing (Q-ENEMY-4: no supply).-R-COMBAT-005: Combat changes only combatant units, the Arms and, through a surrender, the counts of prisoners and of the player's soldiers held (R-POW-001, R-POW-005). No city, locality, resident, building, job or other resource, and no score, changes because of a combat outcome (Q-CIV-2; impact plan §4.3: kills and enemy losses never score). Halutzim are never attackers or targets.+R-COMBAT-005: Combat changes only combatant units, the Arms and, through a surrender, the counts of prisoners and of the player's soldiers held (R-POW-001, R-POW-005). No city, locality, resident, building, job or other resource, and no score, changes because of a combat outcome (Q-CIV-2; impact plan §4.3: kills and enemy losses never score). Halutzim are never attackers or targets. Lost strength comes back only through replacements (R-TRAIN-004), which are training, not a combat outcome.R-COMBAT-006: Each engagement's Why line names the hex, the units on each side and the ratio, and states "the attackers lost N people and the defenders lost M people", the strength each side lost times `people_per_unit`, in the same words whichever side attacks (Q-CIV-4; impact plan §4.2). A destroyed unit gets "Unit N was destroyed", a retreat the hex it went to, a surrender the people it surrendered with. No running count of losses is kept; the war's Israeli total is PR 13's.@@ -348,7 +350,7 @@ R-ARMS-001: Arms is a national stock of whole units (`GameState.Arms`, hashed asR-ARMS-002: `BuyArms(count)` adds `count` units to the stock at once, with no delivery delay, and the Treasury pays `count * arms_price` (IL 1m an Arms), borrowing what it lacks (R-MONEY-003). It is refused, state and Attention unchanged, for fewer than one unit or a stock that would pass a whole number's range; the legacy loop refuses it before charging Attention. Its Attention cost is `attention_cost.buy_arms` (1), whatever the count.-R-ARMS-003: Recruit training (R-TRAIN-001) takes `arms_per_recruit_group` (1) Arms for each group when it starts, after its other checks and before it pays. A stock short of that refuses the order with a reason naming the need and the stock, state and Attention unchanged (Q-UNIT-3). A gun or armoured car crew takes its type's `training_arms` a group instead, by the same rule (R-UNIT-008). Pioneer training takes no Arms. The cohort keeps the Arms it took, and the state hash writes them with it; cancelling the cohort (R-TRAIN-002) returns them to the pool, up to the most the stock can hold, although the Money stays paid (owner, 18 October 2026, #1047: "Refund on cancel").+R-ARMS-003: Recruit training (R-TRAIN-001) takes `arms_per_recruit_group` (1) Arms for each group when it starts, after its other checks and before it pays. A stock short of that refuses the order with a reason naming the need and the stock, state and Attention unchanged (Q-UNIT-3). A gun or armoured car crew takes its type's `training_arms` a group instead, by the same rule (R-UNIT-008). Pioneer training takes no Arms. The cohort keeps the Arms it took, and the state hash writes them with it; cancelling the cohort (R-TRAIN-002) returns them to the pool, up to the most the stock can hold, although the Money stays paid (owner, 18 October 2026, #1047: "Refund on cancel"). Replacement groups (R-TRAIN-004) take their course's Arms by the same rule (owner, 23 October 2026, #1510: "Replacements cost Arms").## Defeatdiff --git a/sim/Statecraft.Sim.Tests/CombatTests.cs b/sim/Statecraft.Sim.Tests/CombatTests.csindex 88a88e9a3..0505d4915 100644--- a/sim/Statecraft.Sim.Tests/CombatTests.cs+++ b/sim/Statecraft.Sim.Tests/CombatTests.cs@@ -447,6 +447,16 @@ public class CombatTestsAssert.Equal((1, 2, 4, 5), (s.Units[1].Strength, s.Units[3].Strength, s.Units[2].Strength, s.Units[4].Strength));}+ // R-COMBAT-003 with R-TRAIN-004: an engagement's loss stores a player's unit's strength before it, and no enemy's.+ [Fact]+ public void AnEngagementsLossStoresThePlayersStartingStrength()+ {+ var c = Load();+ var s = With(c, Attacking(Soldier(1, 3, 0, 2), 2, 0), Enemy(2, 2, 0, 5));+ Resolve(c, s); // 2 against 5: both sides lose 1+ Assert.Equal((1, 2, 4, 0), (s.Units[1].Strength, s.Units[1].Full, s.Units[2].Strength, s.Units[2].Full));+ }+// R-COMBAT-006 (Q-CIV-4, "2+3"): the engagement's Why line gives the people each side lost, in the same words for both.[Fact]public void TheWhyLineGivesPeopleLostOnBothSides()diff --git a/sim/Statecraft.Sim.Tests/CommandGuardTests.cs b/sim/Statecraft.Sim.Tests/CommandGuardTests.csindex 154622ed7..90a0443eb 100644--- a/sim/Statecraft.Sim.Tests/CommandGuardTests.cs+++ b/sim/Statecraft.Sim.Tests/CommandGuardTests.cs@@ -21,6 +21,7 @@ public class CommandGuardTests[typeof(AssignWorkers)] = new AssignWorkers("tel_aviv", "job", 1),[typeof(Train)] = new Train("tel_aviv", "halutz", 1),[typeof(CancelTraining)] = new CancelTraining(1),+ [typeof(Reinforce)] = new Reinforce(1, "tel_aviv", 1),[typeof(PioneerWork)] = new PioneerWork(1, "build_yishuv", "mefalsim"),[typeof(StopWork)] = new StopWork(1),[typeof(UnitOrder)] = new UnitOrder(1, "fortify"),diff --git a/sim/Statecraft.Sim.Tests/DeportTests.cs b/sim/Statecraft.Sim.Tests/DeportTests.csindex bc2f89b9a..e94303de9 100644--- a/sim/Statecraft.Sim.Tests/DeportTests.cs+++ b/sim/Statecraft.Sim.Tests/DeportTests.cs@@ -187,7 +187,7 @@ public class DeportTests// These name no place or hex: a city, a cohort, a unit's own work, a policy, a budget, an event, an office or a count.[typeof(SetPolicy)] = null, [typeof(AllocateBudget)] = null, [typeof(ChooseEventOption)] = null, [typeof(SetMobilization)] = null,[typeof(SecurityOrder)] = null, [typeof(Appoint)] = null, [typeof(AssignWorkers)] = null, [typeof(Train)] = null,- [typeof(CancelTraining)] = null, [typeof(StopWork)] = null, [typeof(CancelProject)] = null, [typeof(BuyArms)] = null,+ [typeof(CancelTraining)] = null, [typeof(Reinforce)] = null, [typeof(StopWork)] = null, [typeof(CancelProject)] = null, [typeof(BuyArms)] = null,};var kinds = typeof(Command).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Command)) && !t.IsAbstract).OrderBy(t => t.Name, StringComparer.Ordinal);Assert.Equal(kinds.Select(t => t.Name), aimed.Keys.OrderBy(t => t.Name, StringComparer.Ordinal).Select(t => t.Name));diff --git a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs b/sim/Statecraft.Sim.Tests/DesignValuesTests.csindex 49a0c0518..b0bd3124e 100644--- a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs+++ b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs@@ -19,6 +19,7 @@ public class DesignValuesTests{("rules.yaml", "attention_cost.assign_workers"),("rules.yaml", "attention_cost.train"),+ ("rules.yaml", "attention_cost.reinforce"),("rules.yaml", "attention_cost.cancel_training"),("rules.yaml", "attention_cost.pioneer_work"),("rules.yaml", "attention_cost.stop_work"),diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.csindex 46fa1f07a..ce9f9b88d 100644--- a/sim/Statecraft.Sim.Tests/Fixture.cs+++ b/sim/Statecraft.Sim.Tests/Fixture.cs@@ -243,7 +243,7 @@ series:}/// <summary>The fixture's attention_cost line with the GDD command kinds added (replaces "map_action: 1 }").</summary>- public const string GddCosts = "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1, pioneer_work: 0, stop_work: 0, start_project: 1, cancel_project: 0.5, buy_arms: 1, move: 0, unit_order: 0, resolve_capture: 0 }";+ public const string GddCosts = "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1, reinforce: 1, pioneer_work: 0, stop_work: 0, start_project: 1, cancel_project: 0.5, buy_arms: 1, move: 0, unit_order: 0, resolve_capture: 0 }";public const string GddRules = @"mvp:diff --git a/sim/Statecraft.Sim.Tests/ReplacementTests.cs b/sim/Statecraft.Sim.Tests/ReplacementTests.csnew file mode 100644index 000000000..5fca19633--- /dev/null+++ b/sim/Statecraft.Sim.Tests/ReplacementTests.cs@@ -0,0 +1,257 @@+using System.Collections.Generic;+using System.Linq;+using Statecraft.Sim;++/// <summary>#1510: military replacements (R-TRAIN-004). A damaged Israeli formation on a city's settlement hex takes trained+/// replacement groups from that city's civilians without work; each group pays its course's Money and Arms (owner, 23 October+/// 2026: "Replacements cost Arms"), and the finished cohort adds to the unit's strength up to the strength it started with.+/// Which formations, veterans and a lost target follow the owner's "Default (Recommended)" ruling of the same day.</summary>+public class ReplacementTests+{+ static readonly Content Mvp = ContentLoader.Load(RealContentTests.ContentRoot());++ /// <summary>Tel Aviv has the start's military camp (cities.yaml, D-D5).</summary>+ const string City = "tel_aviv";++ static SettlementHex Hex(string city) => Mvp.SettlementHexes.Single(h => h.Id == city);++ /// <summary>A new game with a player formation of <paramref name="type"/> on Tel Aviv's hex, at+ /// <paramref name="strength"/> of the <paramref name="full"/> it started with (0: never damaged), and Arms to spare.</summary>+ static (GameState s, int id) Game(string type = "recruit", int strength = 2, int full = 5, int service = 0)+ {+ var s = Simulation.NewGame(Mvp, GoldenRun.Seed, Mode.Historical);+ var h = Hex(City);+ var id = s.NextId++;+ s.Units.Add(id, new Unit(id, type, h.Q, h.R, service, side: "israel", strength: strength, homeCity: City, full: full));+ s.Arms = 100;+ return (s, id);+ }++ static string? Reinforce(GameState s, int unit, int n, string city = City) => Training.Reinforce(Mvp, s, unit, city, n, new List<Cause>());++ static void Turns(GameState s, int n) { for (int i = 0; i < n; i++) Training.Progress(Mvp, s, new List<Cause>()); }++ static int Turns(string track) => Mvp.UnitTypes.Single(t => t.Id == track).TrainingTurns;++ // R-TRAIN-004: the finished cohort adds its count to the unit, makes no new unit, and the unit is at full strength again.+ [Fact]+ public void ARefillAddsStrengthToTheUnit()+ {+ var (s, id) = Game();+ var civilians = s.Cities[City].Civilians;+ Assert.Null(Reinforce(s, id, 3));+ Assert.Equal(civilians - 3, s.Cities[City].Civilians);+ var cohort = Assert.Single(s.Cohorts.Values);+ Assert.Equal((id, "recruit", 3), (cohort.Unit, cohort.Type, cohort.Count));+ var next = s.NextId;+ var units = s.Units.Count;++ Turns(s, Turns("recruit"));++ Assert.Empty(s.Cohorts);+ Assert.Equal(units, s.Units.Count);+ Assert.Equal(next, s.NextId);+ Assert.Equal((5, 0), (s.Units[id].Strength, s.Units[id].Full));+ }++ // R-TRAIN-004 with R-ARMS-003: a recruit group takes arms_per_recruit_group, and a short stock refuses it, state unchanged.+ [Fact]+ public void ARefillTakesArmsAndAShortStockRefusesIt()+ {+ var (s, id) = Game();+ var per = Mvp.RulesAt(s.Date).Mvp!.ArmsPerRecruitGroup!.Value;+ Assert.Null(Reinforce(s, id, 2));+ Assert.Equal(100 - 2 * per, s.Arms);+ Assert.Equal(2 * per, Assert.Single(s.Cohorts.Values).Arms);++ var (t, tid) = Game();+ t.Arms = 2 * per - 1;+ var before = t.Hash();+ Assert.Contains("not enough Arms", Reinforce(t, tid, 2));+ Assert.Equal(before, t.Hash());+ }++ // R-TRAIN-004: a partial refill keeps the unit's Full; in one turn a cancelled cohort and a finishing one both resolve.+ [Fact]+ public void APartialRefillKeepsFullBesideACancelledCohort()+ {+ var (s, id) = Game(strength: 2, full: 5);+ Assert.Null(Reinforce(s, id, 1));+ var h = Hex(City);+ var other = s.NextId++;+ s.Units.Add(other, new Unit(other, "recruit", h.Q, h.R, side: "israel", strength: 1, homeCity: City, full: 3));+ Assert.Null(Reinforce(s, other, 2));+ Turns(s, Turns("recruit") - 1);+ s.Units.Remove(other);+ var why = new List<Cause>();+ Training.Progress(Mvp, s, why);+ Assert.Empty(s.Cohorts);+ Assert.Equal((3, 5), (s.Units[id].Strength, s.Units[id].Full));+ Assert.Equal(100, s.Arms + Mvp.RulesAt(s.Date).Mvp!.ArmsPerRecruitGroup!.Value); // the cancelled cohort's Arms came back+ Assert.Contains(why, x => x.Message.Contains($"joined unit {id}"));+ }++ // R-TRAIN-004 (owner, 23 October 2026, "Default"): a gun crew pays its own type's course and training_arms (R-UNIT-008).+ [Fact]+ public void ArtilleryReplacementsPayTheGunsCourse()+ {+ var (s, id) = Game("artillery");+ var guns = Mvp.UnitTypes.Single(t => t.Id == "artillery");+ Assert.Null(Reinforce(s, id, 1));+ var k = Assert.Single(s.Cohorts.Values);+ Assert.Equal(("artillery", guns.TrainingArms!.Value, guns.TrainingTurns), (k.Type, k.Arms, k.TurnsLeft));+ Assert.Equal(100 - guns.TrainingArms!.Value, s.Arms);+ }++ // R-TRAIN-004 (owner, 23 October 2026, "Default"): a veteran trains replacements on basic training and stays a veteran+ // with its service (R-UNIT-004).+ [Fact]+ public void AVeteranKeepsItsTypeAndServiceWhenRefilled()+ {+ var (s, id) = Game("veteran_soldier", strength: 3, full: 4, service: 6);+ Assert.Null(Reinforce(s, id, 1));+ Assert.Equal("recruit", Assert.Single(s.Cohorts.Values).Type);+ Turns(s, Turns("recruit"));+ var u = s.Units[id];+ Assert.Equal(("veteran_soldier", 6, 4), (u.Type, u.Service, u.Strength));+ }++ // R-TRAIN-004: the cap is the starting strength, counting the replacements already in training.+ [Fact]+ public void TheOrderIsRefusedPastTheStartingStrength()+ {+ var (s, id) = Game(strength: 2, full: 5);+ Assert.Equal($"Unit {id} can take 3 more groups", Reinforce(s, id, 4));+ Assert.Null(Reinforce(s, id, 2));+ Assert.Equal($"Unit {id} can take 1 more group", Reinforce(s, id, 2));+ Assert.Null(Reinforce(s, id, 1));+ Assert.Equal($"Unit {id} has no losses to replace", Reinforce(s, id, 1));++ var (t, tid) = Game(strength: 4, full: 0); // never damaged+ Assert.Equal($"Unit {tid} has no losses to replace", Reinforce(t, tid, 1));+ }++ // R-TRAIN-004: only the player's trained military types, on the city's own hex, take replacements.+ [Fact]+ public void TheOrderIsRefusedForTheWrongUnitOrPlace()+ {+ var (s, id) = Game();+ var h = Hex(City);+ var halutz = s.NextId++;+ s.Units.Add(halutz, new Unit(halutz, "halutz", h.Q, h.R));+ var enemy = s.NextId++;+ s.Units.Add(enemy, new Unit(enemy, "egyptian_army", h.Q, h.R, side: "egypt", strength: 1, full: 3));+ var before = s.Hash();+ Assert.Equal("There is no such unit", Reinforce(s, 999, 1));+ Assert.Equal("Only a military unit takes that order", Reinforce(s, halutz, 1));+ Assert.Equal("That unit is not yours", Reinforce(s, enemy, 1));+ Assert.Equal("There is no such city", Reinforce(s, id, 1, "nowhere"));+ Assert.Equal($"Unit {id} is not in Haifa", Reinforce(s, id, 1, "haifa"));+ Assert.Equal(before, s.Hash());+ }++ // R-TRAIN-002 with R-TRAIN-004: cancelling the replacements returns the people and the Arms, the Money stays spent.+ [Fact]+ public void CancellingReplacementsRefundsPeopleAndArms()+ {+ var (s, id) = Game();+ var civilians = s.Cities[City].Civilians;+ Assert.Null(Reinforce(s, id, 2));+ var treasury = s.Treasury;+ Assert.Null(Training.Cancel(Mvp, s, s.Cohorts.Keys.Single(), new List<Cause>()));+ Assert.Equal((civilians, 100, treasury), (s.Cities[City].Civilians, s.Arms, s.Treasury));+ Assert.Equal(2, s.Units[id].Strength);+ }++ // R-TRAIN-004 (owner, 23 October 2026, "Default"): a target destroyed, captured or sent home cancels the cohort as+ // R-TRAIN-002 does.+ [Fact]+ public void ALostTargetCancelsTheCohort()+ {+ var (s, id) = Game();+ var civilians = s.Cities[City].Civilians;+ Assert.Null(Reinforce(s, id, 2));+ var treasury = s.Treasury;+ s.Units.Remove(id);+ var why = new List<Cause>();+ Training.Progress(Mvp, s, why);+ Assert.Empty(s.Cohorts);+ Assert.Equal((civilians, 100, treasury), (s.Cities[City].Civilians, s.Arms, s.Treasury));+ Assert.Contains(why, x => x.Message.Contains($"unit {id} is no longer in Tel Aviv"));+ }++ // R-TRAIN-004: a target that left the city's hex before the course ends cancels it too.+ [Fact]+ public void ATargetThatLeavesTheCityCancelsTheCohort()+ {+ var (s, id) = Game();+ Assert.Null(Reinforce(s, id, 2));+ Turns(s, 1);+ var u = s.Units[id];+ s.Units[id] = new Unit(u.Id, u.Type, u.Q + 1, u.R, u.Service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);+ Turns(s, 1);+ Assert.Empty(s.Cohorts);+ Assert.Equal(100, s.Arms);+ Assert.Equal(2, s.Units[id].Strength);+ }++ // R-COMBAT-003 with R-TRAIN-004: the first loss stores the strength the unit had; a destroyed unit leaves with it.+ [Fact]+ public void TheFirstLossStoresTheStartingStrength()+ {+ var u = new Unit(1, "recruit", 0, 0, side: "israel", strength: 4);+ Assert.Equal(0, u.Full);+ Assert.DoesNotContain("|full=", u.Canonical());+ var hit = Combat.Lose(u);+ Assert.Equal((3, 4), (hit.Strength, hit.Full));+ Assert.EndsWith("|full=4", hit.Canonical());+ Assert.Equal((2, 4), (Combat.Lose(hit).Strength, Combat.Lose(hit).Full));+ Assert.Equal(0, Combat.Lose(new Unit(2, "egyptian_army", 0, 0, side: "egypt", strength: 4)).Full); // no rule reads an enemy's+ }++ // R-TRAIN-004, R-LOOP-002: the cohort's target is hashed only when set, so other cohorts hash as before.+ [Fact]+ public void TheCohortsTargetIsHashedOnlyWhenSet()+ {+ Assert.Equal("3:recruit@tel_avivx2/3|arms=2", new Cohort(3, "recruit", "tel_aviv", 2, 3, 2).Canonical());+ Assert.Equal("3:recruit@tel_avivx2/3|arms=2|unit=0", new Cohort(3, "recruit", "tel_aviv", 2, 3, 2, 0).Canonical());+ Assert.Equal(0, new Cohort(3, "recruit", "tel_aviv", 2, 3, 2, 0).WithTurnsLeft(1).Unit);+ }++ // R-TRAIN-004: the order saves, replays and plays from a scenario.+ [Fact]+ public void TheOrderSavesAndReplays()+ {+ var g = GameSession.New(Mvp, GoldenRun.Seed, Mode.Historical);+ // The save keeps the command log, a refused order included (unit 0 is a starting brigade away from Tel Aviv), and the+ // replay must reach the same hash; StepRunsTheOrder covers an accepted one.+ g.Step(new Command[] { new Reinforce(0, City, 1) });+ var text = g.Save.Write();+ Assert.Contains($"\nreinforce 0 {City} 1\n", text);+ Assert.Equal(g.State.Hash(), GameSession.Load(Mvp, text, out _).State.Hash());+ Assert.Equal("reinforce", new Reinforce(0, City, 1).Kind);+ var built = Scenario.Build(new Dictionary<string, object> { ["kind"] = "reinforce", ["unit"] = "3", ["city"] = City, ["count"] = "2" });+ var r = Assert.IsType<Reinforce>(built);+ Assert.Equal((3, City, 2), (r.Unit, r.City, r.Count));+ }++ // R-TRAIN-004: Step takes the order and charges its Attention (rules.yaml attention_cost.reinforce).+ [Fact]+ public void StepRunsTheOrder()+ {+ var (s, id) = Game();+ var r = Simulation.Step(Mvp, s, new Command[] { new Reinforce(id, City, 1) });+ Assert.Empty(r.Rejected);+ Assert.Equal(2, r.State.Units[id].Strength); // training_turns 3 counts the turn of the order: two turns to go+ var k = Assert.Single(r.State.Cohorts.Values);+ Assert.Equal((id, 2), (k.Unit, k.TurnsLeft));+ Assert.Contains(r.Why, x => x.Message == "Tel Aviv: 1 group began basic training as replacements for unit " + id + ", cost IL 0.5m");+ }++ // R-TRAIN-004 with R-CITY-001: a queued Reinforce takes its city's civilians as a queued Train does.+ [Fact]+ public void AQueuedReinforceCountsAgainstTheCitysFreeCivilians()+ {+ Assert.Equal(5, Training.Ordered(City, new Command[] { new Train(City, "recruit", 2), new Reinforce(0, City, 3), new Reinforce(0, "haifa", 4) }));+ }+}diff --git a/sim/Statecraft.Sim.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.csindex 5454fb36a..f28885ea8 100644--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs@@ -28,7 +28,7 @@ public class SaveGameTestsnew Command[] { new Appoint("finance_minister", "pm_one"), new MapAction("housing", 2, 0) },new Command[] { new SetPolicy("odd id with spaces%", 0.5), new MapAction("transit_camp", 4, 0) },new Command[] { new AssignWorkers("town_a", "job", 1), new UnitOrder(1, "hold") }, // GDD orders: the legacy fixture refuses them- new Command[] { new Train("town_a", "halutz", 1), new CancelTraining(1) }, // GDD orders too+ new Command[] { new Train("town_a", "halutz", 1), new CancelTraining(1), new Reinforce(1, "town_a", 1) }, // GDD orders toonew Command[] { new PioneerWork(1, "build_yishuv", "site_a"), new StopWork(1), new StartProject("housing", "town_a", 1, 1), new CancelProject(1), new BuyArms(2), new Move(1, -2, 3), new ResolveCapture("town_a", "raid") },new Command[] { new SecurityOrder(1) }, new Command[0],};diff --git a/sim/Statecraft.Sim/AttentionSystem.cs b/sim/Statecraft.Sim/AttentionSystem.csindex a84ef6f65..21193690d 100644--- a/sim/Statecraft.Sim/AttentionSystem.cs+++ b/sim/Statecraft.Sim/AttentionSystem.cs@@ -8,11 +8,11 @@ namespace Statecraft.Simpublic static class AttentionSystem{static readonly HashSet<string> Kinds = new HashSet<string>- { "set_policy", "allocate_budget", "choose_event_option", "set_mobilization", "security_order", "appoint", "map_action", "assign_workers", "train", "cancel_training", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "move", "unit_order", "resolve_capture" };+ { "set_policy", "allocate_budget", "choose_event_option", "set_mobilization", "security_order", "appoint", "map_action", "assign_workers", "train", "cancel_training", "reinforce", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "move", "unit_order", "resolve_capture" };/// <summary>The kinds only the GDD v0.1 loop runs. Rules price them only when systems.loop is gdd, and the legacy loop/// refuses them before charging Attention.</summary>- static readonly HashSet<string> GddKinds = new HashSet<string> { "assign_workers", "train", "cancel_training", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "move", "unit_order", "resolve_capture" };+ static readonly HashSet<string> GddKinds = new HashSet<string> { "assign_workers", "train", "cancel_training", "reinforce", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "move", "unit_order", "resolve_capture" };public static IReadOnlyCollection<string> CommandKinds => Kinds;diff --git a/sim/Statecraft.Sim/Combat.cs b/sim/Statecraft.Sim/Combat.csindex c33c2e673..41a544862 100644--- a/sim/Statecraft.Sim/Combat.cs+++ b/sim/Statecraft.Sim/Combat.cs@@ -111,7 +111,7 @@ namespace Statecraft.Simvar refused = Check(c, s, unitId, q, r, enemy);if (refused != null) return refused;var u = s.Units[unitId]; var target = Hex(q!.Value, r!.Value);- s.Units[unitId] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, Attack, target, u.HomeCity);+ s.Units[unitId] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, Attack, target, u.HomeCity, u.Full);why.Add(UnitLines.Line(WhyKeys.AttackOrdered, $"Unit {unitId} will attack hex {target}", new[] { u }, target));return null;}@@ -127,7 +127,7 @@ namespace Statecraft.Simvar mvp = c.RulesAt(s.Date).Mvp!;var u = s.Units[unitId];s.Arms -= Need(c, mvp, u);- var attacker = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "", u.HomeCity);+ var attacker = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "", u.HomeCity, u.Full);s.Units[unitId] = attacker;if (u.Order == Orders.Fortify)why.Add(UnitLines.Line(WhyKeys.FortifyLost,@@ -248,7 +248,7 @@ namespace Statecraft.Simstatic void End(GameState s, Unit u, string key, string line, List<Cause> why, params string[] args){- s.Units[u.Id] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "", u.HomeCity);+ s.Units[u.Id] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "", u.HomeCity, u.Full);why.Add(UnitLines.Line(key, line, new[] { u }, args));}@@ -286,7 +286,7 @@ namespace Statecraft.Simif (!s.Units.TryGetValue(d.Id, out var u)) continue;if (Retreat(c, s, mvp, u) is (int, int) to){- s.Units[u.Id] = new Unit(u.Id, u.Type, to.Item1, to.Item2, u.Service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity);+ s.Units[u.Id] = new Unit(u.Id, u.Type, to.Item1, to.Item2, u.Service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);var hex = Hex(to.Item1, to.Item2);why.Add(UnitLines.Line(WhyKeys.Retreated, $"Unit {u.Id} retreated to hex {hex}", new[] { u }, hex));}@@ -320,11 +320,17 @@ namespace Statecraft.Simif (s.Units.TryGetValue(id, out var x) && (top == null || x.Strength > top.Strength)) top = x;if (top == null) break;if (top.Strength <= 1) { s.Units.Remove(top.Id); removed.Add(top); }- else s.Units[top.Id] = new Unit(top.Id, top.Type, top.Q, top.R, top.Service, top.Side, top.Strength - 1, top.Order, top.OrderTarget, top.HomeCity);+ else s.Units[top.Id] = Lose(top);}return taken;}+ /// <summary>R-COMBAT-003 with R-TRAIN-004: the unit one population unit weaker. A player's unit's first loss stores the+ /// strength it had as its Full, the most replacements refill it to; no rule reads an enemy's, so it stores none.</summary>+ internal static Unit Lose(Unit u) =>+ new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength - 1, u.Order, u.OrderTarget, u.HomeCity,+ u.Full == 0 && u.Side == Movement.PlayerSide ? u.Strength : u.Full);+/// <summary>R-COMBAT-003: the first neighbour of the unit's hex, in the fixed order (R-MOVE-002), that is land, holds no/// unit of the other team, has room under mvp.stack_limit for the unit's side (R-MOVE-003) and, for the player's unit,/// is not an enemy-held locality (R-MOVE-005); null when there is none.</summary>diff --git a/sim/Statecraft.Sim/Commands.cs b/sim/Statecraft.Sim/Commands.csindex 7769ec781..432c40826 100644--- a/sim/Statecraft.Sim/Commands.cs+++ b/sim/Statecraft.Sim/Commands.cs@@ -85,6 +85,16 @@ namespace Statecraft.Simpublic CancelTraining(int cohort) { Cohort = cohort; }}+ /// <summary>Starts <see cref="Count"/> groups of <see cref="City"/>'s civilians without work training as replacements for+ /// damaged formation <see cref="Unit"/>, which stands on the city's settlement hex (Training.Reinforce, R-TRAIN-004; #1510).+ /// GDD v0.1 loop only.</summary>+ public sealed class Reinforce : Command+ {+ public override string Kind => Training.ReinforceKind;+ public int Unit { get; } public string City { get; } public int Count { get; }+ public Reinforce(int unit, string city, int count) { Unit = unit; City = city; Count = count; }+ }+/// <summary>Sends halutz unit <see cref="Unit"/> to do pioneer work <see cref="Action"/> (build_yishuv) at designated site/// <see cref="Site"/> (Projects.Start, R-SITE-001). GDD v0.1 loop only.</summary>public sealed class PioneerWork : Command@@ -205,6 +215,7 @@ namespace Statecraft.Simcase AssignWorkers w: Text(w.City, "City"); Text(w.Role, "Role"); break;case Train t: Text(t.City, "City"); Text(t.Track, "Track"); break;case CancelTraining _: break;+ case Reinforce r: Text(r.City, "City"); break;case PioneerWork p: Text(p.Action, "Action"); Text(p.Site, "Site"); break;case StopWork _: break;case UnitOrder o: Text(o.Order, "Order"); break;diff --git a/sim/Statecraft.Sim/Corridors.cs b/sim/Statecraft.Sim/Corridors.csindex c5f049dd0..dab4fc97c 100644--- a/sim/Statecraft.Sim/Corridors.cs+++ b/sim/Statecraft.Sim/Corridors.cs@@ -114,7 +114,7 @@ namespace Statecraft.Simif (u.Type != "halutz") continue;var service = u.Service + 1;var promoted = service >= r.VeteranHalutzService!.Value;- s.Units[u.Id] = new Unit(u.Id, promoted ? Projects.VeteranType : u.Type, u.Q, u.R, service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity);+ s.Units[u.Id] = new Unit(u.Id, promoted ? Projects.VeteranType : u.Type, u.Q, u.R, service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);if (promoted) why.Add(new Cause("map", w.Id, 1, "A group of halutzim became veteran pioneers"));}s.Corridors[w.Id] = cur;diff --git a/sim/Statecraft.Sim/EnemyAI.cs b/sim/Statecraft.Sim/EnemyAI.csindex fee8d3fe8..757c7a15d 100644--- a/sim/Statecraft.Sim/EnemyAI.cs+++ b/sim/Statecraft.Sim/EnemyAI.cs@@ -55,7 +55,7 @@ namespace Statecraft.Sim// fortify (Movement.Move), and step 2 would resolve it inside the truce (owner, #1263).if (truce && u.Order == Combat.Attack){- s.Units[id] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "", u.HomeCity);+ s.Units[id] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "", u.HomeCity, u.Full);why.Add(UnitLines.Line(WhyKeys.AttackEndedTruce,$"Unit {id}'s attack on hex {u.OrderTarget} ends: a truce is on", new[] { u }, u.OrderTarget));}diff --git a/sim/Statecraft.Sim/GddState.cs b/sim/Statecraft.Sim/GddState.csindex 0467ef9f7..b44158716 100644--- a/sim/Statecraft.Sim/GddState.cs+++ b/sim/Statecraft.Sim/GddState.cs@@ -129,10 +129,13 @@ namespace Statecraft.Sim/// <summary>The city whose housing includes this formation (R-HOUSE-003, Q-HOUSE-5), independent of its current hex./// Empty for units without a known home, including pioneers.</summary>public string HomeCity { get; }+ /// <summary>The strength the formation had before its first loss, the most replacements refill it to (R-TRAIN-004), or+ /// 0 while it has lost none: combat sets it (R-COMBAT-003) and a refill to full clears it.</summary>+ public int Full { get; }- public Unit(int id, string type, int q, int r, int service = 0, string side = "", int strength = 0, string order = "", string orderTarget = "", string homeCity = "")+ public Unit(int id, string type, int q, int r, int service = 0, string side = "", int strength = 0, string order = "", string orderTarget = "", string homeCity = "", int full = 0){- Id = id; Type = type; Q = q; R = r; Service = service; Side = side; Strength = strength; Order = order; OrderTarget = orderTarget; HomeCity = homeCity;+ Id = id; Type = type; Q = q; R = r; Service = service; Side = side; Strength = strength; Order = order; OrderTarget = orderTarget; HomeCity = homeCity; Full = full;}/// <summary>The record as the state hash writes it. Each field after the hex is written only when it is not at its@@ -144,7 +147,8 @@ namespace Statecraft.Sim+ (Strength == 0 ? "" : "|strength=" + Strength.ToString(CultureInfo.InvariantCulture))+ (Order == "" ? "" : "|order=" + Order)+ (OrderTarget == "" ? "" : "|target=" + OrderTarget)- + (HomeCity == "" ? "" : "|home=" + HomeCity);+ + (HomeCity == "" ? "" : "|home=" + HomeCity)+ + (Full == 0 ? "" : "|full=" + Full.ToString(CultureInfo.InvariantCulture));}/// <summary>A group of a city's people in training (GDD "Progression"; R-TRAIN-001): <see cref="Count"/> population units@@ -159,16 +163,20 @@ namespace Statecraft.Simpublic int Count { get; }public int TurnsLeft { get; }public int Arms { get; }+ /// <summary>The formation these replacements join when they finish (R-TRAIN-004), or null for a cohort that becomes+ /// something new (R-TRAIN-003).</summary>+ public int? Unit { get; }- public Cohort(int id, string type, string city, int count, int turnsLeft, int arms = 0) { Id = id; Type = type; City = city; Count = count; TurnsLeft = turnsLeft; Arms = arms; }+ public Cohort(int id, string type, string city, int count, int turnsLeft, int arms = 0, int? unit = null) { Id = id; Type = type; City = city; Count = count; TurnsLeft = turnsLeft; Arms = arms; Unit = unit; }/// <summary>The same cohort with <paramref name="turnsLeft"/> turns to go.</summary>- public Cohort WithTurnsLeft(int turnsLeft) => new Cohort(Id, Type, City, Count, turnsLeft, Arms);+ public Cohort WithTurnsLeft(int turnsLeft) => new Cohort(Id, Type, City, Count, turnsLeft, Arms, Unit);- /// <summary>The record as the state hash writes it. Arms only when the cohort holds some, so cohorts without Arms hash as- /// before.</summary>+ /// <summary>The record as the state hash writes it. Arms only when the cohort holds some, and the target unit only when+ /// it has one, so other cohorts hash as before.</summary>public string Canonical() => string.Format(CultureInfo.InvariantCulture, "{0}:{1}@{2}x{3}/{4}", Id, Type, City, Count, TurnsLeft)- + (Arms == 0 ? "" : "|arms=" + Arms.ToString(CultureInfo.InvariantCulture));+ + (Arms == 0 ? "" : "|arms=" + Arms.ToString(CultureInfo.InvariantCulture))+ + (Unit is int u ? "|unit=" + u.ToString(CultureInfo.InvariantCulture) : "");}/// <summary>Pioneer work at a designated site (sites.yaml; R-SITE-001 to R-SITE-003): <see cref="Unit"/> building it withdiff --git a/sim/Statecraft.Sim/Military.cs b/sim/Statecraft.Sim/Military.csindex 3359852b9..490f38c23 100644--- a/sim/Statecraft.Sim/Military.cs+++ b/sim/Statecraft.Sim/Military.cs@@ -16,7 +16,7 @@ namespace Statecraft.Simvar service = u.Service + 1;var veteran = service >= r.VeteranSoldierService!.Value;s.Units[u.Id] = new Unit(u.Id, veteran ? "veteran_soldier" : u.Type, u.Q, u.R, service,- u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity);+ u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);if (veteran) why.Add(new Cause("city", "units", u.Strength, "Recruits became veteran soldiers"));}}diff --git a/sim/Statecraft.Sim/Movement.cs b/sim/Statecraft.Sim/Movement.csindex 571a532bc..4da0e8620 100644--- a/sim/Statecraft.Sim/Movement.cs+++ b/sim/Statecraft.Sim/Movement.cs@@ -106,7 +106,7 @@ namespace Statecraft.Simstatic void Stop(GameState s, Unit u, string key, string line, string hex, List<Cause> why){- s.Units[u.Id] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "", u.HomeCity);+ s.Units[u.Id] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "", u.HomeCity, u.Full);why.Add(UnitLines.Line(key, line, new[] { u }, hex));}@@ -125,7 +125,7 @@ namespace Statecraft.Simif (Closed(c, s, false).Contains((q.Value, r.Value))) return "Units may not enter an enemy-held locality before its capture is possible";if (Route(c, s, unitId, q.Value, r.Value, spent).Count == 0) return "No route reaches that hex";var target = HexText(q.Value, r.Value);- var given = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, GoTo, target, u.HomeCity);+ var given = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, GoTo, target, u.HomeCity, u.Full);s.Units[unitId] = given;why.Add(UnitLines.Line(WhyKeys.OnItsWay, $"Unit {unitId} is on its way to hex {target}", new[] { given }, target));if (u.Order == "fortify")@@ -207,7 +207,7 @@ namespace Statecraft.Sim// is given, with the hex it names), so a unit that goes out and comes back the same turn is not fortified; hold moves with// the unit. The order step at the end of the turn only sees the final hex.var fortified = u.Order == "fortify" || u.Order == "fortifying";- s.Units[unitId] = new Unit(u.Id, u.Type, q, r, u.Service, u.Side, u.Strength, fortified ? "" : u.Order, fortified ? "" : u.OrderTarget, u.HomeCity);+ s.Units[unitId] = new Unit(u.Id, u.Type, q, r, u.Service, u.Side, u.Strength, fortified ? "" : u.Order, fortified ? "" : u.OrderTarget, u.HomeCity, u.Full);spent[unitId] = used + cost;why.Add(new Cause("map", unitId.ToString(CultureInfo.InvariantCulture), cost,FormattableString.Invariant($"Unit {unitId} moved to hex {q},{r} for {cost} movement points"), enemy ? Kind : "",diff --git a/sim/Statecraft.Sim/Orders.cs b/sim/Statecraft.Sim/Orders.csindex 58cdc4f9d..97b9d2ba0 100644--- a/sim/Statecraft.Sim/Orders.cs+++ b/sim/Statecraft.Sim/Orders.cs@@ -24,7 +24,7 @@ namespace Statecraft.Simstatic string Hex(Unit u) => string.Format(CultureInfo.InvariantCulture, "{0},{1}", u.Q, u.R);static Unit With(Unit u, string order, string target) =>- new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, order, target, u.HomeCity);+ new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, order, target, u.HomeCity, u.Full);/// <summary>R-ORDER-001's refusals: null when <see cref="Give"/> takes the order, else the reason shown to the player./// Changes nothing: the unit card asks it before it offers fortify or hold (#754). Refused for an unknown order ordiff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.csindex 5f230b527..c4fb6909a 100644--- a/sim/Statecraft.Sim/Projects.cs+++ b/sim/Statecraft.Sim/Projects.cs@@ -91,7 +91,7 @@ namespace Statecraft.Simif (u.Type == "halutz"){var service = u.Service + 1;- u = new Unit(u.Id, service >= r.VeteranHalutzService!.Value ? VeteranType : u.Type, u.Q, u.R, service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity);+ u = new Unit(u.Id, service >= r.VeteranHalutzService!.Value ? VeteranType : u.Type, u.Q, u.R, service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);}}}@@ -234,7 +234,7 @@ namespace Statecraft.Simif (u.Type != "halutz") continue;var service = u.Service + 1;var promoted = service >= r.VeteranHalutzService!.Value;- s.Units[u.Id] = new Unit(u.Id, promoted ? VeteranType : u.Type, u.Q, u.R, service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity);+ s.Units[u.Id] = new Unit(u.Id, promoted ? VeteranType : u.Type, u.Q, u.R, service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);if (promoted) why.Add(new Cause("map", w.Site, 1, "A group of halutzim became veteran pioneers"));}Corridors.Advance(c, s, next, why); // R-COR-002: after the sites (Phase 4 PR 2)diff --git a/sim/Statecraft.Sim/SaveGame.cs b/sim/Statecraft.Sim/SaveGame.csindex c5a87b41c..56e49e6c7 100644--- a/sim/Statecraft.Sim/SaveGame.cs+++ b/sim/Statecraft.Sim/SaveGame.cs@@ -143,6 +143,7 @@ namespace Statecraft.SimAssignWorkers w => $"work {Esc(w.City)} {Esc(w.Role)} {Int(w.Count)}",Train t => $"train {Esc(t.City)} {Esc(t.Track)} {Int(t.Count)}",CancelTraining t => $"untrain {Int(t.Cohort)}",+ Reinforce r => $"reinforce {Int(r.Unit)} {Esc(r.City)} {Int(r.Count)}",PioneerWork p => $"pioneer {Int(p.Unit)} {Esc(p.Action)} {Esc(p.Site)}",StopWork w => $"stop {Int(w.Unit)}",UnitOrder o => $"order {Int(o.Unit)} {Esc(o.Order)}" + (o.Q is int q && o.R is int r ? $" {Int(q)} {Int(r)}" : ""),@@ -257,6 +258,7 @@ namespace Statecraft.Simcase "work": Arity(4); return new AssignWorkers(Str(f[1]), Str(f[2]), I(f[3]));case "train": Arity(4); return new Train(Str(f[1]), Str(f[2]), I(f[3]));case "untrain": Arity(2); return new CancelTraining(I(f[1]));+ case "reinforce": Arity(4); return new Reinforce(I(f[1]), Str(f[2]), I(f[3]));case "pioneer": Arity(4); return new PioneerWork(I(f[1]), Str(f[2]), Str(f[3]));case "stop": Arity(2); return new StopWork(I(f[1]));case "order": // an attack carries its hex (R-COMBAT-001); fortify and hold nonediff --git a/sim/Statecraft.Sim/Scenario.cs b/sim/Statecraft.Sim/Scenario.csindex 0072bbcf5..2a4d93a3b 100644--- a/sim/Statecraft.Sim/Scenario.cs+++ b/sim/Statecraft.Sim/Scenario.cs@@ -64,6 +64,7 @@ namespace Statecraft.Sim["security_order"] = new[] { "delta" }, ["appoint"] = new[] { "office", "person" },["map_action"] = new[] { "action", "q", "r" }, ["assign_workers"] = new[] { "city", "role", "count" },["train"] = new[] { "city", "track", "count" }, ["cancel_training"] = new[] { "cohort" },+ ["reinforce"] = new[] { "unit", "city", "count" },["pioneer_work"] = new[] { "unit", "action", "site" }, ["stop_work"] = new[] { "unit" },["unit_order"] = new[] { "unit", "order", "q", "r" }, // q and r: an attack's hex only (R-COMBAT-001)["start_project"] = new[] { "project", "city", "q", "r" }, ["cancel_project"] = new[] { "project" },@@ -96,6 +97,7 @@ namespace Statecraft.Simcase "assign_workers": return new AssignWorkers(Str(c, "city"), Str(c, "role"), Whole(c, "count"));case "train": return new Train(Str(c, "city"), Str(c, "track"), Whole(c, "count"));case "cancel_training": return new CancelTraining(Whole(c, "cohort"));+ case "reinforce": return new Reinforce(Whole(c, "unit"), Str(c, "city"), Whole(c, "count"));case "pioneer_work": return new PioneerWork(Whole(c, "unit"), Str(c, "action"), Str(c, "site"));case "stop_work": return new StopWork(Whole(c, "unit"));case "unit_order": return new UnitOrder(Whole(c, "unit"), Str(c, "order"), c.ContainsKey("q") ? Whole(c, "q") : (int?)null, c.ContainsKey("r") ? Whole(c, "r") : (int?)null);@@ -142,6 +144,7 @@ namespace Statecraft.SimSetPolicy p => $"{p.Policy} {p.Level}", ChooseEventOption e => $"{e.EventId}/{e.OptionId}", SetMobilization m => m.Level.ToString(CultureInfo.InvariantCulture),SecurityOrder o => o.Delta.ToString(CultureInfo.InvariantCulture), Appoint a => $"{a.Office} {a.Person}", MapAction m => $"{m.Action} {m.Q},{m.R}",AssignWorkers w => $"{w.City} {w.Role} {w.Count}", Train t => $"{t.City} {t.Track} {t.Count}", CancelTraining t => t.Cohort.ToString(CultureInfo.InvariantCulture),+ Reinforce r => FormattableString.Invariant($"{r.Unit} {r.City} {r.Count}"),PioneerWork p => FormattableString.Invariant($"{p.Unit} {p.Action} {p.Site}"), StopWork w => w.Unit.ToString(CultureInfo.InvariantCulture),UnitOrder o => FormattableString.Invariant($"{o.Unit} {o.Order}") + (o.Q is int q && o.R is int r ? FormattableString.Invariant($" {q},{r}") : ""),StartProject p => FormattableString.Invariant($"{p.ProjectKind} {p.City} {p.Q},{p.R}"), CancelProject p => p.Project.ToString(CultureInfo.InvariantCulture),diff --git a/sim/Statecraft.Sim/SettlementControl.cs b/sim/Statecraft.Sim/SettlementControl.csindex 6b9326e8f..69efaf356 100644--- a/sim/Statecraft.Sim/SettlementControl.cs+++ b/sim/Statecraft.Sim/SettlementControl.cs@@ -142,7 +142,7 @@ namespace Statecraft.Simmoved.Clear();return $"A unit has no free hex next to {name} to withdraw to";}- var w = new Unit(u.Id, u.Type, to.Value.Q, to.Value.R, u.Service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity);+ var w = new Unit(u.Id, u.Type, to.Value.Q, to.Value.R, u.Service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);s.Units[u.Id] = w;moved.Add((u, w));}diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.csindex cda7619e1..2afbd4c77 100644--- a/sim/Statecraft.Sim/Simulation.cs+++ b/sim/Statecraft.Sim/Simulation.cs@@ -200,6 +200,8 @@ namespace Statecraft.Simreturn Training.Start(c, s, t.City, t.Track, t.Count, why);case CancelTraining t:return Training.Cancel(c, s, t.Cohort, why);+ case Reinforce r:+ return Training.Reinforce(c, s, r.Unit, r.City, r.Count, why);case PioneerWork p:return Projects.Start(c, s, p.Unit, p.Action, p.Site, why);case StopWork w:diff --git a/sim/Statecraft.Sim/Training.cs b/sim/Statecraft.Sim/Training.csindex c64a32751..e1b47ed3e 100644--- a/sim/Statecraft.Sim/Training.cs+++ b/sim/Statecraft.Sim/Training.cs@@ -15,6 +15,7 @@ namespace Statecraft.Sim{public const string TrainKind = "train";public const string CancelKind = "cancel_training";+ public const string ReinforceKind = "reinforce";/// <summary>The craftsman's unit type id (D-D4; R-CRAFT-001).</summary>public const string Craftsman = "craftsman";@@ -51,9 +52,10 @@ namespace Statecraft.Sim/// city's jobs first (R-CRAFT-002), so only the employed beyond its craftsmen are civilians in work.</summary>public static int Idle(City city) => city.Civilians - Math.Max(0, city.Employed - city.Craftsmen);- /// <summary>The groups the Train orders in <paramref name="pending"/> (this turn's queue) take from+ /// <summary>The groups the Train and Reinforce orders in <paramref name="pending"/> (this turn's queue) take from/// <paramref name="city"/>, every track together.</summary>- public static int Ordered(string city, IEnumerable<Command> pending) => pending.OfType<Train>().Where(t => t.City == city).Sum(t => t.Count);+ public static int Ordered(string city, IEnumerable<Command> pending) =>+ pending.OfType<Train>().Where(t => t.City == city).Sum(t => t.Count) + pending.OfType<Reinforce>().Where(t => t.City == city).Sum(t => t.Count);/// <summary>R-TRAIN-001 with R-CITY-001: the groups still free to train in <paramref name="city"/> once the orders in/// <paramref name="pending"/> (this turn's queue) have run: <see cref="Idle"/>, less every track's Train order there,@@ -73,7 +75,39 @@ namespace Statecraft.Sim/// lacks. The trainees leave the civilians at once, and the cohort takes the next id. Refused, state untouched, when the/// city or track is unknown, the count is below 1, the city has no such facility (<see cref="HasFacility"/>), or it has fewer civilians without/// work. Step has already refused it in the legacy loop.</summary>- public static string? Start(Content c, GameState s, string city, string track, int count, List<Cause> why)+ public static string? Start(Content c, GameState s, string city, string track, int count, List<Cause> why) => Start(c, s, city, track, count, why, null);++ /// <summary>R-TRAIN-004 (#1510; owner, 23 October 2026: "Replacements cost Arms" and "Default (Recommended)"):+ /// <paramref name="count"/> groups of <paramref name="city"/>'s civilians without work train as replacements for the+ /// player's formation <paramref name="unit"/>, which stands on the city's settlement hex. The course is the trained type+ /// of the unit's side and class (a veteran soldier's is the recruit's basic training), and <see cref="Start"/>'s checks,+ /// Money and Arms apply. Refused, state untouched, for a unit that is unknown, not military or not the player's, an+ /// unknown city, a unit off the city's hex, a type no course trains, or a count past its <see cref="Unit.Full"/> less+ /// its strength and the replacements already training for it.</summary>+ public static string? Reinforce(Content c, GameState s, int unit, string city, int count, List<Cause> why)+ {+ if (!s.Units.TryGetValue(unit, out var u)) return "There is no such unit";+ if (u.Side == "") return "Only a military unit takes that order";+ if (u.Side != Movement.PlayerSide) return "That unit is not yours";+ if (!s.Cities.ContainsKey(city)) return "There is no such city";+ var hex = c.SettlementHexes.First(h => h.Id == city);+ if ((u.Q, u.R) != (hex.Q, hex.R)) return FormattableString.Invariant($"Unit {unit} is not in {PlayerText.Settlement(c, city)}");+ var type = c.UnitTypes.First(t => t.Id == u.Type);+ var course = c.UnitTypes.FirstOrDefault(t => t.Side == type.Side && t.Class == type.Class && t.Facility != "");+ if (course == null) return FormattableString.Invariant($"Unit {unit} cannot take replacements");+ var room = Room(s, u);+ if (room <= 0) return FormattableString.Invariant($"Unit {unit} has no losses to replace");+ if (count > room) return FormattableString.Invariant($"Unit {unit} can take {room} more {(room == 1 ? "group" : "groups")}");+ return Start(c, s, city, course.Id, count, why, unit);+ }++ /// <summary>R-TRAIN-004: the groups <paramref name="u"/> can still take: the strength it had before its first loss, less+ /// its strength and the replacements already training for it (0 for a unit that has lost nobody). The unit card reads+ /// it for the Reinforce button's count.</summary>+ public static int Room(GameState s, Unit u) =>+ (u.Full == 0 ? u.Strength : u.Full) - u.Strength - s.Cohorts.Values.Where(k => k.Unit == u.Id).Sum(k => k.Count);++ static string? Start(Content c, GameState s, string city, string track, int count, List<Cause> why, int? unit){if (!s.Cities.TryGetValue(city, out var x)) return "There is no such city";var type = c.UnitTypes.FirstOrDefault(t => t.Id == track && t.Facility != "");@@ -98,8 +132,9 @@ namespace Statecraft.Sim// The plan's reading of D-A6, not part of the owner's ruling: the turn of the order is the first training turn, so// with training_turns 3 an order on turn T is done at the end of T+2 (TrainingTests.ACohortOrderedOnTurnTWithThreeTurnsFinishesAtTheEndOfTurnTPlusTwo). For "done at the end of// T+3", open the cohort with type.TrainingTurns + 1 here; nothing else changes.- s.Cohorts.Add(id, new Cohort(id, type.Id, city, count, type.TrainingTurns, (int)arms));- why.Add(new Cause("city", city, -count, $"{name}: {Groups(count)} began {Course(type)}, cost {PlayerText.Money(c, "treasury", cost)}"));+ s.Cohorts.Add(id, new Cohort(id, type.Id, city, count, type.TrainingTurns, (int)arms, unit));+ var aim = unit is int target ? FormattableString.Invariant($" as replacements for unit {target}") : "";+ why.Add(new Cause("city", city, -count, $"{name}: {Groups(count)} began {Course(type)}{aim}, cost {PlayerText.Money(c, "treasury", cost)}"));if (arms > 0){s.Arms -= (int)arms;@@ -137,11 +172,32 @@ namespace Statecraft.Sim{foreach (var k in s.Cohorts.Values.ToList()){+ // R-TRAIN-004 (owner, 23 October 2026, "Default"): replacements whose unit is gone (destroyed, captured, sent+ // home) or off the city's hex are cancelled as R-TRAIN-002 cancels a cohort, before they lose a turn.+ Unit? target = null;+ if (k.Unit is int aim)+ {+ var at = c.SettlementHexes.First(h => h.Id == k.City);+ if (!s.Units.TryGetValue(aim, out target) || (target.Q, target.R) != (at.Q, at.R))+ {+ why.Add(new Cause("city", k.City, 0, FormattableString.Invariant($"{PlayerText.Settlement(c, k.City)}: unit {aim} is no longer in {PlayerText.Settlement(c, k.City)}, so its replacements stop training")));+ Cancel(c, s, k.Id, why);+ continue;+ }+ }if (k.TurnsLeft > 1) { s.Cohorts[k.Id] = k.WithTurnsLeft(k.TurnsLeft - 1); continue; }s.Cohorts.Remove(k.Id);var type = c.UnitTypes.First(t => t.Id == k.Type);var name = PlayerText.Settlement(c, k.City);- if (type.Side != "")+ if (target != null)+ {+ // The unit keeps its type, service and order (a veteran stays one); full again, it forgets its Full.+ var strength = target.Strength + k.Count;+ s.Units[target.Id] = new Unit(target.Id, target.Type, target.Q, target.R, target.Service, target.Side, strength,+ target.Order, target.OrderTarget, target.HomeCity, strength >= target.Full ? 0 : target.Full);+ why.Add(new Cause("city", k.City, k.Count, FormattableString.Invariant($"{name}: {Groups(k.Count)} finished {Course(type)} and joined unit {target.Id}")));+ }+ else if (type.Side != ""){var hex = c.SettlementHexes.First(h => h.Id == k.City);var id = s.NextId++;diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.csindex ce7dfa09f..d4261c7be 100644--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs@@ -26,8 +26,10 @@ namespace Statecraft.Game.UIreadonly List<(VisualElement row, Label line)> rows = new List<(VisualElement, Label)>();readonly VisualElement panel; readonly SimBridge bridge; readonly UiText text;- readonly Button campButton, housingButton, defenceButton, moveButton, fortifyButton, holdButton, attackButton, sendHomeButton;- readonly System.Action onCamp, onHousing, onDefence, onMove, onFortify, onHold, onAttack, onSendHome;+ readonly Button campButton, housingButton, defenceButton, moveButton, fortifyButton, holdButton, attackButton, sendHomeButton, reinforceButton;+ /// <summary>The Reinforce order the card offers now (#1510), or null: what its button queues.</summary>+ Reinforce? reinforce;+ readonly System.Action onCamp, onHousing, onDefence, onMove, onFortify, onHold, onAttack, onSendHome, onReinforce;readonly System.Func<PlacedToken?> selectedUnit;bool unitMode;/// <summary>Lights the hexes the Move or Attack pick offers on the map (none: clears them); null: nothing is drawn.</summary>@@ -119,6 +121,9 @@ namespace Statecraft.Game.UIonSendHome = () => GiveOrder(Demobilization.SendHome);sendHomeButton.clicked += onSendHome;sendHomeButton.text = text["unit.order.send_home"];+ reinforceButton = panel.Q<Button>("info-reinforce");+ onReinforce = () => { if (reinforce is Reinforce r) { bridge.Queue(r); Render(); } };+ reinforceButton.clicked += onReinforce;bridge.Changed += Render;panel.parent?.RegisterCallback<GeometryChangedEvent>(OnHudGeometry);Render();@@ -127,7 +132,7 @@ namespace Statecraft.Game.UIvoid OnHudGeometry(GeometryChangedEvent e) => panel.EnableInClassList(ShortClass, e.newRect.height < ShortBelowPx);/// <summary>Unsubscribes from the bridge and the buttons (the owner calls this when disabled).</summary>- public void Dispose() { presses.Dispose(); bridge.Changed -= Render; panel.parent?.UnregisterCallback<GeometryChangedEvent>(OnHudGeometry); campButton.clicked -= onCamp; housingButton.clicked -= onHousing; defenceButton.clicked -= onDefence; moveButton.clicked -= onMove; fortifyButton.clicked -= onFortify; holdButton.clicked -= onHold; attackButton.clicked -= onAttack; sendHomeButton.clicked -= onSendHome; EndPick(); }+ public void Dispose() { presses.Dispose(); bridge.Changed -= Render; panel.parent?.UnregisterCallback<GeometryChangedEvent>(OnHudGeometry); campButton.clicked -= onCamp; housingButton.clicked -= onHousing; defenceButton.clicked -= onDefence; moveButton.clicked -= onMove; fortifyButton.clicked -= onFortify; holdButton.clicked -= onHold; attackButton.clicked -= onAttack; sendHomeButton.clicked -= onSendHome; reinforceButton.clicked -= onReinforce; EndPick(); }/// <summary>Below this window height (logical px; 1366x657 is about 998) the panel gets ShortClass, and the city's own/// hex folds its projects behind their toggle as on a stacked bar (GddHexPanel.ToggleName): there the full list ran into@@ -425,6 +430,21 @@ namespace Statecraft.Game.UI// no card copy; the player sees it only after the relevant armistice makes the order available.var sendHomeWhy = orderUnit is int du ? Demobilization.Check(c, s, du) : null;sendHomeButton.style.display = orderUnit != null && sendHomeWhy == null ? DisplayStyle.Flex : DisplayStyle.None;+ // Reinforce (#1510, R-TRAIN-004): offered for a unit of Israel's that has lost strength and stands in a city, for+ // the missing strength up to the city's free civilians; the sim's own Reinforce, run on a copy, decides, and its+ // refusal shows as the other orders' do. None while one is queued for the unit.+ reinforce = null;+ var reinforceQueued = orderUnit is int rq && bridge.QueuedLike(new Reinforce(rq, "", 0)) != null;+ if (orderUnit is int ru && own && !reinforceQueued && s.Units.TryGetValue(ru, out var formation) && Training.Room(s, formation) > 0+ && c.SettlementHexes.FirstOrDefault(h => h.Q == formation.Q && h.R == formation.R && s.Cities.ContainsKey(h.Id)) is { } home)+ {+ var n = System.Math.Max(1, System.Math.Min(Training.Room(s, formation), Training.Available(s, home.Id, bridge.Queued)));+ var why = Training.Reinforce(c, s.Clone(), ru, home.Id, n, new List<Cause>());+ if (why == null) reinforce = new Reinforce(ru, home.Id, n);+ else if (!refusals.Contains(why)) refusals.Add(why);+ }+ reinforceButton.style.display = reinforce != null ? DisplayStyle.Flex : DisplayStyle.None;+ if (reinforce is Reinforce offer) reinforceButton.text = text.Format("unit.order.reinforce", offer.Count);panel.EnableInClassList(UnitClass, unit != null);if (unit != null){@@ -439,7 +459,7 @@ namespace Statecraft.Game.UI? given.Order == Orders.Fortify ? text["unit.fortify_queued"] : given.Order == Orders.Hold ? text["unit.hold_queued"]: given.Order == Combat.Attack && given.Q is int gq && given.R is int gr ? text["unit.attack_queued"] + "\n" + Odds(su, gq, gr): given.Order == Demobilization.SendHome ? text["unit.send_home_queued"] : "" : "";- var lines = new[] { card.Body, order, standing }.Where(x => x != "");+ var lines = new[] { card.Body, order, standing, reinforceQueued ? text["unit.reinforce_queued"] : "" }.Where(x => x != "");title.text = card.Title; subtitle.text = card.Subtitle; settlements.text = string.Join("\n", lines);ShowLocalities("");region.text = ""; // a unit's card names no sub-district (the last hex's would stay under it)diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.csindex 8571a5ac7..61e569f85 100644--- a/unity/Assets/Scripts/UI/SimBridge.cs+++ b/unity/Assets/Scripts/UI/SimBridge.cs@@ -57,6 +57,7 @@ namespace Statecraft.Game.UIAssignWorkers w => "work:" + w.City,Train t => "train:" + t.City + ":" + t.Track,CancelTraining x => FormattableString.Invariant($"untrain:{x.Cohort}"),+ Reinforce x => FormattableString.Invariant($"reinforce:{x.Unit}"),PioneerWork w => FormattableString.Invariant($"unit:{w.Unit}"),StopWork w => FormattableString.Invariant($"unit:{w.Unit}"),UnitOrder o => FormattableString.Invariant($"order:{o.Unit}"),@@ -129,6 +130,10 @@ namespace Statecraft.Game.UI?? Unknown("training", t.Track, Content.UnitTypes.Where(x => !string.IsNullOrEmpty(x.Facility)).Select(x => x.Id));case CancelTraining x:return Unknown("cohort", x.Cohort.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Cohorts.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)));+ // Replacements (#1510): ids only; the sim refuses a full, enemy or misplaced unit and the training checks itself.+ case Reinforce x:+ return Unknown("unit", x.Unit.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Units.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)))+ ?? Unknown("city", x.City, Content.Cities.Select(k => k.Id));// Pioneer work (#378, camp/field/swamp #1124, corridors #786): ids only; the sim refuses a busy unit, a built site or segment, a kind// mismatch or a short Treasury with its own reason. A corridor action names "corridor:N", N from 1.case PioneerWork w:diff --git a/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs b/unity/Assets/Tests/EditMode/SimBridgeGuardTests.csindex 79b85165a..fb58bd391 100644--- a/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs+++ b/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs@@ -29,6 +29,7 @@ public class SimBridgeGuardTests[typeof(AssignWorkers)] = new AssignWorkers("tel_aviv", "job", 1),[typeof(Train)] = new Train("tel_aviv", "halutz", 1),[typeof(CancelTraining)] = new CancelTraining(1),+ [typeof(Reinforce)] = new Reinforce(1, "tel_aviv", 1),[typeof(PioneerWork)] = new PioneerWork(1, "build_yishuv", "mefalsim"),[typeof(StopWork)] = new StopWork(1),[typeof(UnitOrder)] = new UnitOrder(1, "fortify"),diff --git a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs b/unity/Assets/Tests/EditMode/UnitOrdersTests.csindex b4882e70d..a33ecd455 100644--- a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs+++ b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs@@ -277,6 +277,48 @@ public class UnitOrdersTests}}+ /// <summary>#1510 (R-TRAIN-004): a damaged unit of Israel's on a city's hex gets Reinforce for its missing strength, in+ /// English and Hebrew; a press queues the sim's Reinforce and the card says it waits for End turn. With no Arms the button+ /// hides and the sim's reason shows; an undamaged unit, or one off a city, gets neither.</summary>+ [Test]+ public void ReinforceQueuesTheMissingStrengthFromTheCityTheUnitStandsIn()+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ foreach (var (t, label) in new[] { (Text, "Reinforce +"), (he, "תגבור +") })+ {+ using var ui = new UiTestKit();+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ var bridge = new SimBridge(g, t);+ var token = UnitRoster.FromState(Units, C, g.State, _ => true, (row, a, q, r) => a).Single(x => x.Unit.Id == "golani");+ var id = UnitCard.SimUnit(C, g.State, token.Unit)!.Value;+ var u = g.State.Units[id];+ var city = C.SettlementHexes.Single(h => h.Id == "tel_aviv");+ PlacedToken? selected = new PlacedToken(token, new AnchorSpot(0, 0, 0, 0, false));+ var info = new InfoPanelPresenter(ui.Root, bridge, t, new Dictionary<string, string>(), selectedUnit: () => selected);+ var button = ui.Q<Button>("info-reinforce");+ info.ShowUnit();+ Assert.AreEqual(DisplayStyle.None, button.style.display.value, "Golani at the start has lost nobody");++ g.State.Units[id] = new Unit(u.Id, u.Type, city.Q, city.R, u.Service, u.Side, u.Strength - 2, u.Order, u.OrderTarget, u.HomeCity, u.Strength);+ g.State.Arms = 0;+ info.ShowUnit();+ Assert.AreEqual(DisplayStyle.None, button.style.display.value, "no Arms, no Reinforce");+ StringAssert.Contains("not enough Arms", ui.Q<Label>("info-reason").text, "the sim's reason shows");++ g.State.Arms = 100;+ info.ShowUnit();+ Assert.AreEqual(DisplayStyle.Flex, button.style.display.value, "damaged, in Tel Aviv, with Arms");+ Assert.AreEqual(t.Format("unit.order.reinforce", 2), button.text);+ StringAssert.StartsWith(label, button.text);+ UiTestKit.Press(button);+ var queued = bridge.Queued.OfType<Reinforce>().Single();+ Assert.AreEqual((id, "tel_aviv", 2), (queued.Unit, queued.City, queued.Count));+ StringAssert.Contains(t["unit.reinforce_queued"], ui.Q<Label>("info-settlements").text, "the card says the order waits for End turn");+ Assert.AreEqual(DisplayStyle.None, button.style.display.value, "one order a unit");+ info.Dispose();+ }+ }+/// <summary>Gives the state the Arms for an attack and, when Golani has no enemy in reach (the sim's Combat.Check takes no/// hex), puts the first enemy sim unit on the first free land hex next to it; returns Golani's sim id.</summary>internal static int EnemyInGolanisReach(GameState s)diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex 6ad476407..00c360e54 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -158,6 +158,9 @@<ui:Button name="info-attack" /><!-- Send home (#1309): shown only when the sim's Demobilization.Check takes the unit. --><ui:Button name="info-send-home" />+ <!-- Reinforce (#1510): shown only when the sim's Training.Reinforce takes the unit's missing strength from the+ city it stands in; else its reason shows. -->+ <ui:Button name="info-reinforce" /></ui:VisualElement><ui:Label name="info-reason" class="reason" /><!-- The hex's city projects (GddHexPanel, #1122): here, not in the GDD column, which a city's own hex fills. -->diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 94ec533a5..23b85b100 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -482,6 +482,9 @@ unit.attack_queued: "Attack ordered: the unit attacks when you end the turn"# The unit card's player-triggered demobilisation order (R-UNIT-005, #1309).unit.order.send_home: "Send home"unit.send_home_queued: "Send home ordered: the unit goes home when you end the turn"+# Reinforce (#1510, R-TRAIN-004): the missing strength trained from the city the unit stands in.+unit.order.reinforce: "Reinforce +{0}"+unit.reinforce_queued: "Reinforce ordered: the replacements start training when you end the turn"newgame.confirm: "Press New game again to abandon this game and start over."newgame.delete_failed: "The old saved game could not be removed; it will be replaced after your next turn."save.unreadable: "Your saved game could not be loaded ({0}). A new game has started."diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 98194b6c0..f33264bcd 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -511,6 +511,9 @@ unit.attack_queued: "ניתנה פקודת התקפה: היחידה תתקוף# Hebrew drafts: agent-checked; native review pending (#564).unit.order.send_home: "שליחה הביתה"unit.send_home_queued: "ניתנה פקודת שליחה הביתה: היחידה תחזור הביתה בסיום התור"+# Reinforce (#1510, R-TRAIN-004). Agent-drafted, awaiting a native read.+unit.order.reinforce: "תגבור +{0}"+unit.reinforce_queued: "ניתנה פקודת תגבור: כוח ההשלמה יתחיל באימון בסיום התור"newgame.confirm: "יש ללחוץ שוב על משחק חדש כדי לעזוב את המשחק הזה ולהתחיל מחדש."newgame.delete_failed: "לא ניתן היה להסיר את השמירה הקודמת; היא תוחלף אחרי התור הבא."save.unreadable: "לא ניתן היה לטעון את המשחק השמור ({0}). משחק חדש התחיל."