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.

content: offices with several holders; Yosef 1952–53 and Assaf 1956 (fixes #277) (#284)

agamrafaeli-instinct27527175f031
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6fe94892..ff95cc7d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
## [Unreleased]
### Added
+- An office can now have several holders at once (`several_holders: true` in offices.yaml): Minister without Portfolio
+ and the deputy ministers of Education. Adds Dov Yosef's term without portfolio (24 December 1952 to 15 June 1953)
+ and Ami Assaf as a second Deputy Minister of Education (from 11 June 1956). Event text, policies and effects cannot
+ name such an office, and the Cabinet refuses to appoint to it. The Cabinet screen shows a card for each holder. No
+ golden moves (#277).
- Rules per era (#58, second piece): the attention, economy, population, security, map-action and cabinet systems read
`RulesAt(date)` of the turn's starting date instead of `rules.yaml` directly, and the Defence and Info screens and the
HUD follow. With no `content/rules/<era>.yaml` files yet, nothing changes: the goldens do not move. A test fails if a
diff --git a/content/offices.yaml b/content/offices.yaml
index c81d13d58..c4c0bac0b 100644
--- a/content/offices.yaml
+++ b/content/offices.yaml
@@ -48,7 +48,7 @@ offices:
- { id: chief_of_staff, title: IDF Chief of the General Staff }
# The role first appeared in the Third Government (Peretz Naphtali, 8 October 1951): he.wiki "שר בלי תיק"; the
# Provisional, First and Second Governments' tables on en.wiki list none (checked 2026-10-11).
- - { id: minister_without_portfolio, title: Minister without Portfolio, from: 1951-10-08 }
+ - { id: minister_without_portfolio, title: Minister without Portfolio, from: 1951-10-08, several_holders: true }
# Established by the Transition Law of 16 February 1949 (he.wiki "נשיא מדינת ישראל", en.wiki "President of Israel",
# checked 2026-10-11; he.wiki "חוק המעבר" gives 16 or 17 February). Weizmann's 1948 office, President of the
# Provisional State Council, is a different office the game does not model.
@@ -57,7 +57,7 @@ offices:
# Sources and the start-date conflict are in research_notes/M3 content 1950-51/deputy-titles.md.
- { id: deputy_agriculture_minister, title: Deputy Minister of Agriculture, historical_only: true }
- { id: deputy_transportation_minister, title: Deputy Minister of Transportation, historical_only: true }
- - { id: deputy_education_minister, title: Deputy Minister of Education and Culture, historical_only: true }
+ - { id: deputy_education_minister, title: Deputy Minister of Education and Culture, historical_only: true, several_holders: true }
- { id: deputy_prime_minister, title: Deputy Prime Minister, historical_only: true }
# Deputy ministers of 1953-1956 (#26): dates from the Knesset records (KNS_PersonToPosition), see people.yaml.
- { id: deputy_religions_minister, title: Deputy Minister of Religions, historical_only: true }
diff --git a/content/people.yaml b/content/people.yaml
index 098375bb9..bdb73e549 100644
--- a/content/people.yaml
+++ b/content/people.yaml
@@ -446,6 +446,9 @@ people:
# en.wiki lists Trade and Industry and Justice; he.wiki lists only Trade and Industry clearly (research notes 1e).
# The Knesset records give Justice too, until Haim Cohn took it on 25 June 1952 (en.wiki and he.wiki agree).
- { office: trade_minister, from: 1951-10-08, to: 1952-12-24, sources: *third }
+ # Without portfolio in the Fourth Government, beside Lavon, until the Ministry of Development was set up for him on
+ # 15 June 1953 (Knesset records, issue #277). Needs several_holders on the office.
+ - { office: minister_without_portfolio, from: 1952-12-24, to: 1953-06-15, sources: [*gov4_k, { url: "https://production.oknesset.org/pipelines/data/members/kns_persontoposition/kns_persontoposition.csv", checked: 2026-10-12 }] }
- { office: justice_minister, from: 1951-10-08, to: 1952-06-25, sources: [*third_en, *third_he, *gov3, { url: "https://fs.knesset.gov.il/2/Plenum/2_ptm_250662.pdf", checked: 2026-10-12 }] }
# Food supply and rationing within Trade and Industry, not a revival of the abolished ministry.
# Schiffman/Goldstein (2026), pp.6 n.9, 33, 62; Knesset 7 January 1952, questions 8-10.
@@ -1170,7 +1173,25 @@ people:
loyalty: 5
offices:
# From 22 March 1956 (Knesset records, he.wiki; en.wiki gives 3 November 1955) to 31 December 1957, after the
- # content range. Ami Assaf (Mapai) was a second Deputy Minister of Education from 11 June 1956 (same sources); one
- # office has one holder at a time here, so his term is not authored.
+ # content range. Ami Assaf (Mapai) was a second Deputy Minister of Education from 11 June 1956 (same sources), below.
- { office: deputy_education_minister, from: 1956-03-22, party: national_religious_front, sources: [*gov7_k, { url: "https://he.wikipedia.org/wiki/ממשלת_ישראל_השביעית", checked: 2026-10-12 }, { url: "https://en.wikipedia.org/wiki/Seventh_government_of_Israel", checked: 2026-10-12 }, { url: "https://knesset.gov.il/Odata/ParliamentInfo.svc/KNS_PersonToPosition?$filter=PersonID%20eq%202131%20and%20KnessetNum%20eq%203", checked: 2026-10-12 }] }
status: fact-checked
+ - id: assaf
+ name: Ami Assaf
+ name_he: עמי אסף
+ born: 1903-07-22
+ died: 1963-05-17
+ biography_sources:
+ name_he: &assaf_bio [{ url: "https://en.wikipedia.org/wiki/Ami_Assaf", checked: 2026-10-12 }]
+ born: *assaf_bio
+ died: *assaf_bio
+ living: false
+ party: mapai
+ competence: 5
+ loyalty: 5
+ offices:
+ # Second Deputy Minister of Education from 11 June 1956, beside Moshe Unna (Knesset records: the Knesset's
+ # position records give him the post in the Seventh Government from that date, to 7 January 1958, after the
+ # content range). Open-ended here, like Unna's term. Needs several_holders on the office (issue #277).
+ - { office: deputy_education_minister, from: 1956-06-11, party: mapai, sources: [*gov7_k, { url: "https://production.oknesset.org/pipelines/data/members/kns_persontoposition/kns_persontoposition.csv", checked: 2026-10-12 }, { url: "https://en.wikipedia.org/wiki/Ami_Assaf", checked: 2026-10-12 }] }
+ status: fact-checked
diff --git a/content/schema/offices.schema.json b/content/schema/offices.schema.json
index f00e59332..ca1395c67 100644
--- a/content/schema/offices.schema.json
+++ b/content/schema/offices.schema.json
@@ -21,6 +21,7 @@
"id": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$", "description": "Lowercase letters, digits and underscores, starting with a letter. Unique." },
"title": { "type": "string", "minLength": 1, "description": "The official English title, as the player sees it." },
"historical_only": { "type": "boolean", "description": "Historical record only: no Cabinet seat, no player appointment, no gameplay." },
+ "several_holders": { "type": "boolean", "description": "Several people may hold it on the same day (Minister without Portfolio, a second deputy minister). Such an office cannot appear in event text or own policies or effects, and the player cannot appoint to it." },
"from": { "$ref": "#/definitions/date", "description": "Day the office was established (inclusive). Leave out if it exists from the start." },
"until": { "$ref": "#/definitions/date", "description": "Day the office was abolished (exclusive). Leave out while it still exists." }
}
diff --git a/sim/Statecraft.Sim.Tests/Governments1952To1956Tests.cs b/sim/Statecraft.Sim.Tests/Governments1952To1956Tests.cs
index 06f34c08a..fb0802193 100644
--- a/sim/Statecraft.Sim.Tests/Governments1952To1956Tests.cs
+++ b/sim/Statecraft.Sim.Tests/Governments1952To1956Tests.cs
@@ -41,7 +41,7 @@ public class Governments1952To1956Tests
[Fact]
public void NoOfficeHasTwoHoldersAtOnce()
{
- foreach (var office in C.Offices)
+ foreach (var office in C.Offices.Where(o => !o.SeveralHolders))
{
var terms = C.People.SelectMany(p => p.Offices.Where(t => t.Office == office.Id).Select(t => (p.Id, t.From, To: t.To ?? DateTime.MaxValue)))
.OrderBy(x => x.From).ToList();
diff --git a/sim/Statecraft.Sim.Tests/SeveralHoldersTests.cs b/sim/Statecraft.Sim.Tests/SeveralHoldersTests.cs
new file mode 100644
index 000000000..dc848c020
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/SeveralHoldersTests.cs
@@ -0,0 +1,138 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>Offices that several people may hold at once (#277): the loader rule, the lookups, and the 1952-1956 terms.</summary>
+public class SeveralHoldersTests
+{
+ // Third person on defense beside def_two, same dates.
+ static readonly string People = Fixture.Files["people.yaml"] + @" - id: fin_three
+ name: Fin Three
+ living: false
+ competence: 5
+ loyalty: 5
+ offices:
+ - office: defense_minister
+ from: 1949-01-01
+ to: 1949-06-01
+";
+
+ static Dictionary<string, string> Files(bool several) => new Dictionary<string, string>
+ {
+ ["people.yaml"] = People,
+ ["offices.yaml"] = Fixture.Files["offices.yaml"].Replace(" title: Minister of Defense\n",
+ " title: Minister of Defense\n" + (several ? " several_holders: true\n" : "")),
+ };
+
+ [Fact]
+ public void TwoHoldersOfAnOrdinaryOfficeStillFailToLoad()
+ {
+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(Files(false))));
+ Assert.Equal("offices.defense_minister", ex.Field);
+ Assert.Contains("overlapping dates", ex.Message);
+ }
+
+ [Fact]
+ public void AnOfficeWithSeveralHoldersAcceptsOverlappingTerms()
+ {
+ var c = ContentLoader.Load(Fixture.Write(Files(true)));
+ var day = new DateTime(1949, 3, 1);
+ Assert.Equal(new[] { "def_two", "fin_three" }, Offices.Holders(c, "defense_minister", day).Select(p => p.Id).ToArray());
+ Assert.Equal("def_two", Offices.Holder(c, "defense_minister", day)!.Id);
+ Assert.Equal(new[] { "def_two" }, Offices.Holders(c, "defense_minister", new DateTime(1949, 7, 1)).Select(p => p.Id).ToArray());
+ Assert.Empty(Offices.Holders(c, "prime_minister", new DateTime(1948, 1, 1)));
+ }
+
+ [Fact]
+ public void AHolderWhoDiesLeavesTheListOfHolders()
+ {
+ var files = Files(true);
+ // An open-ended term in the latest government may outlive a death (#167): the holder leaves on the day of death.
+ files["people.yaml"] = files["people.yaml"].Replace(" name: Fin Three\n", " name: Fin Three\n died: 1949-04-01\n")
+ .Replace(" from: 1949-01-01\n to: 1949-06-01\n", " from: 1949-03-10\n");
+ var c = ContentLoader.Load(Fixture.Write(files));
+ Assert.Equal(new[] { "def_two", "fin_three" }, Offices.Holders(c, "defense_minister", new DateTime(1949, 3, 31)).Select(p => p.Id).ToArray());
+ Assert.Equal(new[] { "def_two" }, Offices.Holders(c, "defense_minister", new DateTime(1949, 4, 1)).Select(p => p.Id).ToArray());
+ }
+
+ [Fact]
+ public void TheCabinetListsEveryHolderAndRefusesAppointments()
+ {
+ var c = ContentLoader.Load(Fixture.Write(Files(true)));
+ var s = Simulation.NewGame(c, 42, Mode.Historical);
+ s.Date = new DateTime(1949, 3, 15);
+ var seat = Cabinet.Lineup(c, s).Single(x => x.Office.Id == "defense_minister");
+ Assert.Equal(2, seat.Holders.Count);
+ Assert.Equal("def_two", seat.Holder!.Id);
+ Assert.Single(Cabinet.Lineup(c, s).Single(x => x.Office.Id == "finance_minister").Holders);
+ var reason = Cabinet.Check(c, s, "defense_minister", "pm_one");
+ Assert.Contains("several holders", reason);
+ }
+
+ [Fact]
+ public void AnAppointeeFromAnOlderSaveIsTheSeatsOnlyHolder()
+ {
+ var c = ContentLoader.Load(Fixture.Write(Files(true)));
+ var s = Simulation.NewGame(c, 42, Mode.Historical);
+ s.Date = new DateTime(1949, 3, 15);
+ s.Appointments["defense_minister"] = new Appointment("pm_one", new DateTime(1949, 3, 12));
+ s.AppointedUnder = "gov2";
+ var seat = Cabinet.Lineup(c, s).Single(x => x.Office.Id == "defense_minister");
+ Assert.True(seat.Appointed);
+ Assert.Equal("pm_one", seat.Holder!.Id);
+ Assert.Equal(new[] { "pm_one" }, seat.Holders.Select(p => p.Id).ToArray());
+ }
+
+ [Fact]
+ public void AnEventPlaceholderForSuchAnOfficeFailsToLoad()
+ {
+ var ev = "id: shortage\ntitle: Bread lines\ntext: '{defense_minister} reports shortages.'\nfrom: 1948-06-01\noptions:\n - id: a\n text: Ration food\n effects:\n - target: food_supply\n delta: 0.2\n";
+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(Files(true), new Dictionary<string, string> { ["shortage.yaml"] = ev })));
+ Assert.Contains("several holders", ex.Message);
+ }
+
+ /// <summary>The fixture with finance_minister marked several_holders; <paramref name="policiesOwned"/> false moves the
+ /// policies to defense_minister (a policy must have an office), so only the effect still names it.</summary>
+ static Dictionary<string, string> FinanceSeveral(bool policiesOwned) => new Dictionary<string, string>
+ {
+ ["offices.yaml"] = Fixture.Files["offices.yaml"].Replace(" title: Minister of Finance\n", " title: Minister of Finance\n several_holders: true\n"),
+ ["model.yaml"] = policiesOwned ? Fixture.Files["model.yaml"]
+ : Fixture.Files["model.yaml"].Replace(" office: finance_minister\n name: Rationing\n", " office: defense_minister\n name: Rationing\n")
+ .Replace(" office: finance_minister\n name: Transit camps\n", " office: defense_minister\n name: Transit camps\n"),
+ };
+
+ [Fact]
+ public void SuchAnOfficeCannotOwnAPolicy()
+ {
+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(FinanceSeveral(true))));
+ Assert.Equal("policies[rationing].office", ex.Field);
+ Assert.Contains("several holders", ex.Message);
+ }
+
+ [Fact]
+ public void SuchAnOfficeCannotOwnAnEffect()
+ {
+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(FinanceSeveral(false))));
+ Assert.Equal("effects[rationing_food].office", ex.Field);
+ Assert.Contains("several holders", ex.Message);
+ }
+
+ static readonly Content Real = ContentLoader.Load(RealContentTests.ContentRoot());
+ static string[] Who(string office, int y, int m, int d) => Offices.Holders(Real, office, new DateTime(y, m, d)).Select(p => p.Id).OrderBy(x => x).ToArray();
+
+ [Fact]
+ public void YosefAndLavonAreBothWithoutPortfolioInTheFourthGovernment()
+ {
+ Assert.Equal(new[] { "dov_yosef", "lavon" }, Who("minister_without_portfolio", 1953, 3, 1));
+ Assert.Equal(new[] { "lavon" }, Who("minister_without_portfolio", 1953, 6, 15)); // Yosef's term ends on 15 June 1953
+ Assert.Equal(new[] { "lavon" }, Who("minister_without_portfolio", 1952, 12, 23));
+ }
+
+ [Fact]
+ public void AssafIsASecondDeputyMinisterOfEducationFromJune1956()
+ {
+ Assert.Equal(new[] { "unna" }, Who("deputy_education_minister", 1956, 6, 10));
+ Assert.Equal(new[] { "assaf", "unna" }, Who("deputy_education_minister", 1956, 6, 11));
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs b/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs
index a943d6fb8..b6d0bd781 100644
--- a/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs
+++ b/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs
@@ -118,7 +118,7 @@ public class SliceSmokeTests
// CabinetPresenter: every seat, its holder and why each person cannot take it.
foreach (var seat in Cabinet.Lineup(c, s))
{
- yield return (seat.Office.Title + ": " + (seat.Holder?.Name ?? ""), false);
+ yield return (seat.Office.Title + ": " + string.Join(", ", seat.Holders.Select(p => p.Name)), false);
foreach (var reason in Cabinet.Candidates(c, s, seat.Office.Id).Select(x => x.reason).Where(x => x != null).Distinct())
yield return (reason!, false);
}
diff --git a/sim/Statecraft.Sim/Cabinet.cs b/sim/Statecraft.Sim/Cabinet.cs
index 54bdf5366..ada278954 100644
--- a/sim/Statecraft.Sim/Cabinet.cs
+++ b/sim/Statecraft.Sim/Cabinet.cs
@@ -18,9 +18,15 @@ namespace Statecraft.Sim
{
public Office Office { get; }
public Person? Holder { get; }
+ /// <summary>Everyone holding the office today: one person or none, except for an office with several_holders.</summary>
+ public IReadOnlyList<Person> Holders { get; }
/// <summary>True when the holder is the player's appointee, not the historical minister.</summary>
public bool Appointed { get; }
- public Seat(Office office, Person? holder, bool appointed) { Office = office; Holder = holder; Appointed = appointed; }
+ public Seat(Office office, Person? holder, bool appointed, IReadOnlyList<Person>? holders = null)
+ {
+ Office = office; Holder = holder; Appointed = appointed;
+ Holders = holders ?? (holder == null ? new Person[0] : new[] { holder });
+ }
}
/// <summary>The cabinet as the game sees it: the historical holders from people.yaml, overridden by the player's
@@ -54,10 +60,16 @@ namespace Statecraft.Sim
Holder(c, s, m.Groups[1].Value, date)?.Name
?? throw new InvalidOperationException(FormattableString.Invariant($"no holder of '{m.Groups[1].Value}' on {date:yyyy-MM-dd}")));
- /// <summary>Every playable office that exists on the state's date, in offices.yaml order, with its holder (null = vacant).</summary>
+ /// <summary>Every playable office that exists on the state's date, in offices.yaml order, with its holder (null = vacant).
+ /// A player's appointee is the seat's only holder (an appointment from a save made before an office allowed several
+ /// holders), so Seat.Holders never disagrees with Seat.Holder.</summary>
public static IReadOnlyList<Seat> Lineup(Content c, GameState s) =>
c.Offices.Where(o => !o.HistoricalOnly && o.ExistsOn(s.Date))
- .Select(o => new Seat(o, Holder(c, s, o.Id), Active(c, s, o.Id, s.Date) != null))
+ .Select(o =>
+ {
+ bool appointed = Active(c, s, o.Id, s.Date) != null;
+ return new Seat(o, Holder(c, s, o.Id), appointed, o.SeveralHolders && !appointed ? Offices.Holders(c, o.Id, s.Date) : null);
+ })
.ToList();
/// <summary>Null when <paramref name="personId"/> may be appointed to <paramref name="officeId"/> now, else the
@@ -76,6 +88,7 @@ namespace Statecraft.Sim
return $"The office of {office.Title} was abolished on {PlayerText.Date(office.Until.Value)}";
if (office.From.HasValue && s.Date < office.From.Value)
return $"The office of {office.Title} is not established until {PlayerText.Date(office.From.Value)}";
+ if (office.SeveralHolders) return $"{office.Title} can have several holders at once, and appointing to it is not part of the game yet";
if (officeId == "prime_minister") return "You are the Prime Minister: that office is not yours to fill";
if (officeId == "president") return "The President is elected by the Knesset, not appointed";
var person = c.People.FirstOrDefault(p => p.Id == personId);
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 576eb7635..529ea5bcc 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -15,6 +15,9 @@ namespace Statecraft.Sim
public string Title { get; set; } = "";
/// <summary>Historical record only: no Cabinet seat, player appointment or gameplay responsibility. Defaults false for existing offices.</summary>
public bool HistoricalOnly { get; set; }
+ /// <summary>True when several people may hold the office on the same day (Minister without Portfolio, a second
+ /// deputy minister). Every other office has one holder at a time, and the loader refuses overlapping terms.</summary>
+ public bool SeveralHolders { get; set; }
/// <summary>Day the office was established (inclusive, like a term's `from`); null when it exists from the start.</summary>
public DateTime? From { get; set; }
/// <summary>Day the office was abolished (exclusive end, like a term's `to`); null while it still exists.</summary>
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index 7e4d24c33..868e1e10e 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -533,6 +533,7 @@ namespace Statecraft.Sim
{
var (a, b) = (terms[i], terms[j]);
if (a.term.Office != b.term.Office || a.person == b.person) continue;
+ if (c.Offices.Any(o => o.Id == a.term.Office && o.SeveralHolders)) continue;
if (a.term.From < (b.term.To ?? DateTime.MaxValue) && b.term.From < (a.term.To ?? DateTime.MaxValue))
throw new ContentException("people.yaml", $"offices.{a.term.Office}", $"held by both {a.person} and {b.person} on overlapping dates");
}
@@ -569,6 +570,7 @@ namespace Statecraft.Sim
{
if (!offices.Contains(p.Office)) throw new ContentException("model.yaml", $"policies[{p.Id}].office", $"unknown office '{p.Office}'");
if (historicalOffices.Contains(p.Office)) throw new ContentException("model.yaml", $"policies[{p.Id}].office", "historical-only titles cannot own policies");
+ if (c.Offices.Any(o => o.Id == p.Office && o.SeveralHolders)) throw new ContentException("model.yaml", $"policies[{p.Id}].office", "an office with several holders cannot own policies");
}
foreach (var e in c.Effects)
{
@@ -578,6 +580,7 @@ namespace Statecraft.Sim
if (e.Inertia < 1) throw new ContentException("model.yaml", $"effects[{e.Id}].inertia", "must be >= 1");
if (e.Office != "" && !offices.Contains(e.Office)) throw new ContentException("model.yaml", $"effects[{e.Id}].office", $"unknown office '{e.Office}'");
if (historicalOffices.Contains(e.Office)) throw new ContentException("model.yaml", $"effects[{e.Id}].office", "historical-only titles cannot own effects");
+ if (c.Offices.Any(o => o.Id == e.Office && o.SeveralHolders)) throw new ContentException("model.yaml", $"effects[{e.Id}].office", "an office with several holders cannot own effects");
}
foreach (var s in c.Situations)
{
diff --git a/sim/Statecraft.Sim/EventRules.cs b/sim/Statecraft.Sim/EventRules.cs
index 59ed9d8dd..5a29dd5da 100644
--- a/sim/Statecraft.Sim/EventRules.cs
+++ b/sim/Statecraft.Sim/EventRules.cs
@@ -102,6 +102,8 @@ namespace Statecraft.Sim
{
var office = m.Groups[1].Value;
if (!offices.Contains(office)) throw new ContentException(e.File, field, $"unknown office placeholder '{m.Value}'");
+ if (c.Offices.Any(o => o.Id == office && o.SeveralHolders))
+ throw new ContentException(e.File, field, $"office '{office}' can have several holders at once, so '{m.Value}' would not name one person");
var gap = FirstUncovered(c, office, e.From, e.To);
if (gap.HasValue)
throw new ContentException(e.File, field, FormattableString.Invariant($"office '{office}' has no holder on {gap.Value:yyyy-MM-dd}, inside the event window"));
diff --git a/sim/Statecraft.Sim/Offices.cs b/sim/Statecraft.Sim/Offices.cs
index 216027d22..4e9669a79 100644
--- a/sim/Statecraft.Sim/Offices.cs
+++ b/sim/Statecraft.Sim/Offices.cs
@@ -9,11 +9,17 @@ namespace Statecraft.Sim
{
static bool In(DateTime d, DateTime from, DateTime? to) => d >= from && (to == null || d < to.Value);
- /// <summary>The historical holder on date. A holder has left office from their date of death on, even when the
+ /// <summary>The historical holder on date; for an office with several_holders, the first in people.yaml order
+ /// (the loader keeps such offices out of event text, policies and effects, so nothing asks it for one). A holder has left office from their date of death on, even when the
/// term is open-ended (the loader lets an open term outlive a death inside the latest government, #167).</summary>
public static Person? Holder(Content c, string office, DateTime date) =>
c.People.FirstOrDefault(p => (!p.Died.HasValue || date < p.Died.Value) && p.Offices.Any(t => t.Office == office && In(date, t.From, t.To)));
+ /// <summary>Everyone holding the office on date, in people.yaml order (one person, or none, unless the office
+ /// has several_holders: true). <see cref="Holder"/> is the first of these.</summary>
+ public static System.Collections.Generic.IReadOnlyList<Person> Holders(Content c, string office, DateTime date) =>
+ c.People.Where(p => (!p.Died.HasValue || date < p.Died.Value) && p.Offices.Any(t => t.Office == office && In(date, t.From, t.To))).ToList();
+
/// <summary>Party of the person on date: the party of a term held that day, else Person.Party.</summary>
public static string PartyOf(Content c, Person p, DateTime date) =>
p.Offices.FirstOrDefault(t => t.Party != "" && In(date, t.From, t.To))?.Party ?? p.Party;
diff --git a/unity/Assets/Scripts/UI/CabinetPresenter.cs b/unity/Assets/Scripts/UI/CabinetPresenter.cs
index 60527903d..72868ac50 100644
--- a/unity/Assets/Scripts/UI/CabinetPresenter.cs
+++ b/unity/Assets/Scripts/UI/CabinetPresenter.cs
@@ -11,7 +11,8 @@ namespace Statecraft.Game.UI
/// Prime Minister's card at the side, listing every office the PM holds (each also a button to select it); the
/// legislature as a half circle of seats, coalition and opposition, with the majority line, and the coalition's seats,
/// the opposition's, the majority, the largest party, coalition stability and each party's seats beside it; and a card
- /// for every other office held by someone else (portrait, party, competence and loyalty bars). Every number is the
+ /// for every other office held by someone else (portrait, party, competence and loyalty bars; one card per holder of an
+ /// office that has several at once). Every number is the
/// sim's: legislatures.yaml seats and size, governments.yaml coalition, people.yaml competence and loyalty, GameState
/// coalition stability. The two seat colours mark coalition and opposition only (content records no party colours).
/// Selecting an office lists every person with Appoint, or the reason they cannot be appointed (Cabinet.Check).
@@ -135,27 +136,27 @@ namespace Statecraft.Game.UI
foreach (var b in pmOffices.Children()) b.EnableInClassList("seat-selected", b.name == "seat-" + Selected);
pmOffices.style.display = pmHeld.Count > 0 ? DisplayStyle.Flex : DisplayStyle.None;
- var grid = lineup.Where(x => x.Office.Id != PrimeMinister && !HeldByPm(x)).ToList();
- if (!grid.Select(x => x.Office.Id).SequenceEqual(cardOrder))
+ var grid = Cards(lineup.Where(x => x.Office.Id != PrimeMinister && !HeldByPm(x)));
+ if (!grid.Select(x => x.key).SequenceEqual(cardOrder))
{
list.Clear(); cards.Clear();
- foreach (var seat in grid)
+ foreach (var (key, seat, _) in grid)
{
var office = seat.Office.Id;
- var card = new Button(() => Select(office)) { name = "seat-" + office };
+ var card = new Button(() => Select(office)) { name = "seat-" + key };
card.AddToClassList("seat");
- PersonCard.Build(card, "seat-" + office, text);
- cards[office] = card;
+ PersonCard.Build(card, "seat-" + key, text);
+ cards[key] = card;
list.Add(card);
}
- cardOrder = grid.Select(x => x.Office.Id).ToList();
+ cardOrder = grid.Select(x => x.key).ToList();
}
- foreach (var seat in grid)
+ foreach (var (key, seat, holder) in grid)
{
- var card = cards[seat.Office.Id];
+ var card = cards[key];
card.EnableInClassList("seat-selected", seat.Office.Id == Selected);
- card.EnableInClassList("seat-vacant", seat.Holder == null);
- PersonCard.Fill(card, "seat-" + seat.Office.Id, c, s, seat.Holder, seat.Office.Title, seat.Appointed, text, portraits, CardPortrait);
+ card.EnableInClassList("seat-vacant", holder == null);
+ PersonCard.Fill(card, "seat-" + key, c, s, holder, seat.Office.Title, seat.Appointed, text, portraits, CardPortrait);
}
RenderPick(c, s);
@@ -164,6 +165,13 @@ namespace Statecraft.Game.UI
screen.Q<Label>("cabinet-status").text = string.Join("\n", queued);
}
+ /// <summary>One card per holder: an office with several holders today (#277: Minister without Portfolio) gets a card for
+ /// each, in Seat.Holders order, named office, office-2, office-3...; every other office one card, named by its id.</summary>
+ static List<(string key, Seat seat, Person? holder)> Cards(IEnumerable<Seat> seats) =>
+ seats.SelectMany(seat => seat.Holders.Count > 1
+ ? seat.Holders.Select((p, i) => (i == 0 ? seat.Office.Id : seat.Office.Id + "-" + (i + 1), seat, (Person?)p))
+ : new[] { (seat.Office.Id, seat, seat.Holder) }).ToList();
+
/// <summary>The candidate list for the selected office: rows are made when the office changes and updated in place.</summary>
void RenderPick(Content c, GameState s)
{
diff --git a/unity/Assets/Tests/EditMode/CabinetScreenTests.cs b/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
index 50643fa2a..7327c0322 100644
--- a/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
@@ -189,6 +189,31 @@ public class CabinetScreenTests
Assert.AreNotEqual("First Government", ui.Q<Label>("cabinet-government").text);
}
+ /// <summary>#277: Minister without Portfolio had two holders from 24 December 1952 to 15 June 1953 (Yosef and Lavon).
+ /// The screen gives each a card, and selecting the office says once why nobody can be appointed to it.</summary>
+ [Test]
+ public void AnOfficeWithSeveralHoldersGetsACardForEach()
+ {
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ g.State.Date = new DateTime(1953, 3, 1);
+ using var ui = Shown();
+ var cabinet = new CabinetPresenter(ui.Root, new SimBridge(g, Text), Text, null);
+ Assert.AreEqual("Dov Yosef", ui.Q<Label>("seat-minister_without_portfolio-holder").text);
+ Assert.AreEqual("Pinhas Lavon", ui.Q<Label>("seat-minister_without_portfolio-2-holder").text);
+ Assert.AreEqual("Minister without Portfolio", ui.Q<Label>("seat-minister_without_portfolio-2-office").text);
+ UiTestKit.Press(ui.Q<Button>("seat-minister_without_portfolio-2"));
+ Assert.AreEqual("minister_without_portfolio", cabinet.Selected);
+ Assert.IsTrue(ui.Q<Button>("seat-minister_without_portfolio").ClassListContains("seat-selected"));
+ Assert.IsTrue(ui.Q<Button>("seat-minister_without_portfolio-2").ClassListContains("seat-selected"));
+ StringAssert.Contains("several holders", ui.Q<Label>("cabinet-pick-reason").text);
+ Assert.AreEqual(DisplayStyle.Flex, ui.Q<Label>("cabinet-pick-reason").style.display.value);
+
+ g.State.Date = new DateTime(1953, 7, 1); // Yosef has moved to Development: one holder, one card
+ cabinet.Render();
+ Assert.AreEqual("Pinhas Lavon", ui.Q<Label>("seat-minister_without_portfolio-holder").text);
+ Assert.IsNull(ui.Root.Q<Button>("seat-minister_without_portfolio-2"));
+ }
+
[Test]
public void AVacantSeatSaysSoAndHasNoPortrait()
{