Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

sim: refuse the player's attacks during an accepted truce (#750 slice 2) (#1310)

agamrafaeli-instinct3abb743627aa
diff --git a/changelog.d/sim-truce-attacks-750.md b/changelog.d/sim-truce-attacks-750.md
new file mode 100644
index 000000000..8df4ff1c3
--- /dev/null
+++ b/changelog.d/sim-truce-attacks-750.md
@@ -0,0 +1,4 @@
+- Simulation: from accepting a truce card until its window ends, the player's attack orders are refused with "A
+ truce is in force" - from the first truce's acceptance until the turn covering 8 July 1948, and from the second's
+ until the turn covering 15 October 1948 (refs #750). Accepting a truce ends and clears the player's standing
+ attacks with a line; movement and every other order stand. The enemy side's own truce guard is untouched.
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index df1470345..081ee8668 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -222,6 +222,10 @@ R-COMBAT-007: Artillery (a type of class `artillery`, which needs a `range` and
R-COMBAT-008: A military type may carry a `combat_percent` (at least 1; none is 100): its units' strength counts at that percent in the ratio, attacking and defending, in integers (R-COMBAT-002). The armoured car's is 150 (real value), with its 5 movement points (R-MOVE-001) and no other rule (Q-ARTY-2).
+Phase 5 PR 11, slice 2 (#750): the truce cards bind the player's attack orders (Q-WAR-3). The windows and the two rulings below are the owner's of 21 and 22 October 2026 (https://github.com/eyalgolan/statecraft-israel/issues/750#issuecomment-6327133246). The card-to-window binding by `ChosenOptions` is an agent default of this PR; the rest of #750's war state replaces R-ENEMY-006's date-alone guard in its own slices.
+
+R-COMBAT-009: From accepting a truce card until its window ends, the player's attack orders are refused with "A truce is in force": from `first_truce`'s `accept` on the turns that start before 8 July 1948, and from `second_truce`'s `comply` on the turns that start before 15 October 1948, on the sourced dates of `events/first_truce.yaml`, `events/ten_days.yaml`, `events/second_truce.yaml` and `events/operation_yoav.yaml` (R-ENEMY-006's windows). A refused or defied card binds nothing: only the accepting option starts the binding. A complying player attacks again from the 15 October 1948 turn (owner ruling 1). The rule reads its turn by the turn's first day (the date the HUD shows) and R-ENEMY-006 by the turn's middle day; on monthly turns the two agree: the turns of 15 June to 15 September 1948 are bound, 15 October is free. Movement and every other order stand. Accepting a truce ends and clears every standing attack of the player's, with a line ("Unit N's attack on hex (q, r) ends: a truce is on"), the same as the enemy side's (owner ruling 2; R-ENEMY-006); the enemy side's own guard is untouched. The truce's refusal takes nothing: the order names its hex before the truce is checked, the state and the Attention are preserved, and no Arms are paid.
+
## The enemy
Phase 5 PR 10, part 1 (#749). Q-ENEMY-1 to Q-ENEMY-4 are the plan's recommendations (owner, 15 October 2026, #375: "Take all recommendations"). The march's turns (through the 15 June 1948 turn, until the first truce ends on 8 July) are the owner's (owner, 21 October 2026, #749); so is the truce guard (R-ENEMY-006, same ruling). The scripted anchor's choice, the goal order, `mvp.enemy_attack_ratio_percent` and the truce guard's turn-middle reading are agent defaults proposed on #749 and #1263. The operation cards' orders (Q-ENEMY-5, the plan's R-ENEMY-005) are part 2.
diff --git a/sim/Statecraft.Sim.Tests/TruceTests.cs b/sim/Statecraft.Sim.Tests/TruceTests.cs
new file mode 100644
index 000000000..e67a96d6e
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/TruceTests.cs
@@ -0,0 +1,164 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>The player's side of a truce (GDD Phase 5 PR 11, slice 2; Q-WAR-3; #750): from accepting first_truce until
+/// the turn covering 8 July 1948, and from accepting second_truce until the turn covering 15 October 1948, the player's
+/// attack orders are refused with "A truce is in force", state unchanged, while movement and the other orders stay
+/// allowed; accepting a truce ends and clears a queued attack, as on the enemy side (owner rulings, 22 October 2026,
+/// #750). The enemy side's date-driven guard is R-ENEMY-006 (#1263).</summary>
+public class TruceTests
+{
+ static Content Load(Dictionary<string, string>? events = null) => ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>
+ {
+ ["unit_types.yaml"] = 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",
+ ["map/hexes.json"] = MovementTests.Board(),
+ ["corridors.yaml"] = "corridors: []\n",
+ }), events));
+
+ /// <summary>A game on <paramref name="date"/> with a soldier on (3, 0), an enemy on (2, 0), and the truce cards
+ /// answered as given.</summary>
+ static GameState State(Content c, DateTime date, params (string Event, string Option)[] chosen)
+ {
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ s.Date = date;
+ s.Units.Add(1, new Unit(1, "soldier", 3, 0, side: "israel", strength: 5));
+ s.Units.Add(2, new Unit(2, "enemy", 2, 0, side: "egypt", strength: 3));
+ foreach (var (e, o) in chosen) s.ChosenOptions[e] = o;
+ return s;
+ }
+
+ static StepResult Step(Content c, GameState s, params Command[] cmds) => Simulation.Step(c, s, cmds);
+
+ // R-COMBAT-009: an attack order is refused with "A truce is in force" while a truce the player accepted is in
+ // force, and the state is untouched.
+ [Theory]
+ [InlineData("1948-06-15", "first_truce", "accept")] // inside the first truce
+ [InlineData("1948-09-15", "second_truce", "comply")] // inside the second truce
+ public void AnAcceptedTruceRefusesAttacks(string date, string ev, string option)
+ {
+ var c = Load();
+ var s = State(c, DateTime.Parse(date), (ev, option));
+ var r = Step(c, s, new UnitOrder(1, Combat.Attack, 2, 0));
+ Assert.Equal("A truce is in force", Assert.Single(r.Rejected).Reason);
+ Assert.Equal("", r.State.Units[1].Order);
+ }
+
+ // R-COMBAT-009: the truce binds from accepting the card, to the turn that covers its end (owner ruling 1, 22 Oct
+ // 2026: a complying player attacks again from the 15 October 1948 turn). A refused or defied card binds nothing,
+ // and no answer binds nothing.
+ [Theory]
+ [InlineData("1948-07-15", "first_truce", "accept")] // the first truce ended on 8 July
+ [InlineData("1948-10-15", "second_truce", "comply")] // the second truce's last day: attacks are back
+ [InlineData("1948-06-15", "first_truce", "refuse")] // a refused card binds nothing
+ [InlineData("1948-09-15", "second_truce", "defy")]
+ [InlineData("1948-06-15", null, null)] // no card answered yet
+ public void OutsideAnAcceptedTruceAttacksStand(string date, string? ev, string? option)
+ {
+ var c = Load();
+ var s = ev == null ? State(c, DateTime.Parse(date)) : State(c, DateTime.Parse(date), (ev, option!));
+ Assert.Empty(Step(c, s, new UnitOrder(1, Combat.Attack, 2, 0)).Rejected);
+ }
+
+ // R-COMBAT-009: movement and the other standing orders stay allowed inside a truce.
+ [Fact]
+ public void ATruceAllowsMovementAndFortify()
+ {
+ var c = Load();
+ var s = State(c, new DateTime(1948, 6, 15), ("first_truce", "accept"));
+ Assert.Empty(Step(c, s, new Move(1, 4, 0)).Rejected);
+ Assert.Empty(Step(c, s, new UnitOrder(1, Orders.Fortify)).Rejected);
+ }
+
+ /// <summary>R-COMBAT-009: the player's accepted truce binds the player's orders only - an enemy attack order on
+ /// the same turn is untouched (R-ENEMY-006's own date-driven guard is the enemy side's).</summary>
+ [Fact]
+ public void AnAcceptedTruceDoesNotBindTheEnemy()
+ {
+ var c = Load();
+ var s = State(c, new DateTime(1948, 6, 15), ("first_truce", "accept"));
+ var why = new List<Cause>();
+ Assert.Null(Combat.Give(c, s, 2, 3, 0, why, enemy: true));
+ Assert.Equal(Combat.Attack, s.Units[2].Order);
+ }
+
+ /// <summary>R-COMBAT-009: the unit card asks <see cref="Combat.Check"/> which hexes to offer (#754) - inside an
+ /// accepted truce it answers "A truce is in force" (the card hides Attack), and null for the same order once the
+ /// window has ended.</summary>
+ [Theory]
+ [InlineData("1948-06-15", "A truce is in force")] // inside the accepted first truce
+ [InlineData("1948-07-15", null)] // the first truce ended on 8 July
+ public void TheUnitCardsCheckReadsTheTruce(string date, string? expected)
+ {
+ var c = Load();
+ var s = State(c, DateTime.Parse(date), ("first_truce", "accept"));
+ Assert.Equal(expected, Combat.Check(c, s, 1, 2, 0));
+ }
+
+ // R-COMBAT-009 (owner ruling 2): accepting a truce ends and clears the player's standing attacks, with a line;
+ // fortify and the enemy's orders are untouched. Choosing to fight on keeps them.
+ [Fact]
+ public void AcceptingATruceEndsAQueuedAttack()
+ {
+ var c = Load(TruceEvents);
+ var s = State(c, new DateTime(1948, 6, 15));
+ s.Units[1] = new Unit(1, "soldier", 3, 0, side: "israel", strength: 5, order: Combat.Attack, orderTarget: "2,0");
+ s.Units[2] = new Unit(2, "enemy", 2, 0, side: "egypt", strength: 3, order: Combat.Attack, orderTarget: "3,0");
+
+ s.PendingEvents.Add("first_truce");
+ var why = new List<Cause>();
+ Assert.Null(EventSystem.Choose(c, s, "first_truce", "accept", why));
+ Assert.Equal("", s.Units[1].Order);
+ Assert.Equal(Combat.Attack, s.Units[2].Order); // the enemy's guard is R-ENEMY-006's, at resolver step 1
+ Assert.Contains(why, w => w.Message.Contains("a truce is on"));
+
+ // And from here the player cannot order a new attack until the truce's end.
+ Assert.Equal("A truce is in force", Assert.Single(Step(c, s, new UnitOrder(1, Combat.Attack, 2, 0)).Rejected).Reason);
+
+ // Choosing to fight on keeps a queued attack.
+ var t = State(c, new DateTime(1948, 6, 15));
+ t.Units[1] = new Unit(1, "soldier", 3, 0, side: "israel", strength: 5, order: Combat.Attack, orderTarget: "2,0");
+ t.PendingEvents.Add("first_truce");
+ Assert.Null(EventSystem.Choose(c, t, "first_truce", "refuse", new List<Cause>()));
+ Assert.Equal(Combat.Attack, t.Units[1].Order);
+ }
+
+ /// <summary>The two truce cards as the fixture needs them: the accepting option and one that fights on. Fixture
+ /// texts, not the cards'.</summary>
+ static readonly Dictionary<string, string> TruceEvents = new Dictionary<string, string>
+ {
+ ["first_truce.yaml"] = @"
+id: first_truce
+title: The First Truce
+text: The Security Council has called for a cease-fire.
+office: prime_minister
+from: 1948-06-01
+options:
+ - id: accept
+ text: Accept the truce
+ historical: true
+ recommended: true
+ - id: refuse
+ text: Refuse the truce and keep fighting
+ alternative: { basis: design }
+",
+ ["second_truce.yaml"] = @"
+id: second_truce
+title: The Second Truce
+text: The Security Council has ordered a cease-fire.
+office: prime_minister
+from: 1948-07-15
+options:
+ - id: comply
+ text: Comply with the cease-fire
+ historical: true
+ recommended: true
+ - id: defy
+ text: Defy the order and keep fighting
+ alternative: { basis: design }
+",
+ };
+}
diff --git a/sim/Statecraft.Sim/Combat.cs b/sim/Statecraft.Sim/Combat.cs
index 427472a37..f20355373 100644
--- a/sim/Statecraft.Sim/Combat.cs
+++ b/sim/Statecraft.Sim/Combat.cs
@@ -53,6 +53,36 @@ namespace Statecraft.Sim
/// <summary>R-COMBAT-007, R-COMBAT-008: the percent of its strength a unit fights at, its type's combat_percent or 100.</summary>
static long Factor(Content c, Unit u) => TypeOf(c, u)?.CombatPercent ?? 100;
+ /// <summary>R-COMBAT-009: the truce cards and the ends of their windows, half-open like R-ENEMY-006's (Q-WAR-3;
+ /// owner, 22 October 2026, #750): from accepting first_truce to 8 July 1948, and from accepting second_truce to
+ /// 15 October 1948, the sourced dates of first_truce.yaml, ten_days.yaml, second_truce.yaml and
+ /// operation_yoav.yaml. The player's side is bound from accepting the card, not by date alone: a refused or
+ /// defied card binds nothing.</summary>
+ internal static readonly (string Event, string Option, DateTime Until)[] PlayerTruces =
+ {
+ ("first_truce", "accept", new DateTime(1948, 7, 8)),
+ ("second_truce", "comply", new DateTime(1948, 10, 15)),
+ };
+
+ /// <summary>R-COMBAT-009: whether a truce the player accepted is in force on <see cref="GameState.Date"/> (the
+ /// turn's first day, the date the HUD shows): until the turn that covers the window's end, so a complying
+ /// player attacks again from the 15 October 1948 turn (owner ruling 1, 22 October 2026, #750).</summary>
+ internal static bool TruceInForce(GameState s) =>
+ PlayerTruces.Any(t => s.Date < t.Until && s.ChosenOptions.TryGetValue(t.Event, out var o) && o == t.Option);
+
+ /// <summary>R-COMBAT-009: accepting a truce ends and clears every standing attack of the player's, with a
+ /// line, the same as the enemy side's (owner ruling 2, 22 October 2026, #750; R-ENEMY-006).</summary>
+ internal static void EndAttacksForTruce(GameState s, List<Cause> why)
+ {
+ foreach (var id in s.Units.Keys.ToList())
+ {
+ var u = s.Units[id];
+ if (!Player(u) || u.Order != Attack) continue;
+ s.Units[id] = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, "", "");
+ why.Add(new Cause("map", id.ToString(CultureInfo.InvariantCulture), 0, $"Unit {id}'s attack on hex {u.OrderTarget} ends: a truce is on"));
+ }
+ }
+
/// <summary>The enemy military units on (q, r), seen from <paramref name="attacker"/>'s team, in id order.</summary>
static List<Unit> Defenders(GameState s, Unit attacker, int q, int r) =>
s.Units.Values.Where(x => x.Q == q && x.R == r && Military(x) && Player(x) != Player(attacker)).ToList();
@@ -60,8 +90,8 @@ namespace Statecraft.Sim
/// <summary>R-COMBAT-001's refusals: null when <see cref="Give"/> takes the attack on (q, r), else the reason shown to
/// the player. Changes nothing: the unit card asks it for each enemy hex before it offers that hex (#754). Refused for
/// an unknown unit, a halutz, an enemy unit, no hex, the attack it already has, a hex not next to it (artillery: beyond
- /// its range) or with no enemy unit, or fewer Arms than one attack takes on top of the player's other attacks already
- /// ordered (Q-COMBAT-4). With <paramref name="enemy"/> the enemy AI orders its own unit through the same checks, the
+ /// its range) or with no enemy unit, a truce the player accepted (R-COMBAT-009), or fewer Arms than one attack takes
+ /// on top of the player's other attacks already ordered (Q-COMBAT-4). With <paramref name="enemy"/> the enemy AI orders its own unit through the same checks, the
/// sides swapped, and pays no Arms (R-ENEMY-001; Q-ENEMY-4).</summary>
public static string? Check(Content c, GameState s, int unitId, int? q, int? r, bool enemy = false)
{
@@ -69,6 +99,7 @@ namespace Statecraft.Sim
if (!Military(u)) return "Only a military unit takes that order";
if (Player(u) == enemy) return "That unit is not yours";
if (q == null || r == null) return "An attack names a hex";
+ if (!enemy && TruceInForce(s)) return "A truce is in force"; // R-COMBAT-009
var target = Hex(q.Value, r.Value);
if (u.Order == Attack && u.OrderTarget == target) return "That unit already has that order";
if (!InReach(c, u, q.Value, r.Value)) return Guns(c, u) ? "That hex is beyond the unit's range" : "That hex is not next to the unit";
diff --git a/sim/Statecraft.Sim/EventSystem.cs b/sim/Statecraft.Sim/EventSystem.cs
index d59ef8db0..7812b2521 100644
--- a/sim/Statecraft.Sim/EventSystem.cs
+++ b/sim/Statecraft.Sim/EventSystem.cs
@@ -147,6 +147,8 @@ namespace Statecraft.Sim
why.Add(new Cause("events", kv.Key, kv.Value, $"{PlayerText.Target(c, kv.Key)} set to {PlayerText.Percent(kv.Value)} ({title})"));
}
if (o.SetRung.HasValue) SecuritySystem.SetRung(c, s, o.SetRung.Value, why);
+ // R-COMBAT-009: accepting a truce ends the player's standing attacks (owner ruling 2, 22 Oct 2026, #750).
+ if (Combat.PlayerTruces.Any(t => t.Event == eventId && t.Option == o.Id)) Combat.EndAttacksForTruce(s, why);
// R-POW-004: an exchange card returns its front's prisoners, whichever way it was resolved (it has one option).
if (Get(c, eventId).Prisoners is var front && front != "") Prisoners.Return(c, s, front, why);
}