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.

Loader: an objective's card waits for nothing but its objective (#2804 item 6) (#2871)

Beriedc12c2be57b
diff --git a/changelog.d/2804-objective-card-window.md b/changelog.d/2804-objective-card-window.md
new file mode 100644
index 000000000..63ed894d4
--- /dev/null
+++ b/changelog.d/2804-objective-card-window.md
@@ -0,0 +1,5 @@
+### Fixed
+
+- Content checks: the loader now refuses an objective's card that opens after the game's start, closes before its end,
+ or has `requires` or `conditions`, naming the file and field. Such a card could fire late or never once its objective
+ is completed (R-OBJ-003). No shipped card is affected.
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 83cd122d9..ba1b129fd 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -410,7 +410,7 @@ R-OBJ-001: An objective (`objectives.yaml`) names its condition, `completes_when
R-OBJ-002: Recording a standalone objective adds `objective_points + min(objective_bonus_cap, objective_bonus_per_month * monthsEarly)` to the score, once. `monthsEarly` is `max(0, monthsFromHistory)`, and `monthsFromHistory` counts calendar months from the completion's month to the reference date's month, `(y2 - y1) * 12 + (m2 - m1)`: 0 in the same month ("on time, as in history"), negative when late (owner's card wording, #379, 14 October 2026). Late costs nothing. The owner set 100 points (D-B6) and +5 a month capped at +60 (D-B2) on 14 October 2026 (#456); they are balance values and stay tunable, as `rules.yaml` design values (R-LOOP-005). R-OBJ-006 says when a multipart objective receives the same base. The rules are those of the date the turn starts from (docs/determinism.md, "Rules per era"), so a turn that ends on the next era's first day scores with the era it started in.
-R-OBJ-003: An event with `objective:` is that objective's card. It is eligible only once its objective is recorded, so it fires once, at the end of the turn the objective is completed in, and never in the legacy loop. It takes no soft-event slot, like a Deport card (owner, 4 November 2026, #2605: "Always that turn (Recommended)"). That holds on the turn that ends the game too (the dated end of R-LOOP-004, or a defeat): its objective cards, and the card of any objective recorded earlier that has not fired yet, fire then, without the cap, and no other event does; and Unity shows them before the end screen (owner, 4 November 2026, #2536: "Show the card (Recommended)"). Answering one there is no order and changes nothing: the score is the one step 11 recorded. A card has exactly one option, and an objective and its card name each other (the loader checks both). An unanswered card resolves to its option without drawing from the RNG.
+R-OBJ-003: An event with `objective:` is that objective's card. It is eligible only once its objective is recorded, so it fires once, at the end of the turn the objective is completed in, and never in the legacy loop. It takes no soft-event slot, like a Deport card (owner, 4 November 2026, #2605: "Always that turn (Recommended)"). That holds on the turn that ends the game too (the dated end of R-LOOP-004, or a defeat): its objective cards, and the card of any objective recorded earlier that has not fired yet, fire then, without the cap, and no other event does; and Unity shows them before the end screen (owner, 4 November 2026, #2536: "Show the card (Recommended)"). Answering one there is no order and changes nothing: the score is the one step 11 recorded. A card has exactly one option, an objective and its card name each other, and the card waits for nothing else: its window runs from the game's start to its end (or its era's, since an event may not span an era boundary), with no `requires` or `conditions` (the loader checks all three, #2804). An unanswered card resolves to its option without drawing from the RNG.
R-OBJ-004: An objective may instead name `completes_when: { absorbed: { population_at_least, overflow_at_most, employed_at_least } }` (D-B4; owner, 18 October 2026, #738, option (a)). It holds at step 11 once the population (`GameState.TotalPopulation`, the national count as step 11 reads it, before the turn's population step, annexed residents included, R-CITY-008) is at or above `population_at_least`, and then the cities' overflow (R-HOUSE-002), summed, is at most `overflow_at_most` of their housed people (R-HOUSE-003), summed, and their employed, summed, are at least `employed_at_least` of their civilians and craftsmen, summed (as R-CITY-005 counts them; owner, 3 November 2026, #1714: "Both rulesets (Recommended)", so gdd-0.1 and gdd-0.3 alike). Refugees waiting do not count: each turn's arrivals (step 9) wait at step 11, after housing (step 8). The gate keeps the census start values (41% employed, no overflow) from completing it on the first turn. Sums are integers, compared with the decimal share, so city order cannot change the result. An objective names exactly one kind; all three keys are required (a missing key is never read as 0), the shares are from 0 to 1 and the population above 0 (the loader). Recorded and scored as R-OBJ-001 and R-OBJ-002 say; its card follows R-OBJ-003. The shipped milestone, 1,000,000, stays Q-ABS-1's sourced number for the Jewish population; since the total counts annexed residents (owner, 4 November 2026, "Count them everywhere", #2620), a game that annexes a stayed town may reach it earlier.
diff --git a/sim/Statecraft.Sim.Tests/ObjectivesTests.cs b/sim/Statecraft.Sim.Tests/ObjectivesTests.cs
index 24d6f6ad8..ebdc5a7be 100644
--- a/sim/Statecraft.Sim.Tests/ObjectivesTests.cs
+++ b/sim/Statecraft.Sim.Tests/ObjectivesTests.cs
@@ -784,6 +784,10 @@ eras:
new object[] { "objectives.yaml", Objective("card: first_card", "card: no_card"), Card, "objectives.yaml", "objectives[first_goal].card", "unknown event 'no_card'" },
new object[] { "objectives.yaml", ObjectivesYaml, Card.Replace("objective: first_goal\n", ""), "events/first_card.yaml", "events[first_card].objective", "must be 'first_goal'" },
new object[] { "objectives.yaml", ObjectivesYaml, TwoOptions, "events/first_card.yaml", "events[first_card].options", "exactly one option" },
+ new object[] { "objectives.yaml", ObjectivesYaml, Card.Replace("from: 1948-05-15", "from: 1948-06-15"), "events/first_card.yaml", "events[first_card].from", "opens at the game's start, or its era's (1948-05-15)" },
+ new object[] { "objectives.yaml", ObjectivesYaml, Card.Replace("to: 1957-01-01", "to: 1956-12-15"), "events/first_card.yaml", "events[first_card].to", "stays open to the game's end, or its era's (1957-01-01)" },
+ new object[] { "events/other.yaml", Card.Replace("id: first_card", "id: other").Replace("objective: first_goal\n", ""), Card.Replace("objective: first_goal\n", "objective: first_goal\nrequires: [{ event: other, option: continue }]\n"), "events/first_card.yaml", "events[first_card].requires", "waits for nothing but its objective" },
+ new object[] { "objectives.yaml", ObjectivesYaml, Card.Replace("objective: first_goal\n", "objective: first_goal\nconditions: [{ indicator: morale, max: 0.9 }]\n"), "events/first_card.yaml", "events[first_card].conditions", "waits for nothing but its objective" },
new object[] { "objectives.yaml", "objectives: []\n", Card, "events/first_card.yaml", "events[first_card].objective", "unknown objective 'first_goal'" },
new object[] { "objectives.yaml", Objective("site_built: site_a", "site_built: nowhere"), Card, "objectives.yaml", "objectives[first_goal].completes_when.site_built", "unknown site 'nowhere'" },
new object[] { "objectives.yaml", Objective("reference_date: 1949-06-12", "reference_date: 1949-06-08"), Card, "objectives.yaml", "objectives[first_goal].reference_date", "must be 1949-06-12, the founding date of site 'site_a'" },
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index 4857ce276..74162cec3 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -1839,6 +1839,21 @@ namespace Statecraft.Sim
if (o.PartOf != "" && (o.ReferenceDate < c.Rules.Start || o.ReferenceDate >= c.End))
throw new ContentException(ObjectivesFileName, at + ".reference_date",
FormattableString.Invariant($"must be inside the MVP ({c.Rules.Start:yyyy-MM-dd} to {c.End:yyyy-MM-dd})"));
+ // R-OBJ-003: the card fires at the end of the turn its objective is completed in, so nothing but the objective may
+ // hold it back: its window runs from the game's start to its end, and it has no requires or conditions. An event
+ // may not span an era boundary (EventRules), so with several eras the card's own era bounds it instead.
+ // EventRules has already checked the card exists; only the GDD loop fires it, so only it checks this.
+ var card = c.Events.First(e => e.Id == o.Card);
+ string CardField(string key) => $"events[{card.Id}].{key}";
+ var era = c.EraAt(card.From);
+ var opens = era?.From ?? c.Rules.Start;
+ var closes = era != null && era.To < c.End ? era.To : c.End;
+ if (card.From > opens)
+ throw new ContentException(card.File, CardField("from"), FormattableString.Invariant($"an objective's card opens at the game's start, or its era's ({opens:yyyy-MM-dd}), so it fires the turn its objective is completed"));
+ if (card.To is DateTime to && to < closes)
+ throw new ContentException(card.File, CardField("to"), FormattableString.Invariant($"an objective's card stays open to the game's end, or its era's ({closes:yyyy-MM-dd}), so it fires the turn its objective is completed"));
+ foreach (var (key, set) in new[] { ("requires", card.Requires.Count > 0), ("conditions", card.Conditions.Count > 0) })
+ if (set) throw new ContentException(card.File, CardField(key), "an objective's card waits for nothing but its objective");
if (o.CompletesWhen!.Absorbed != null) continue; // R-OBJ-004 has no site; the GDD loop always has cities
if (o.CompletesWhen.CorridorComplete != "")
{