A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
sim: capture, resolver step 3 (GDD Phase 6 PR 4, refs #796) (#1239)
Beri388780f4a405
diff --git a/changelog.d/sim-gdd-capture-796.md b/changelog.d/sim-gdd-capture-796.mdnew file mode 100644index 000000000..e2df4b530--- /dev/null+++ b/changelog.d/sim-gdd-capture-796.md@@ -0,0 +1,8 @@+- GDD Phase 6 PR 4: capture, resolver step 3 (refs #796, #386). At turn end, in ordinal id order, a curated target that+ starts under enemy control is captured when Israeli military units are on its hex and no enemy military unit is+ (Q-CAP-1 (a), Q-CAP-3 (a); R-CTRL-004). Its settlement record names Israel, awaits the player's choice and starts on+ the turn's end; enemy units alone on a captured target return it to enemy control (#796). A halutz holds nothing, and+ "enemy-held" means `mvp.enemy_held_localities` (owner, 21 October 2026, #796). A target that is not enemy-held at the+ start (Jaffa, #793) is never captured. The loader refuses a target whose hex is not its hex in+ `map/settlement_hexes.yaml` (R-CTRL-001). Capture changes no resident, unit, resource, city, score or objective and+ draws nothing from the RNG (R-CTRL-005). The shipped target list is empty, so no golden moves.diff --git a/docs/determinism.md b/docs/determinism.mdindex eb0cc78f2..bb1d78ed3 100644--- a/docs/determinism.md+++ b/docs/determinism.md@@ -18,6 +18,9 @@ The simulation must produce the same state, bit for bit, on .NET, Unity Mono andRound-trip decimal formatting is only a display concern: .NET and Unity Mono can spell the same carry bitsdifferently. The Phase 7 minister carry correction re-pins hash1950, hash1952 and mvp-end for this representationonly; stored values, gameplay and completion dates are unchanged.+- **Settlement control (resolver step 3):** targets resolve in ordinal id order, and the capture check reads only unit+ positions, with no RNG draw (R-CTRL-004; `CaptureTests.SettlementsResolveInOrdinalOrder` and `NoRngDraw`). The shipped+ target list is empty, so no golden captures a place.## Golden playthroughsdiff --git a/docs/gdd/settlement-control.md b/docs/gdd/settlement-control.mdindex 0fa4fb821..850603ac8 100644--- a/docs/gdd/settlement-control.md+++ b/docs/gdd/settlement-control.md@@ -10,7 +10,7 @@ As the player, I want a captured settlement to present a sober choice between le- Enemy units may capture the player's localities. The capture changes their state, and every place tied by sources to a dated loss receives a sourced card. A capture that exists only in an alternate timeline also requires researched cards (`Q-TGT-2`; planned R-CTRL-006; owner ruling [S3]).- Settlement state uses one immutable record per settlement in an ordinal `SortedDictionary<string, SettlementControl>`. It is written to the deterministic hash as `ctrl{...}` only when non-empty, and each field is written only when it differs from its default. `DisplacedByPlayer` is an integer count of places and is written only when non-zero (`Q-TECH-2`, `Q-CAP-2`; R-CTRL-002 for the collection; owner rulings [S3], [S4]).- Residents and combatants are distinct. The state records only whether a place is inhabited, not a resident count, and only enemy military units on its hex are combatants (`Q-CAP-2`, `Q-CAP-3`; R-CTRL-003; owner ruling [S4]).-- A target is captured at turn end when its hex contains no enemy combatant and a player unit holds it (`Q-CAP-1` / `D-F2`; planned R-CTRL-004; owner ruling [S4]).+- A target is captured at turn end when its hex contains no enemy combatant and a player unit holds it (`Q-CAP-1` / `D-F2`; R-CTRL-004, R-CTRL-005; owner ruling [S4]).- A capture awaiting a decision remains pending and the player's units stay in place. What happens if that decision is still pending at the MVP's end remains open (`Q-HIST-1`; planned R-CTRL-008; owner ruling [S5]). **Then decided (owner, 18 Oct 2026, "Counts as Raid"; [#797](https://github.com/eyalgolan/statecraft-israel/issues/797#issuecomment-6254333420)):** at the MVP's end the units leave, nothing changes for the residents and the pending capture adds nothing to the score [S10].- Capture outcomes use one `ResolveCapture(settlement, outcome)` command and one Attention-cost key. End-of-occupation outcomes likewise use one `EndOccupation(settlement, outcome)` command. The capture dialog reads its options and cost preview from public simulation helpers and sends the selected command through the existing queue; it holds no rule of its own (`Q-TECH-3`, `Q-TECH-5`; owner ruling [S3]).- Raid makes the player's units leave immediately, returns the place to enemy control and does not change its residents (`Q-RAID-1`; planned R-CTRL-010; owner ruling [S5]). The reference player and `HistoricalAI` always choose Raid (`Q-REF-1`; planned R-CTRL-009; owner ruling [S5]).diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex edf8fd93c..ae6c49d18 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -30,12 +30,16 @@ The ID R-LOOP-003 (the Phase 1 overlay, `MvpSlice.Overlay`) is retired with the## Settlement control-R-CTRL-001: Only a settlement in `settlement_targets.yaml` may be captured. Each target is an `arab_town` row of `map/settlements_1948.yaml` (Q-TGT-1 (a), owner ruling of 18 October 2026), stands on a land hex of `map/hexes.json`, names a sourced operation (each source an https URL with a `checked` date) and carries a review status; any other row is a load error naming file and field. The shipped list is empty until researched rows have a person's check and the sensitivity review (D-F5).+R-CTRL-001: Only a settlement in `settlement_targets.yaml` may be captured. Each target is an `arab_town` row of `map/settlements_1948.yaml` (Q-TGT-1 (a), owner ruling of 18 October 2026), stands on a land hex of `map/hexes.json` that is its own hex in `map/settlement_hexes.yaml`, names a sourced operation (each source an https URL with a `checked` date) and carries a review status; any other row is a load error naming file and field. The shipped list is empty until researched rows have a person's check and the sensitivity review (D-F5).R-CTRL-002: Settlement control is an ordinal `SortedDictionary<string, SettlementControl>`. It is written to the state hash as `ctrl{...}` only when non-empty, in ordinal id order; each record field is written only when it differs from its default (R-LOOP-002).R-CTRL-003: Residents and combatants are distinct fields. Residents are a state, inhabited or depopulated, not a count (Q-CAP-2 (b)). No rule reads residents as combatants, prisoners, refugee units, labour or a resource; annexation is the one place a later owner-approved rule may say otherwise.+R-CTRL-004: Resolver step 3 is the capture check, after combat (step 2), in ordinal settlement id (Q-CAP-1 (a), Q-CAP-3 (a), owner rulings of 18 October 2026). A target that starts under enemy control, one listed in `mvp.enemy_held_localities` (owner, 21 October 2026, #796), is captured at turn end when Israeli military units are on its hex and no enemy military unit is; only enemy military units are combatants (Q-CAP-3 (a)), and a halutz holds nothing (#796). Its record names `israel` as owner, has the state `awaiting_choice` and starts on the turn's end (`Since`); the player's units stay on the hex. A captured target still awaiting the choice that only enemy military units are on is under enemy control again, and its record is removed (#796). A target not enemy-held at the start (Jaffa, owner ruling of 18 October 2026 on #793, "Only in a what-if") is never captured. The check is an integer rule on unit positions and draws nothing from the RNG. Enemy captures of the player's localities (Q-TGT-2 (c), the plan's R-CTRL-006) are not built yet: with the real starting forces a Syrian unit stands on Degania Alef's hex with no Israeli unit, so the rule would record a capture at the first turn's end (#796).++R-CTRL-005: Capture writes the settlement state only. It changes no resident field (the place stays inhabited), no unit, no resource, parameter, city or score, and counts towards no objective (constraint 6 of the Phase 6 plan; impact plan section 4.3).+## SavesR-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).diff --git a/sim/Statecraft.Sim.Tests/CaptureTests.cs b/sim/Statecraft.Sim.Tests/CaptureTests.csnew file mode 100644index 000000000..1211c7615--- /dev/null+++ b/sim/Statecraft.Sim.Tests/CaptureTests.cs@@ -0,0 +1,184 @@+using System;+using System.Collections.Generic;+using System.Linq;+using Statecraft.Sim;++/// <summary>Capture, resolver step 3 (GDD Phase 6 PR 4, #796). The owner's rulings of 18 October 2026 (#783, batch 2):+/// Q-CAP-1 (a), a settlement counts as captured when no enemy combatant is in the hex and a player unit holds it at turn end;+/// Q-CAP-3 (a), only enemy military units on the hex are its combatants. The owner's ruling of 21 October 2026 (#796): a+/// halutz holds nothing, "enemy-held" means mvp.enemy_held_localities, and enemy units alone on an awaiting_choice target+/// take it back. The fixture's places are fixture values, not+/// history: town_a and town_c are arab_town targets the fixture lists as enemy-held, town_d an arab_town target that is+/// not, and town_e an enemy-held arab_town that is not a target.</summary>+public class CaptureTests+{+ 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";++ static readonly (string Id, string Type, int Q, int R)[] Places =+ {+ ("town_a", "arab_town", 1, 0), ("town_c", "arab_town", 4, 0),+ ("town_d", "arab_town", 1, 2), ("town_e", "arab_town", 4, 2),+ };++ static string Target(string id, int q, int r) => FormattableString.Invariant(+ $" - {{ id: {id}, q: {q}, r: {r}, operation: fixture_operation, sources: [{{ url: \"https://example.org/{id}\", checked: 2026-10-18 }}], status: sensitivity-reviewed }}\n");++ /// <summary>MovementTests' 6 x 3 coastal plain with the four places; <paramref name="targets"/> lists the targets in+ /// file order.</summary>+ static Content Load(params string[] targets)+ {+ var files = Fixture.Gdd(new Dictionary<string, string>+ {+ ["unit_types.yaml"] = Types, ["map/hexes.json"] = MovementTests.Board(), ["corridors.yaml"] = "corridors: []\n",+ ["map/settlement_hexes.yaml"] = "settlements:\n" + string.Concat(Places.Select(p => FormattableString.Invariant($" - {{ id: {p.Id}, q: {p.Q}, r: {p.R} }}\n"))),+ ["map/settlements_1948.yaml"] = "settlements:\n" + string.Concat(Places.Select(p => FormattableString.Invariant(+ $" - {{ id: {p.Id}, name: {p.Id.Replace("town_", "Town ").ToUpperInvariant()}, lon: 34.29, lat: 33.35, type: {p.Type}, founded: 1900, pre_modern: false }}\n"))),+ ["settlement_targets.yaml"] = targets.Length == 0 ? "targets: []\n" : "targets:\n" + string.Concat(targets.Select(id => { var p = Places.Single(x => x.Id == id); return Target(p.Id, p.Q, p.R); })),+ });+ files["rules.yaml"] = files["rules.yaml"].Replace("enemy_held_localities: []", "enemy_held_localities: [town_a, town_c, town_e]");+ return ContentLoader.Load(Fixture.Write(files));+ }++ static readonly string[] AllTargets = { "town_a", "town_c", "town_d" };++ static GameState With(Content c, params Unit[] units) => CombatTests.With(c, units);+ static Unit Soldier(int id, int q, int r) => new Unit(id, "soldier", q, r, side: "israel", strength: 2);+ static Unit Enemy(int id, int q, int r) => new Unit(id, "enemy", q, r, side: "egypt", strength: 2);++ static GameState Step(Content c, GameState s) => Simulation.Step(c, s, Array.Empty<Command>()).State;++ static List<Cause> Capture(Content c, GameState s)+ {+ var why = new List<Cause>();+ SettlementControl.Capture(c, s, s.Date.AddDays(7), why);+ return why;+ }++ // R-CTRL-004 (Q-CAP-1 (a)): a target is captured at turn end when a player unit holds its hex and no enemy combatant+ // is there. The capture writes the player as owner, the turn's end as Since, and marks it as awaiting the choice.+ [Fact]+ public void ATargetIsCapturedWhenAPlayerUnitHoldsItWithNoEnemyCombatant()+ {+ var c = Load(AllTargets);+ var s = With(c, Soldier(1, 1, 0));+ var start = s.Date;+ var next = Step(c, s);+ var ctrl = Assert.Single(next.Settlements);+ Assert.Equal("town_a", ctrl.Key);+ Assert.Equal(Movement.PlayerSide, ctrl.Value.Owner);+ Assert.Equal(SettlementControl.AwaitingChoice, ctrl.Value.State);+ Assert.Equal(next.Date, ctrl.Value.Since);+ Assert.True(ctrl.Value.Since > start);+ Assert.Contains("ctrl{\n town_a=owner=israel,state=awaiting_choice,since=", next.Describe());+ }++ // R-CTRL-004 (Q-CAP-1 (a), Q-CAP-3 (a)): an enemy military unit on the hex is a combatant, so no capture; and with+ // both sides on a captured target, neither holds it, so its record stays.+ [Fact]+ public void AnEnemyCombatantOnTheHexPreventsTheCapture()+ {+ var c = Load(AllTargets);+ var s = With(c, Soldier(1, 1, 0), Enemy(2, 1, 0));+ Assert.Empty(Step(c, s).Settlements);+ s.Settlements["town_a"] = new SettlementControl(Movement.PlayerSide, SettlementControl.AwaitingChoice, s.Date);+ Assert.Empty(Capture(c, s));+ Assert.Equal(SettlementControl.AwaitingChoice, s.Settlements["town_a"].State);+ }++ // R-CTRL-004 (Q-CAP-1 (a); #796, 21 October 2026): no player unit, or only a halutz (no combatant, R-UNIT-001), holds+ // nothing.+ [Fact]+ public void NoPlayerCombatantNoCapture()+ {+ var c = Load(AllTargets);+ Assert.Empty(Step(c, With(c)).Settlements);+ Assert.Empty(Step(c, With(c, new Unit(1, "halutz", 1, 0))).Settlements);+ Assert.Empty(Step(c, With(c, Soldier(1, 2, 0))).Settlements); // next to the target is not on it+ }++ // R-CTRL-004 (#796, 21 October 2026): a halutz beside a soldier is not an enemy unit, so the soldier still captures.+ [Fact]+ public void AHalutzBesideASoldierDoesNotBlockTheCapture()+ {+ var c = Load(AllTargets);+ var next = Step(c, With(c, Soldier(1, 1, 0), new Unit(2, "halutz", 1, 0)));+ Assert.Equal("town_a", Assert.Single(next.Settlements).Key);+ }++ // R-CTRL-004 (#793, "Only in a what-if"): a target that is not enemy-held at the start (Jaffa's case) offers no capture.+ [Fact]+ public void ATargetThatIsNotEnemyHeldIsNotCaptured()+ {+ var c = Load(AllTargets);+ Assert.Empty(Step(c, With(c, Soldier(1, 1, 2))).Settlements);+ }++ // R-CTRL-004 (#796, 21 October 2026): a captured target the enemy holds again, with no player combatant there, is back+ // under enemy control.+ [Fact]+ public void AnEnemyUnitHoldingACapturedTargetReturnsItToEnemyControl()+ {+ var c = Load(AllTargets);+ var s = With(c, Enemy(1, 1, 0));+ s.Settlements["town_a"] = new SettlementControl(Movement.PlayerSide, SettlementControl.AwaitingChoice, s.Date);+ Capture(c, s);+ Assert.Empty(s.Settlements);+ }++ // R-CTRL-001: a player unit on a locality that is not on the list changes nothing.+ [Fact]+ public void ANonTargetIsNeverCaptured()+ {+ var c = Load(AllTargets);+ var s = With(c, Soldier(1, 4, 2)); // town_e: an enemy-held arab_town, not a target+ Assert.Empty(Step(c, s).Settlements);+ var none = Load(); // the real list ships empty+ Assert.Empty(Step(none, With(none, Soldier(1, 1, 0))).Settlements);+ }++ // R-CTRL-005: capture changes no resident field and grants nothing. Every resource, parameter, city, the score and+ // every objective are the same before and after step 3 on a capture turn; only the settlement state differs.+ [Fact]+ public void CaptureGrantsNothing()+ {+ var c = Load(AllTargets);+ var s = With(c, Soldier(1, 1, 0), Soldier(2, 4, 0));+ var before = s.Clone();+ Assert.NotEmpty(Capture(c, s));+ Assert.Equal(2, s.Settlements.Count);+ Assert.All(s.Settlements.Values, x => Assert.False(x.Depopulated));+ Assert.All(s.Settlements.Values, x => Assert.Equal(0, x.Combatants));+ s.Settlements.Clear();+ Assert.Equal(before.Describe(), s.Describe());+ }++ // R-CTRL-004, determinism: two captures in one turn give the same state whatever order the targets and the units+ // were added in.+ [Fact]+ public void SettlementsResolveInOrdinalOrder()+ {+ var c1 = Load("town_a", "town_c");+ var c2 = Load("town_c", "town_a");+ var s1 = With(c1, Soldier(1, 1, 0), Soldier(2, 4, 0));+ var s2 = With(c2, Soldier(2, 4, 0), Soldier(1, 1, 0));+ var why1 = Capture(c1, s1);+ var why2 = Capture(c2, s2);+ Assert.Equal(new[] { "town_a", "town_c" }, why1.Select(x => x.Target).ToArray()); // the Why lines, in ordinal id order+ Assert.Equal(why1.Select(x => x.Message), why2.Select(x => x.Message));+ Assert.Equal(s1.Describe(), s2.Describe());+ }++ // R-CTRL-004, determinism: step 3 draws nothing from the RNG.+ [Fact]+ public void NoRngDraw()+ {+ var c = Load(AllTargets);+ var s = With(c, Soldier(1, 1, 0), Soldier(2, 4, 0));+ var rng = s.RngState;+ Capture(c, s);+ Assert.Equal(2, s.Settlements.Count);+ Assert.Equal(rng, s.RngState);+ }+}diff --git a/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs b/sim/Statecraft.Sim.Tests/ContentLoaderTests.csindex 4c95aa68d..b32dba687 100644--- a/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs+++ b/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs@@ -37,6 +37,7 @@ targets:[Theory][InlineData("town_a", "unknown", ".id", "is not an arab_town row of map/settlements_1948.yaml")][InlineData(" q: 1\n", " q: 0\n", ".q", "is not a land hex")]+ [InlineData(" r: 0\n", " r: 1\n", ".q", "is not town_a's hex in map/settlement_hexes.yaml")][InlineData(" operation: fixture_operation\n", "", ".operation", "required")][InlineData(" sources: [{ url: \"https://example.org/operation\", checked: 2026-10-18 }]\n", "", ".sources", "needs at least one source")][InlineData(", checked: 2026-10-18", "", ".sources[0]", "needs an https url and a checked date")]diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex d9627515f..0ced526ab 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -1540,8 +1540,9 @@ namespace Statecraft.Sim}}- /// <summary>R-CTRL-001 (Q-TGT-1 (a)): every target is an arab_town row of settlements_1948.yaml on a land hex, with a- /// sourced operation and a review status.</summary>+ /// <summary>R-CTRL-001 (Q-TGT-1 (a)): every target is an arab_town row of settlements_1948.yaml on a land hex that is+ /// its own hex in settlement_hexes.yaml (capture reads the target's hex, movement the settlement's), with a sourced+ /// operation and a review status.</summary>static void ValidateSettlementTargets(Content c, IEnumerable<string> arabTownIds){Unique(SettlementTargetsFileName, "targets", c.SettlementTargets.Select(x => x.Id));@@ -1554,6 +1555,8 @@ namespace Statecraft.Simvar hex = c.HexAt(x.Q, x.R);if (hex == null || !hex.Land)throw new ContentException(SettlementTargetsFileName, at + ".q", FormattableString.Invariant($"hex q={x.Q} r={x.R} is not a land hex in {HexesFile}"));+ if (c.SettlementHexes.Any(h => h.Id == x.Id && (h.Q != x.Q || h.R != x.R)))+ throw new ContentException(SettlementTargetsFileName, at + ".q", FormattableString.Invariant($"hex q={x.Q} r={x.R} is not {x.Id}'s hex in {SettlementHexesFileName}"));if (string.IsNullOrWhiteSpace(x.Operation)) throw new ContentException(SettlementTargetsFileName, at + ".operation", "required");if (x.Sources.Count == 0) throw new ContentException(SettlementTargetsFileName, at + ".sources", "needs at least one source");for (int i = 0; i < x.Sources.Count; i++)diff --git a/sim/Statecraft.Sim/GddState.cs b/sim/Statecraft.Sim/GddState.csindex 42a60a3b0..3e9a2ab7f 100644--- a/sim/Statecraft.Sim/GddState.cs+++ b/sim/Statecraft.Sim/GddState.cs@@ -8,7 +8,7 @@ namespace Statecraft.Sim/// <summary>One settlement's control state. Residents are a state, inhabited (the default) or depopulated, never a count/// or a combatant field (Q-CAP-2 (b); R-CTRL-003). Immutable so <see cref="GameState.Clone"/> can copy the containing map/// shallowly.</summary>- public sealed class SettlementControl+ public sealed partial class SettlementControl{public string Owner { get; }public string State { get; }diff --git a/sim/Statecraft.Sim/SettlementControl.cs b/sim/Statecraft.Sim/SettlementControl.csnew file mode 100644index 000000000..ee381d575--- /dev/null+++ b/sim/Statecraft.Sim/SettlementControl.cs@@ -0,0 +1,55 @@+using System;+using System.Collections.Generic;+using System.Linq;++namespace Statecraft.Sim+{+ /// <summary>Settlement control in the GDD v0.1 loop (GDD Phase 6; docs/gdd/settlement-control.md). This half holds resolver+ /// step 3, the capture check (R-CTRL-004, R-CTRL-005). The record itself is in GddState.cs.</summary>+ public sealed partial class SettlementControl+ {+ /// <summary>The <see cref="State"/> of a target the player has captured and has not yet chosen an outcome for.</summary>+ public const string AwaitingChoice = "awaiting_choice";++ /// <summary>Resolver step 3 (R-CTRL-004, R-CTRL-005), after combat, in ordinal settlement id. A curated target that+ /// starts under enemy control (on mvp.enemy_held_localities, owner, 21 October 2026, #796) is captured when the+ /// player's military units are on its hex and no enemy military unit is (Q-CAP-1 (a); Q-CAP-3 (a): only enemy military+ /// units are combatants; #796: a halutz holds nothing): its record names the player, awaits the player's choice and+ /// starts on <paramref name="next"/>, the turn's end. A captured target still awaiting the choice that only enemy+ /// military units are on is under enemy control again, and its record goes (#796). A target that is not enemy-held+ /// at the start (Jaffa, #793) is never captured. Capture writes the settlement state only: no resident field, unit,+ /// resource, score or objective (R-CTRL-005). It draws nothing from the RNG.</summary>+ public static void Capture(Content c, GameState s, DateTime next, List<Cause> why)+ {+ var enemyHeld = new HashSet<string>(c.RulesAt(s.Date).Mvp!.EnemyHeldLocalities, StringComparer.Ordinal);+ foreach (var t in c.SettlementTargets.Where(x => enemyHeld.Contains(x.Id)).OrderBy(x => x.Id, StringComparer.Ordinal))+ {+ var holder = Holder(s, t.Q, t.R);+ var record = s.Settlements.TryGetValue(t.Id, out var held) ? held : null;+ var name = c.SettlementNames[t.Id];+ if (holder == Movement.PlayerSide && record == null)+ {+ s.Settlements[t.Id] = new SettlementControl(Movement.PlayerSide, AwaitingChoice, next);+ why.Add(new Cause("map", t.Id, 0, $"{name} is captured: Israeli units hold it and no enemy unit is there. It awaits a decision"));+ }+ else if (holder == Enemy && record?.State == AwaitingChoice) // PR 5's outcomes decide what a later state returns to+ {+ s.Settlements.Remove(t.Id);+ why.Add(new Cause("map", t.Id, 0, $"{name} is under enemy control again: enemy units hold it and no Israeli unit is there"));+ }+ }+ }++ const string Enemy = "enemy";++ /// <summary>Who holds (q, r): <see cref="Movement.PlayerSide"/> when only Israeli military units are on it,+ /// <see cref="Enemy"/> when only enemy ones are, else null (none, or both).</summary>+ static string? Holder(GameState s, int q, int r)+ {+ var on = s.Units.Values.Where(u => u.Q == q && u.R == r && u.Side != "").ToList();+ if (on.Count == 0) return null;+ var player = on.Count(u => u.Side == Movement.PlayerSide);+ return player == on.Count ? Movement.PlayerSide : player == 0 ? Enemy : null;+ }+ }+}diff --git a/sim/Statecraft.Sim/TurnResolver.cs b/sim/Statecraft.Sim/TurnResolver.csindex 7dff55dd6..07b092495 100644--- a/sim/Statecraft.Sim/TurnResolver.cs+++ b/sim/Statecraft.Sim/TurnResolver.cs@@ -16,7 +16,7 @@ namespace Statecraft.Simvar r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop// 1. Enemy orders: Phase 5 PR 10.Combat.Resolve(c, s, why); // 2. combat, in ascending attacker id (R-COMBAT-002)- // 3. Capture: Phase 6.+ SettlementControl.Capture(c, s, next, why); // 3. capture, in ordinal settlement id (R-CTRL-004, R-CTRL-005)Orders.Settle(s, why); // 3b. after combat: fortify given this turn is set, and lost where a unit left its hex (R-ORDER-002)Training.Progress(c, s, why); // 4. trainingProjects.Advance(c, s, next, why); // 5. construction