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: rejoin, a consequence card's way back to the record (R-ALT-009, refs #951) (#978)

Eyal Golanb9077acd7ce5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1cc9c0103..333c6df2a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
## [0.1.0] - 2026-10-18
### Added
+- Events: a consequence card's option can rejoin the record (`rejoin`, R-ALT-009; refs #951, #939). No content uses it yet.
- Events: consequence cards (`kind: consequence`) for the roads not taken. They are soft, follow only a road
contemporaries proposed or debated (the Ferguson test), lie at most 2 cards deep, carry the sensitive tags of the road
they follow and take the first soft slots of a turn (R-ALT-005 to R-ALT-008, R-ALT-012; refs #950, #939). No content
diff --git a/content/schema/event.schema.json b/content/schema/event.schema.json
index af2f55564..3609be2b3 100644
--- a/content/schema/event.schema.json
+++ b/content/schema/event.schema.json
@@ -80,6 +80,7 @@
"text": { "type": "string", "minLength": 1 },
"historical": { "type": "boolean" },
"recommended": { "type": "boolean" },
+ "rejoin": { "$ref": "#/definitions/id", "description": "A consequence card's option that returns the course to the record of this event (R-ALT-009)." },
"effects": {
"type": "array",
"items": {
diff --git a/docs/WRITING_EVENTS.md b/docs/WRITING_EVENTS.md
index 39f383b31..078f9de69 100644
--- a/docs/WRITING_EVENTS.md
+++ b/docs/WRITING_EVENTS.md
@@ -130,6 +130,7 @@ requires: [{ event: parent_event, option: road_not_taken }] # or { event: pare
options:
- id: hold
text: ...
+ rejoin: parent_event # optional: this answer returns later cards to the recorded course
alternative: { basis: debated, by: ..., date: ..., sources: [...] } # every option carries one
```
@@ -148,6 +149,12 @@ The loader refuses a consequence card that:
Consequence cards take a turn's soft slots before the other soft events (R-ALT-008). They never fire in the historical
run (R-ALT-012), so `EventRetimingTests` counts only the other events.
+An option on a consequence card may `rejoin` the event whose alternative road the card follows, provided that event has
+a historical option (R-ALT-009). Choosing it makes requirements on that historical option hold again, but only later
+cards whose absolute windows are still open can fire. It does not erase the option the player actually chose: a
+`diverged: true` requirement on the same event remains true. The loader refuses `rejoin` on any other kind of event, an
+unknown or self target, or a target whose alternative road the card does not follow.
+
### requires
```yaml
@@ -182,6 +189,7 @@ Each option has:
| `grant_units` | no | GDD loop only. A list of `{ type, n, at }`: see "grant_units and city_effects". |
| `city_effects` | no | GDD loop only. A list of `{ city, field, delta }`: see "grant_units and city_effects". |
| `alternative` | no (required later, #949) | On an option that did not happen: who put it forward, on what record. See below. |
+| `rejoin` | no | Consequence cards only. The id of the event whose road the card follows; choosing this option returns later cards to the recorded course (R-ALT-009). See "kind". |
An event needs at least one option. `historical` is a statement of fact and needs a source; `recommended` is a game
design choice and does not.
@@ -341,6 +349,8 @@ Errors are printed as `file: field: message`. These are the messages you are mos
| `only a consequence card may follow a consequence card` | A historical event requires a consequence card. |
| `a consequence card is not an objective's card` | A consequence card has `objective:`. |
| `must be historical, consequence or reconvergence` | `kind` is another word. |
+| `only a consequence card rejoins the record` | An option of another kind of event has `rejoin`. |
+| `rejoins only an event whose road this card follows` | `rejoin` names an event the card does not follow on a road not taken, or one with no historical option. |
| `is already required` | Two `requires` entries name the same event (they could never both hold, or one is redundant). |
A full message looks like this (an effect target misspelled `securty`):
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 494262268..b201c1ce5 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -174,7 +174,7 @@ R-EVT-003: An event the player leaves unanswered at End Turn is delegated to its
R-EVT-004: An option's effects apply when it is chosen or delegated, on that turn, and never later; an option has no delayed form, and the loader refuses an unknown key such as `delay` (Q-EVT-3).
-R-EVT-005: One sim helper, `EventSystem.OptionEffects`, lists every effect of an option in the order choosing it applies them: the numeric effects, the unit grants and city effects (R-EFX-006), the policies it sets (by id), then the security level, each with the option's own amount (Q-EVT-4). The event card will show this list (GDD Phase 7 PR 8), so no number will be computed in Unity.
+R-EVT-005: One sim helper, `EventSystem.OptionEffects`, lists every effect of an option in the order choosing it applies them: the numeric effects, the unit grants and city effects (R-EFX-006), the policies it sets (by id), then the security level, then the way back to the record (`rejoin`, R-ALT-009), each with the option's own amount (Q-EVT-4). The event card will show this list (GDD Phase 7 PR 8), so no number will be computed in Unity.
## Alternate timelines
@@ -194,4 +194,6 @@ R-ALT-007: A consequence card carries every sensitive tag (case aside) of each e
R-ALT-008: Consequence cards take a turn's soft slots before the other soft events, then by `from` and id (Q-ALT-14). A `front_quiet` armistice (Q-EVT-1, Phase 5 PR 13) will come before them. With no consequence card eligible the order is unchanged.
+R-ALT-009: An option of a consequence card may `rejoin` an event whose road the card follows (and which has a historical option). Once it is chosen, a requirement on that event's historical option holds, so the record's later cards fire again if their windows are still open. The event's own chosen option is not rewritten, and `diverged: true` on it still holds.
+
R-ALT-012: The historical run (the reference player's orders from 15 May 1948 to 15 January 1952) raises no consequence card and diverges nowhere.
diff --git a/sim/Statecraft.Sim.Tests/AlternateTimelineTests.cs b/sim/Statecraft.Sim.Tests/AlternateTimelineTests.cs
index 3a7c58681..fa6d36c16 100644
--- a/sim/Statecraft.Sim.Tests/AlternateTimelineTests.cs
+++ b/sim/Statecraft.Sim.Tests/AlternateTimelineTests.cs
@@ -130,6 +130,101 @@ options:
sources: [{ url: ""https://example.org/cabinet"", checked: 2026-10-17 }]
";
+ static string WithRejoin => Consequence.Replace(" text: Hold the course\n", " text: Hold the course\n rejoin: parent\n");
+
+ internal const string RecordFollowUp = @"
+id: on_record
+title: On the record
+text: 'The next real decision.'
+from: 1948-07-01
+to: 1948-09-15
+requires: [{ event: parent, option: record }]
+options:
+ - id: ok
+ text: Ok
+";
+
+ [Fact]
+ // R-ALT-009
+ public void ARejoinReopensOnlyCardsStillInsideTheirWindow()
+ {
+ var c = Load(("parent.yaml", Parent), ("after_road.yaml", WithRejoin), ("on_record.yaml", RecordFollowUp));
+ var s = NewState(c);
+ s.ChosenOptions["parent"] = "road"; s.FiredEvents.Add("parent");
+ s.Date = new DateTime(1948, 7, 15);
+ EventSystem.Trigger(c, s, new List<Cause>(), new DateTime(1948, 6, 15));
+ Assert.DoesNotContain("on_record", s.FiredEvents); // off the record: the follow-up waits
+ Assert.Null(EventSystem.Choose(c, s, "after_road", "hold", new List<Cause>()));
+ Assert.True(Timeline.Rejoined(c, s, "parent"));
+ EventSystem.Trigger(c, s, new List<Cause>(), new DateTime(1948, 6, 15));
+ Assert.Contains("on_record", s.FiredEvents); // its window is still open
+
+ var late = NewState(c);
+ late.ChosenOptions["parent"] = "road"; late.ChosenOptions["after_road"] = "hold";
+ late.FiredEvents.Add("parent"); late.FiredEvents.Add("after_road");
+ late.Date = new DateTime(1948, 10, 15);
+ EventSystem.Trigger(c, late, new List<Cause>(), new DateTime(1948, 9, 15));
+ Assert.DoesNotContain("on_record", late.FiredEvents); // its window closed on 15 September: no resurrection
+ }
+
+ [Fact]
+ // R-ALT-009
+ public void TheTimelineKeepsTheRoadAfterARejoin()
+ {
+ var c = Load(("parent.yaml", Parent), ("after_road.yaml", WithRejoin));
+ var s = NewState(c);
+ s.ChosenOptions["parent"] = "road";
+ Assert.False(Timeline.Rejoined(c, s, "parent")); // no rejoin until the card's option is chosen
+ Assert.False(Timeline.Met(c, s, new EventRequirement { Event = "parent", Option = "record" }));
+ s.ChosenOptions["after_road"] = "hold";
+ Assert.False(Timeline.Rejoined(c, s, "after_road")); // only the event named by `rejoin`
+ Assert.Equal("road", s.ChosenOptions["parent"]); // the record of the road is not rewritten
+ Assert.True(Timeline.Diverged(c, s, "parent"));
+ Assert.True(Timeline.Met(c, s, new EventRequirement { Event = "parent", Option = "record" }));
+ Assert.True(Timeline.Met(c, s, new EventRequirement { Event = "parent", Option = "road" })); // and the road itself still holds
+ Assert.False(Timeline.Met(c, s, new EventRequirement { Event = "parent", Option = "elsewhere" })); // only the record's own option
+ }
+
+ // R-ALT-009
+ [Theory]
+ [InlineData("rejoin: parent", "rejoin: nowhere", "rejoin", "unknown event 'nowhere'")]
+ [InlineData("rejoin: parent", "rejoin: after_road", "rejoin", "a card cannot rejoin itself")]
+ public void ABadRejoinIsALoadError(string from, string to, string field, string message)
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("after_road.yaml", WithRejoin.Replace(from, to))));
+ Assert.Equal("events[after_road].options[hold]." + field, ex.Field);
+ Assert.Contains(message, ex.Message);
+ }
+
+ [Fact]
+ // R-ALT-009
+ public void OnlyAConsequenceCardRejoinsAndOnlyARoadItFollows()
+ {
+ var other = "id: other\ntitle: Other\ntext: x\nfrom: 1948-06-01\noptions:\n - id: a\n text: A\n historical: true\n - id: b\n text: B\n alternative: { basis: design }\n";
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("other.yaml", other), ("after_road.yaml", WithRejoin.Replace("rejoin: parent", "rejoin: other"))));
+ Assert.Contains("rejoins only an event whose road this card follows", ex.Message);
+ var onRecord = RecordFollowUp.Replace(" text: Ok\n", " text: Ok\n rejoin: parent\n");
+ var ex2 = Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("on_record.yaml", onRecord)));
+ Assert.Contains("only a consequence card rejoins", ex2.Message);
+ // A consequence card has no historical option, so a card that follows one has no record to rejoin there.
+ var deeper = Consequence.Replace("id: after_road", "id: deeper").Replace("{ event: parent, option: road }", "{ event: after_road, option: hold }")
+ .Replace(" text: Hold the course\n", " text: Hold the course\n rejoin: after_road\n");
+ var ex3 = Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("after_road.yaml", Consequence), ("deeper.yaml", deeper)));
+ Assert.Equal("events[deeper].options[hold].rejoin", ex3.Field);
+ Assert.Contains("which has a historical option", ex3.Message);
+ }
+
+ [Fact]
+ // R-ALT-009, R-EVT-005: the card's effect list names the way back.
+ public void TheEffectListNamesTheRejoin()
+ {
+ var c = Load(("parent.yaml", Parent), ("after_road.yaml", WithRejoin));
+ var o = c.Events.Single(x => x.Id == "after_road").Options.Single();
+ var line = Assert.Single(EventSystem.OptionEffects(c, NewState(c), o));
+ Assert.Equal(("rejoin", 0.0), (line.Target, line.Delta));
+ Assert.Equal("Returns to the recorded course: Parent", line.Message);
+ }
+
const string RecordToo = "options:\n - id: record_too\n text: As recorded\n historical: true\n";
static ContentException LoadError(string consequence) =>
diff --git a/sim/Statecraft.Sim.Tests/EventRulesGddTests.cs b/sim/Statecraft.Sim.Tests/EventRulesGddTests.cs
index 96108ab93..1dea0de50 100644
--- a/sim/Statecraft.Sim.Tests/EventRulesGddTests.cs
+++ b/sim/Statecraft.Sim.Tests/EventRulesGddTests.cs
@@ -206,7 +206,8 @@ options:
{
var expected = o.Effects.Select(fx => (fx.Target, fx.Delta))
.Concat(o.SetPolicy.OrderBy(k => k.Key, StringComparer.Ordinal).Select(k => (k.Key, k.Value)))
- .Concat(o.SetRung.HasValue ? new[] { ("rung", (double)o.SetRung.Value) } : new (string, double)[0]);
+ .Concat(o.SetRung.HasValue ? new[] { ("rung", (double)o.SetRung.Value) } : new (string, double)[0])
+ .Concat(o.Rejoin != "" ? new[] { ("rejoin", 0.0) } : new (string, double)[0]);
Assert.Equal(expected, EventSystem.OptionEffects(C, s, o).Select(l => (l.Target, l.Delta)));
checkedOptions++;
}
diff --git a/sim/Statecraft.Sim.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
index 44f54a3d4..4fa7a19e7 100644
--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs
+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
@@ -50,6 +50,40 @@ public class SaveGameTests
Assert.Equal(played.Previous!.Hash(), loaded.Previous!.Hash()); // "since last turn" survives a load
}
+ [Fact]
+ // R-ALT-009
+ public void ARejoinedRoadRoundTripsThroughASave()
+ {
+ var consequence = AlternateTimelineTests.Consequence.Replace(" text: Hold the course\n", " text: Hold the course\n rejoin: parent\n");
+ var c = ContentLoader.Load(Fixture.Write(events: new Dictionary<string, string>
+ {
+ ["parent.yaml"] = AlternateTimelineTests.Parent,
+ ["after_road.yaml"] = consequence,
+ ["on_record.yaml"] = AlternateTimelineTests.RecordFollowUp,
+ }));
+ var played = GameSession.New(c, 1, Mode.Historical);
+ // The fixture's turns are a week long: wait for each card, then answer it.
+ void Answer(string id, string option)
+ {
+ for (int i = 0; i < 20 && !played.State.PendingEvents.Contains(id); i++) played.Step(new Command[0]);
+ Assert.Contains(id, played.State.PendingEvents);
+ Assert.Empty(played.Step(new Command[] { new ChooseEventOption(id, option) }).Rejected);
+ }
+ Answer("parent", "road");
+ Answer("after_road", "hold");
+ for (int i = 0; i < 20 && !played.State.FiredEvents.Contains("on_record"); i++) played.Step(new Command[0]);
+ Assert.Equal("road", played.State.ChosenOptions["parent"]);
+ Assert.Equal("hold", played.State.ChosenOptions["after_road"]);
+ Assert.True(Timeline.Rejoined(c, played.State, "parent"));
+ Assert.Contains("on_record", played.State.FiredEvents);
+
+ var loaded = GameSession.Load(c, played.Save.Write(), out var warnings);
+ Assert.Empty(warnings);
+ Assert.Equal(played.State.Hash(), loaded.State.Hash());
+ Assert.Equal(played.State.ChosenOptions.OrderBy(kv => kv.Key), loaded.State.ChosenOptions.OrderBy(kv => kv.Key));
+ Assert.True(Timeline.Rejoined(c, loaded.State, "parent"));
+ }
+
/// <summary>#398 review S1: a load also keeps the step before the last, so a change that compares two steps (the top
/// bar's arrivals) is the one the player saw before the reload. A new session and one step have none.</summary>
[Fact]
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 7b1e5d9ac..308c86fae 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -718,6 +718,8 @@ namespace Statecraft.Sim
public List<CityEffect> CityEffects { get; set; } = new List<CityEffect>();
/// <summary>Who put this non-historical option forward, and on what record (R-ALT-003). Null when absent.</summary>
public OptionAlternative? Alternative { get; set; }
+ /// <summary>The event whose historical course this consequence option rejoins (R-ALT-009), or empty.</summary>
+ public string Rejoin { get; set; } = "";
}
/// <summary>An option's grant of <see cref="N"/> units of a unit_types.yaml type of kind unit (R-EFX-003). They stand at
diff --git a/sim/Statecraft.Sim/EventRules.cs b/sim/Statecraft.Sim/EventRules.cs
index 0a38c3bb4..9ec23119a 100644
--- a/sim/Statecraft.Sim/EventRules.cs
+++ b/sim/Statecraft.Sim/EventRules.cs
@@ -208,6 +208,15 @@ namespace Statecraft.Sim
string F(string field) => $"events[{e.Id}].{field}";
if (e.Kind != EventKinds.Historical && e.Kind != EventKinds.Consequence && e.Kind != EventKinds.Reconvergence)
throw new ContentException(e.File, F("kind"), $"'{e.Kind}' must be historical, consequence or reconvergence");
+ foreach (var o in e.Options.Where(o => o.Rejoin != ""))
+ {
+ var at = F($"options[{o.Id}].rejoin");
+ if (e.Kind != EventKinds.Consequence) throw new ContentException(e.File, at, "only a consequence card rejoins the record");
+ if (o.Rejoin == e.Id) throw new ContentException(e.File, at, "a card cannot rejoin itself");
+ var target = c.Events.FirstOrDefault(x => x.Id == o.Rejoin) ?? throw new ContentException(e.File, at, $"unknown event '{o.Rejoin}'");
+ if (!target.Options.Any(x => x.Historical) || !e.Requires.Any(r => r.Event == target.Id && IsAlternativeRoad(c, r)))
+ throw new ContentException(e.File, at, "rejoins only an event whose road this card follows, and which has a historical option");
+ }
if (e.Kind != EventKinds.Consequence)
{
// Only a consequence card may follow one: the record never raises a consequence card, and a historical
diff --git a/sim/Statecraft.Sim/EventSystem.cs b/sim/Statecraft.Sim/EventSystem.cs
index 42edd5d57..d5f83023d 100644
--- a/sim/Statecraft.Sim/EventSystem.cs
+++ b/sim/Statecraft.Sim/EventSystem.cs
@@ -139,7 +139,7 @@ namespace Statecraft.Sim
FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {field.Replace('_', ' ')} {(delta > 0 ? "+" : "")}{delta}");
/// <summary>R-EVT-005: every effect of an option, in the order choosing it applies them (Resolve): the numeric
- /// effects, the unit grants and city effects (R-EFX-006), the policies it sets (by id), then the security level.
+ /// effects, the unit grants and city effects (R-EFX-006), the policies it sets (by id), the security level, then rejoin.
/// Each amount is the option's own; Resolve may apply less where an indicator meets its bound or the Food stock its floor, and rounds Food to whole units. The
/// event card will read this list (Q-EVT-4, owner 17 October 2026; Phase 7 PR 8), so no number is computed in Unity.</summary>
public static List<Cause> OptionEffects(Content c, GameState s, EventOption o)
@@ -151,6 +151,9 @@ namespace Statecraft.Sim
lines.AddRange(o.SetPolicy.Where(k => s.Policies.ContainsKey(k.Key)).OrderBy(k => k.Key, StringComparer.Ordinal)
.Select(k => new Cause("events", k.Key, k.Value, $"{PlayerText.Target(c, k.Key)} set to {PlayerText.Percent(k.Value)}")));
if (o.SetRung.HasValue) lines.Add(new Cause("events", "rung", o.SetRung.Value, FormattableString.Invariant($"Security level set to {o.SetRung.Value}")));
+ // R-ALT-009: the way back to the record is shown with the other effects (R-EVT-005).
+ if (o.Rejoin != "")
+ lines.Add(new Cause("events", "rejoin", 0, $"Returns to the recorded course: {Cabinet.Fill(c, s, c.Events.First(x => x.Id == o.Rejoin).Title, s.Date)}"));
return lines;
}
diff --git a/sim/Statecraft.Sim/Timeline.cs b/sim/Statecraft.Sim/Timeline.cs
index 788f36a8d..e06a5b6e3 100644
--- a/sim/Statecraft.Sim/Timeline.cs
+++ b/sim/Statecraft.Sim/Timeline.cs
@@ -19,11 +19,19 @@ namespace Statecraft.Sim
return historical != null && picked != historical.Id;
}
+ /// <summary>R-ALT-009: a consequence card's chosen option rejoined this event to the record.</summary>
+ public static bool Rejoined(Content c, GameState s, string eventId) =>
+ c.Events.Any(e => e.Kind == EventKinds.Consequence && s.ChosenOptions.TryGetValue(e.Id, out var o)
+ && e.Options.Any(x => x.Id == o && x.Rejoin == eventId));
+
/// <summary>R-ALT-001 and R-ALT-002: one requirement holds.</summary>
public static bool Met(Content c, GameState s, EventRequirement r)
{
if (r.Diverged) return Diverged(c, s, r.Event);
- return s.ChosenOptions.TryGetValue(r.Event, out var picked) && picked == r.Option;
+ if (!s.ChosenOptions.TryGetValue(r.Event, out var picked)) return false;
+ if (picked == r.Option) return true;
+ // R-ALT-009: after a rejoin, the record's own option counts as taken; `diverged` stays true.
+ return Rejoined(c, s, r.Event) && HistoricalOption(Get(c, r.Event))?.Id == r.Option;
}
/// <summary>R-ALT-001: every requirement of the event holds (true when it has none).</summary>