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: eras.yaml systems switches, legislature and map_actions (fixes #58) (#290)

agamrafaeli-instinct8f16d96b9dd7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff95cc7d9..687ff8093 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
## [Unreleased]
### Added
+- Era system switches in eras.yaml (`systems`): `legislature: state | assembly` (an assembly's vote against a policy or
+ the budget is held and reported, but does not bind) and `map_actions` (the actions the era allows). The Cabinet and
+ Budget screens say when the body's vote does not bind, and the hex panel shows only the era's map actions. With no
+ `systems` key an era behaves as before; goldens unchanged (fixes #58).
- 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
diff --git a/content/eras.yaml b/content/eras.yaml
index 9b87316f5..d916ca393 100644
--- a/content/eras.yaml
+++ b/content/eras.yaml
@@ -2,6 +2,8 @@
# half-open, like every other window: `to` is the first day after the era. Reaching the last era's `to` ends the game.
# Design decision D3 (docs/superpowers/specs/2026-10-10-chapters-architecture-design.md): the founding era runs from
# the start of play to 1 January 1957, the spec's "Q2 1948 to Q4 1956". These are game-design dates, not historical facts.
+# Optional per era: `systems: { legislature: state | assembly, map_actions: [transit_camp, housing] }` (issue #58). Absent means
+# a state legislature and both map actions. A key is added only with the code behind it.
eras:
- id: founding
name: The Founding
diff --git a/sim/Statecraft.Sim.Tests/EraSystemsTests.cs b/sim/Statecraft.Sim.Tests/EraSystemsTests.cs
new file mode 100644
index 000000000..9ad60b280
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/EraSystemsTests.cs
@@ -0,0 +1,180 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>eras.yaml `systems` (#58): the legislature and map_actions switches, each tested both ways.</summary>
+public class EraSystemsTests
+{
+ static string Eras(string systems) => $@"
+eras:
+ - id: founding
+ name: The Founding
+ from: 1948-05-15
+ to: 1957-01-01
+{systems}";
+
+ static Content Load(string systems, bool noMajority = false)
+ {
+ var o = new Dictionary<string, string> { ["eras.yaml"] = Eras(systems) };
+ // Government One has no majority in the council (beta holds 2 of 5), so every vote fails.
+ if (noMajority) o["governments.yaml"] = Fixture.Files["governments.yaml"].Replace("coalition: [alpha]", "coalition: [beta]");
+ return ContentLoader.Load(Fixture.Write(o));
+ }
+
+ [Fact]
+ public void RealContentUsesTheDefaultSwitches()
+ {
+ var c = ContentLoader.Load(RealContentTests.ContentRoot());
+ Assert.Equal("state", c.SystemsAt(c.Rules.Start).Legislature);
+ Assert.Equal(new[] { "transit_camp", "housing" }, c.SystemsAt(c.Rules.Start).MapActions);
+ Assert.Equal("state", c.SystemsAt(new DateTime(1960, 1, 1)).Legislature); // outside every era: defaults
+ }
+
+ [Theory]
+ [InlineData(" systems: { legislature: parliament }", "eras[founding].systems.legislature", "must be state or assembly")]
+ [InlineData(" systems: { map_actions: [bulldozer] }", "eras[founding].systems.map_actions", "unknown map action 'bulldozer'")]
+ [InlineData(" systems: { map_actions: [housing, housing] }", "eras[founding].systems.map_actions", "lists an action twice")]
+ public void BadSwitchesFailNamingTheField(string systems, string field, string message)
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(systems));
+ Assert.Equal("eras.yaml", ex.File);
+ Assert.Equal(field, ex.Field);
+ Assert.Contains(message, ex.Message);
+ }
+
+ [Fact]
+ public void AnUnknownSwitchKeyFailsNamingTheFileAndKey()
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(" systems: { war_mode: true }"));
+ Assert.Equal("eras.yaml", ex.File);
+ Assert.Contains("war_mode", ex.Message);
+ }
+
+ [Fact]
+ public void AnEmptySystemsKeyFailsNamingTheField()
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(" systems:"));
+ Assert.Equal("eras.yaml", ex.File);
+ Assert.Equal("eras[founding].systems", ex.Field);
+ }
+
+ /// <summary>The budget vote (the fixture's House approves budgets from 1949-02-14; Government One holds 4 of 10, so the
+ /// vote fails): a state legislature puts the old budget back, an assembly's vote is reported and the budget stands.</summary>
+ [Theory]
+ [InlineData("state", 0.5, "House voted the budget down")]
+ [InlineData("assembly", 1.0, "House voted against the budget, but its vote does not bind")]
+ public void TheBudgetVoteBindsOnlyInAState(string legislature, double finance, string cause)
+ {
+ var c = Load($" systems: {{ legislature: {legislature} }}");
+ var s = Simulation.NewGame(c, 42, Mode.Historical);
+ s.Date = new DateTime(1949, 3, 1);
+ s.Budget["finance_minister"] = 0.5; // an older budget to fall back to
+ var r = Simulation.Step(c, s, new Command[] { new AllocateBudget(new Dictionary<string, double> { ["finance_minister"] = 1.0 }) });
+ Assert.Empty(r.Rejected);
+ Assert.Equal(finance, r.State.Budget["finance_minister"]);
+ Assert.Contains(r.Why, w => w.System == "politics" && w.Target == "budget" && w.Message == cause);
+ }
+
+ /// <summary>A map action switched off is refused through Step with the chapter reason and builds nothing; the same order in
+ /// an era that allows it builds.</summary>
+ [Theory]
+ [InlineData(" systems: { map_actions: [transit_camp] }", false)]
+ [InlineData(" systems: { map_actions: [] }", false)]
+ [InlineData(" systems: { map_actions: [transit_camp, housing] }", true)]
+ [InlineData("", true)]
+ public void ASwitchedOffMapActionIsRefusedThroughStep(string systems, bool builds)
+ {
+ var c = Load(systems);
+ var s = Simulation.NewGame(c, 42, Mode.Historical);
+ s.Date = new DateTime(1948, 6, 1); // map actions open in the fixture
+ var r = Simulation.Step(c, s, new Command[] { new MapAction(MapActions.Housing, 2, 0) });
+ if (builds)
+ {
+ Assert.Empty(r.Rejected);
+ Assert.Equal(MapActions.Housing, MapActions.At(r.State, 2, 0)!.Action);
+ }
+ else
+ {
+ Assert.Equal("That map action is not available in this chapter", r.Rejected.Single().Reason);
+ Assert.Empty(r.State.Placements);
+ }
+ }
+
+ /// <summary>The switches follow the turn's starting date, like RulesAt: across a boundary inside a turn (1948-06-01; the
+ /// fixture's weekly war turns run 05-29 to 06-05) the turn that starts in the assembly era is not bound by the vote, and
+ /// the first turn that starts in the state era is.</summary>
+ [Fact]
+ public void TheSwitchesFollowTheTurnsStartingDate()
+ {
+ var o = new Dictionary<string, string>
+ {
+ ["eras.yaml"] = @"
+eras:
+ - id: yishuv
+ name: An Assembly Chapter
+ from: 1948-05-15
+ to: 1948-06-01
+ systems: { legislature: assembly, map_actions: [] }
+ - id: founding
+ name: The Founding
+ from: 1948-06-01
+ to: 1957-01-01
+",
+ ["governments.yaml"] = Fixture.Files["governments.yaml"].Replace("coalition: [alpha]", "coalition: [beta]"),
+ };
+ var c = ContentLoader.Load(Fixture.Write(o));
+ var boundary = new DateTime(1948, 6, 1);
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ while (s.Date.AddDays(7) <= boundary) s = Simulation.Step(c, s, new Command[0]).State;
+ Assert.True(s.Date < boundary);
+ var crossing = Simulation.Step(c, s, new Command[] { new SetPolicy("rationing", 1.0) });
+ Assert.True(crossing.State.Date > boundary); // the turn ends in the state era
+ Assert.Equal(1.0, crossing.State.Policies["rationing"]);
+ Assert.Equal("assembly", c.SystemsAt(s.Date).Legislature);
+ var next = Simulation.Step(c, crossing.State, new Command[] { new SetPolicy("rationing", 0.0) });
+ Assert.Equal(1.0, next.State.Policies["rationing"]); // voted down: the state era's vote binds
+ Assert.Contains(next.Why, w => w.Message.Contains("voted down"));
+ }
+
+ [Fact]
+ public void AStateLegislatureVotesDownAPolicy()
+ {
+ var c = Load(" systems: { legislature: state }", noMajority: true);
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ var r = Simulation.Step(c, s, new Command[] { new SetPolicy("rationing", 1.0) });
+ Assert.Equal(0.0, r.State.Policies["rationing"]);
+ Assert.Contains(r.Why, w => w.Message.Contains("voted down"));
+ }
+
+ [Fact]
+ public void AnAssemblyVotesAgainstAPolicyButItStillTakesEffect()
+ {
+ var c = Load(" systems: { legislature: assembly }", noMajority: true);
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ var r = Simulation.Step(c, s, new Command[] { new SetPolicy("rationing", 1.0) });
+ Assert.Equal(1.0, r.State.Policies["rationing"]);
+ Assert.Contains(r.Why, w => w.Message.Contains("its vote does not bind"));
+ Assert.DoesNotContain(r.Why, w => w.Message.Contains("voted down"));
+ }
+
+ [Fact]
+ public void AnEmptyMapActionsListAllowsNone()
+ {
+ var c = Load(" systems: { map_actions: [] }");
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ Assert.Equal("That map action is not available in this chapter", MapActions.Check(c, s, MapActions.Housing, 0, 0));
+ }
+
+ [Fact]
+ public void MapActionsAreLimitedToTheErasList()
+ {
+ var c = Load(" systems: { map_actions: [housing] }");
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ Assert.Equal("That map action is not available in this chapter", MapActions.Check(c, s, MapActions.TransitCamp, 0, 0));
+ Assert.NotEqual("That map action is not available in this chapter", MapActions.Check(c, s, MapActions.Housing, 0, 0));
+ var all = Load(" systems: { map_actions: [transit_camp, housing] }");
+ var s2 = Simulation.NewGame(all, 1, Mode.Historical);
+ Assert.NotEqual("That map action is not available in this chapter", MapActions.Check(all, s2, MapActions.TransitCamp, 0, 0));
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/EraTests.cs b/sim/Statecraft.Sim.Tests/EraTests.cs
index d8e247ea3..00c53acdb 100644
--- a/sim/Statecraft.Sim.Tests/EraTests.cs
+++ b/sim/Statecraft.Sim.Tests/EraTests.cs
@@ -139,7 +139,7 @@ public class EraTests
[Fact]
public void AnUnknownFieldIsALoadError() =>
- BadEras(Eras(Era("a", "1948-05-15", "1957-01-01") + "\n systems: {}"));
+ BadEras(Eras(Era("a", "1948-05-15", "1957-01-01") + "\n carry: carry/founding.yaml"));
// --- the boundary turn (spec 4.1) and the end of the last era (spec 4.5)
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 529ea5bcc..d52f3d8c0 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -34,6 +34,20 @@ namespace Statecraft.Sim
public string Name { get; set; } = "";
public DateTime From { get; set; }
public DateTime To { get; set; }
+ /// <summary>The era's system switches (eras.yaml `systems`). Absent means the defaults: a state legislature and every map action.</summary>
+ public EraSystems Systems { get; set; } = new EraSystems();
+ }
+
+ /// <summary>Switches for code that exists (chapters design §5). A key is added here only with the code behind it.</summary>
+ public sealed class EraSystems
+ {
+ public const string State = "state";
+ public const string Assembly = "assembly";
+ /// <summary>`state`: the sitting body's votes bind. `assembly`: a consent body without force of law; its votes are
+ /// held and reported, but a vote against does not stop a policy or a budget.</summary>
+ public string Legislature { get; set; } = State;
+ /// <summary>The map actions allowed in the era (transit_camp, housing). Absent means both. An empty list means none.</summary>
+ public List<string> MapActions { get; set; } = new List<string> { "transit_camp", "housing" };
}
public sealed class Party { public string Id { get; set; } = ""; public string Name { get; set; } = ""; }
@@ -305,6 +319,8 @@ namespace Statecraft.Sim
public List<Era> Eras = new List<Era>();
/// <summary>The era that contains <paramref name="date"/> (From inclusive, To exclusive), or null outside every era.</summary>
public Era? EraAt(DateTime date) => Eras.FirstOrDefault(e => date >= e.From && date < e.To);
+ /// <summary>The system switches in force on <paramref name="date"/>; the defaults outside every era.</summary>
+ public EraSystems SystemsAt(DateTime date) => EraAt(date)?.Systems ?? new EraSystems();
public List<Indicator> Indicators = new List<Indicator>();
public List<Policy> Policies = new List<Policy>();
public List<Effect> Effects = new List<Effect>();
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index 868e1e10e..759e1bbc4 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -633,6 +633,13 @@ namespace Statecraft.Sim
Named("eras.yaml", at + ".name", e.Name);
if (e.To == default) throw new ContentException("eras.yaml", at + ".to", "required (the first day after the era)");
Period("eras.yaml", at, e.From, e.To);
+ if (e.Systems == null) throw new ContentException("eras.yaml", at + ".systems", "must be a map of switches (leave it out for the defaults)");
+ if (e.Systems.Legislature != EraSystems.State && e.Systems.Legislature != EraSystems.Assembly)
+ throw new ContentException("eras.yaml", at + ".systems.legislature", "must be state or assembly");
+ foreach (var a in e.Systems.MapActions)
+ if (!MapActions.Actions.Contains(a)) throw new ContentException("eras.yaml", at + ".systems.map_actions", $"unknown map action '{a}' (transit_camp or housing)");
+ if (e.Systems.MapActions.Distinct().Count() != e.Systems.MapActions.Count)
+ throw new ContentException("eras.yaml", at + ".systems.map_actions", "lists an action twice");
if (i == 0)
{
if (c.Rules.Start != default && e.From != c.Rules.Start) // a missing start is rules.yaml's own error
diff --git a/sim/Statecraft.Sim/MapActions.cs b/sim/Statecraft.Sim/MapActions.cs
index faf025e1c..96d4e2e83 100644
--- a/sim/Statecraft.Sim/MapActions.cs
+++ b/sim/Statecraft.Sim/MapActions.cs
@@ -42,6 +42,8 @@ namespace Statecraft.Sim
// No id in either reason: a command from an old save or a stale UI may name an action this content lacks; the
// replay refuses it here, before anything is formatted, so a placement always has its rule (fix round 3, m-6).
if (!Actions.Contains(action)) return "There is no such map action";
+ // eras.yaml systems.map_actions: the actions this era allows
+ if (!c.SystemsAt(s.Date).MapActions.Contains(action)) return "That map action is not available in this chapter";
var rules = c.RulesAt(s.Date); // the era the turn starts in
var rule = rules.MapActions.TryGetValue(action, out var x) ? x : null;
if (rule == null) return "That map action is not available in this game";
diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.cs
index 760660705..50a54e563 100644
--- a/sim/Statecraft.Sim/Simulation.cs
+++ b/sim/Statecraft.Sim/Simulation.cs
@@ -94,8 +94,13 @@ namespace Statecraft.Sim
if (legislature == null) return "No legislature is sitting";
if (!PassVote(c, s))
{
- why.Add(new Cause("politics", p.Policy, 0, $"{legislature.Body} voted down {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}"));
- return null;
+ if (Advisory(c, s))
+ why.Add(new Cause("politics", p.Policy, 0, $"{legislature.Body} voted against {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}, but its vote does not bind"));
+ else
+ {
+ why.Add(new Cause("politics", p.Policy, 0, $"{legislature.Body} voted down {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}"));
+ return null;
+ }
}
s.Policies[p.Policy] = p.Level;
why.Add(new Cause("policy", p.Policy, p.Level, $"{PlayerText.Target(c, p.Policy)} set to {PlayerText.Percent(p.Level)}"));
@@ -108,8 +113,13 @@ namespace Statecraft.Sim
if (invalid != null) return invalid;
if (PoliticsSystem.BudgetNeedsVote(c, s.Date) && !PassVote(c, s))
{
- s.Budget = old;
- why.Add(new Cause("politics", "budget", 0, $"{Offices.Legislature(c, s.Date)!.Body} voted the budget down"));
+ if (Advisory(c, s))
+ why.Add(new Cause("politics", "budget", 0, $"{Offices.Legislature(c, s.Date)!.Body} voted against the budget, but its vote does not bind"));
+ else
+ {
+ s.Budget = old;
+ why.Add(new Cause("politics", "budget", 0, $"{Offices.Legislature(c, s.Date)!.Body} voted the budget down"));
+ }
}
return null;
}
@@ -130,6 +140,9 @@ namespace Statecraft.Sim
}
}
+ /// <summary>True in an era whose legislature is an assembly (eras.yaml systems.legislature): its vote is held but does not bind.</summary>
+ static bool Advisory(Content c, GameState s) => c.SystemsAt(s.Date).Legislature == EraSystems.Assembly;
+
static bool PassVote(Content c, GameState s)
{
var rng = new Rng(s.RngState);
diff --git a/unity/Assets/Scripts/UI/BudgetPresenter.cs b/unity/Assets/Scripts/UI/BudgetPresenter.cs
index 365d20a63..e7e2e15a8 100644
--- a/unity/Assets/Scripts/UI/BudgetPresenter.cs
+++ b/unity/Assets/Scripts/UI/BudgetPresenter.cs
@@ -126,8 +126,10 @@ namespace Statecraft.Game.UI
}
var leg = Offices.Legislature(c, s.Date);
var (seats, size) = PoliticsSystem.CoalitionSeats(c, s.Date);
- screen.Q<Label>("budget-vote").text = leg == null ? "" : leg.BudgetApproval
- ? text.Format("budget.vote_needed", leg.Body, seats, size) : text.Format("budget.no_vote", leg.Body);
+ // eras.yaml systems.legislature: an assembly's vote is held but does not bind (#58)
+ var advisory = c.SystemsAt(s.Date).Legislature == EraSystems.Assembly;
+ screen.Q<Label>("budget-vote").text = leg == null ? "" : !leg.BudgetApproval ? text.Format("budget.no_vote", leg.Body)
+ : text.Format(advisory ? "budget.vote_advisory" : "budget.vote_needed", leg.Body, seats, size);
screen.Q<Label>("budget-money").text = text.Format("budget.money", PlayerText.Money(c, "treasury", s.Treasury), PlayerText.Money(c, "debt", s.Debt), PlayerText.Money(c, "fx_reserves", s.FxReserves));
var flows = EconomySystem.Flows(c, s, 1.0); // the sim's own arithmetic, for a year
screen.Q<Label>("budget-flow").text = text.Format("budget.flow", PlayerText.Money(c, "treasury", flows.Tax), PlayerText.Money(c, "treasury", flows.Spending), PlayerText.Money(c, "treasury", flows.Mobilization));
diff --git a/unity/Assets/Scripts/UI/CabinetPresenter.cs b/unity/Assets/Scripts/UI/CabinetPresenter.cs
index 72868ac50..8924c60db 100644
--- a/unity/Assets/Scripts/UI/CabinetPresenter.cs
+++ b/unity/Assets/Scripts/UI/CabinetPresenter.cs
@@ -102,7 +102,8 @@ namespace Statecraft.Game.UI
var leg = Offices.Legislature(c, s.Date);
var (seats, size) = PoliticsSystem.CoalitionSeats(c, s.Date);
screen.Q<Label>("cabinet-government").text = gov?.Name ?? "";
- screen.Q<Label>("cabinet-legislature").text = leg == null ? "" : text.Format("cabinet.legislature", leg.Body, leg.Size);
+ var advisory = c.SystemsAt(s.Date).Legislature == EraSystems.Assembly; // eras.yaml systems.legislature (#58)
+ screen.Q<Label>("cabinet-legislature").text = leg == null ? "" : text.Format(advisory ? "cabinet.legislature_advisory" : "cabinet.legislature", leg.Body, leg.Size);
RenderHouse(c, s, gov, leg, seats, size);
var lineup = Cabinet.Lineup(c, s);
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index 7e27beeaa..3fa699118 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -158,8 +158,14 @@ namespace Statecraft.Game.UI
: here != null ? text.Format("info.built", PlayerText.Capitalised(PlayerText.MapAction(c, here.Action)), PlayerText.Month(here.Date)) : "";
var campWhy = MapActions.Check(c, s, MapActions.TransitCamp, q, r);
var housingWhy = MapActions.Check(c, s, MapActions.Housing, q, r);
- camp.style.display = DisplayStyle.Flex; housing.style.display = DisplayStyle.Flex;
- camp.SetEnabled(campWhy == null); housing.SetEnabled(housingWhy == null);
+ // eras.yaml systems.map_actions (#58): an action the era does not allow has no button and no reason
+ var allowed = c.SystemsAt(s.Date).MapActions;
+ bool campOn = allowed.Contains(MapActions.TransitCamp), housingOn = allowed.Contains(MapActions.Housing);
+ camp.style.display = campOn ? DisplayStyle.Flex : DisplayStyle.None;
+ housing.style.display = housingOn ? DisplayStyle.Flex : DisplayStyle.None;
+ camp.SetEnabled(campOn && campWhy == null); housing.SetEnabled(housingOn && housingWhy == null);
+ if (!campOn) campWhy = null;
+ if (!housingOn) housingWhy = null;
// with no rule for an action there is no cost to show (it is disabled with the sim's reason anyway)
camp.text = c.RulesAt(s.Date).MapActions.TryGetValue(MapActions.TransitCamp, out var cr) ? text.Format("info.build_camp", PlayerText.Money(c, "treasury", cr.Cost)) : text["info.build_camp_plain"];
housing.text = c.RulesAt(s.Date).MapActions.TryGetValue(MapActions.Housing, out var hr) ? text.Format("info.build_housing", PlayerText.Money(c, "treasury", hr.Cost)) : text["info.build_housing_plain"];
diff --git a/unity/Assets/Tests/EditMode/BudgetScreenTests.cs b/unity/Assets/Tests/EditMode/BudgetScreenTests.cs
index 2ca19337f..ed515a164 100644
--- a/unity/Assets/Tests/EditMode/BudgetScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/BudgetScreenTests.cs
@@ -237,4 +237,28 @@ public class BudgetScreenTests
new BudgetPresenter(ui.Root, new SimBridge(g, Text), Text);
Assert.AreEqual(vacant.Office.Title + " (vacant)", ui.Q<Label>("budget-" + vacant.Office.Id + "-name").text);
}
+
+ /// <summary>eras.yaml systems.legislature (#58): where the body votes on the budget, an assembly era says its vote does
+ /// not bind and a state era says it must approve. Played on a copy of the content with the switch set.</summary>
+ [Test]
+ public void TheBudgetVoteLineFollowsTheErasSwitch()
+ {
+ var c = ContentLoader.Load(Paths.Content);
+ var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);
+ while (!(Offices.Legislature(c, g.State.Date)?.BudgetApproval ?? false)) g.Step(new Command[0]);
+ var leg = Offices.Legislature(c, g.State.Date)!;
+ var (seats, size) = PoliticsSystem.CoalitionSeats(c, g.State.Date);
+ using (var ui = new UiTestKit())
+ {
+ c.Eras[0].Systems.Legislature = EraSystems.Assembly;
+ new BudgetPresenter(ui.Root, new SimBridge(g, Text), Text);
+ Assert.AreEqual(System.FormattableString.Invariant($"The {leg.Body} votes on it, but its vote does not bind: the coalition holds {seats} of {size} seats"), ui.Q<Label>("budget-vote").text);
+ }
+ using (var ui = new UiTestKit())
+ {
+ c.Eras[0].Systems.Legislature = EraSystems.State;
+ new BudgetPresenter(ui.Root, new SimBridge(g, Text), Text);
+ Assert.AreEqual(System.FormattableString.Invariant($"The {leg.Body} must approve it: the coalition holds {seats} of {size} seats"), ui.Q<Label>("budget-vote").text);
+ }
+ }
}
diff --git a/unity/Assets/Tests/EditMode/CabinetScreenTests.cs b/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
index 7327c0322..71d11c034 100644
--- a/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
@@ -263,4 +263,20 @@ public class CabinetScreenTests
cabinet.Dispose();
Assert.AreEqual(DisplayStyle.None, ui.Q<VisualElement>("cabinet-pick").style.display.value);
}
+
+ /// <summary>eras.yaml systems.legislature (#58): in an assembly era the screen says the body's votes do not bind; in a
+ /// state era it is the body the government answers to. Played on a copy of the content with the switch set.</summary>
+ [Test]
+ public void TheLegislatureLineFollowsTheErasSwitch()
+ {
+ var c = ContentLoader.Load(Paths.Content);
+ using var ui = Shown();
+ var cabinet = new CabinetPresenter(ui.Root, new SimBridge(GameSession.New(c, GoldenRun.Seed, Mode.Historical), Text), Text, null);
+ var leg = Offices.Legislature(c, c.Rules.Start)!;
+ Assert.AreEqual($"Answerable to the {leg.Body} · {leg.Size} members", ui.Q<Label>("cabinet-legislature").text);
+ c.Eras[0].Systems.Legislature = EraSystems.Assembly;
+ cabinet.Render();
+ Assert.AreEqual($"Consults the {leg.Body} · {leg.Size} members · its votes do not bind", ui.Q<Label>("cabinet-legislature").text);
+ cabinet.Dispose();
+ }
}
diff --git a/unity/Assets/Tests/EditMode/MapActionUiTests.cs b/unity/Assets/Tests/EditMode/MapActionUiTests.cs
index a38601c96..2f2093c26 100644
--- a/unity/Assets/Tests/EditMode/MapActionUiTests.cs
+++ b/unity/Assets/Tests/EditMode/MapActionUiTests.cs
@@ -377,4 +377,32 @@ public class MapActionUiTests
{ e.target = image; image.SendEvent(e); }
Assert.AreEqual(0, clicks);
}
+
+ /// <summary>eras.yaml systems.map_actions (#58): an action the era does not allow has no button and no reason; with
+ /// both allowed both show. Played on a copy of the content, switching the list between renders.</summary>
+ [Test]
+ public void OnlyTheErasMapActionsHaveButtons()
+ {
+ var c = ContentLoader.Load(Paths.Content);
+ var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);
+ while (g.State.Date < new DateTime(1950, 8, 1)) g.Step(HistoricalAI.Commands(c, g.State));
+ using var ui = new UiTestKit();
+ var info = new InfoPanelPresenter(ui.Root, new SimBridge(g, Text), Text, Towns.ToDictionary(t => t.Id, t => t.Name));
+ var tlv = c.SettlementHexes.Single(s => s.Id == "tel_aviv");
+ void ShowWith(params string[] actions) { c.Eras[0].Systems.MapActions = actions.ToList(); info.Show(tlv.Q, tlv.R); }
+ DisplayStyle Display(string name) => ui.Q<Button>(name).style.display.value;
+
+ ShowWith(MapActions.TransitCamp, MapActions.Housing);
+ Assert.AreEqual(DisplayStyle.Flex, Display("build-camp")); Assert.AreEqual(DisplayStyle.Flex, Display("build-housing"));
+ Assert.IsTrue(ui.Q<Button>("build-camp").enabledSelf, ui.Q<Label>("info-reason").text);
+
+ ShowWith(MapActions.Housing);
+ Assert.AreEqual(DisplayStyle.None, Display("build-camp")); Assert.AreEqual(DisplayStyle.Flex, Display("build-housing"));
+ Assert.IsFalse(ui.Q<Button>("build-camp").enabledSelf);
+ StringAssert.DoesNotContain("chapter", ui.Q<Label>("info-reason").text);
+
+ ShowWith();
+ Assert.AreEqual(DisplayStyle.None, Display("build-camp")); Assert.AreEqual(DisplayStyle.None, Display("build-housing"));
+ Assert.AreEqual("", ui.Q<Label>("info-reason").text);
+ }
}
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 6a8e5857c..631e54131 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -39,6 +39,7 @@ budget.not_established: "no ministry until {0}"
budget.factor: "spending effect {0}"
budget.vote_needed: "The {0} must approve it: the coalition holds {1} of {2} seats"
budget.no_vote: "The {0} does not vote on the budget"
+budget.vote_advisory: "The {0} votes on it, but its vote does not bind: the coalition holds {1} of {2} seats"
budget.money: "Treasury {0} · debt {1} · foreign currency {2}"
budget.flow: "Taxes {0}, spending {1} and reserve call-up {2} a year"
budget.queued: "Submitted: takes effect at End Turn"
@@ -66,6 +67,7 @@ cabinet.pick: "Appoint to {0}"
cabinet.queued: "Ordered: {0} to {1}, at End Turn"
# Cabinet (promo 04): the body the government answers to, the half circle's legend and its party chips.
cabinet.legislature: "Answerable to the {0} · {1} members"
+cabinet.legislature_advisory: "Consults the {0} · {1} members · its votes do not bind"
cabinet.opposition: "Opposition: {0} seats"
cabinet.majority: "Majority: {0} seats"
cabinet.largest: "Largest party: {0}, {1} seats"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 0111ffa89..9a603ddf6 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -44,6 +44,7 @@ budget.not_established: "אין משרד עד {0}"
budget.factor: "השפעת ההוצאה {0}"
budget.vote_needed: "נדרש אישור של {0}: לקואליציה יש {1} מתוך {2} מנדטים"
budget.no_vote: "{0} אינו מצביע על התקציב"
+budget.vote_advisory: "{0} מצביע עליו, אך הצבעתו אינה מחייבת: לקואליציה יש {1} מתוך {2} מנדטים"
budget.money: "אוצר {0} · חוב {1} · מטבע חוץ {2}"
budget.flow: "מסים {0}, הוצאות {1} וגיוס מילואים {2} בשנה"
budget.queued: "הוגש: ייכנס לתוקף בסיום התור"
@@ -70,6 +71,7 @@ cabinet.no_party: "ללא מפלגה"
cabinet.pick: "מינוי לתפקיד {0}"
cabinet.queued: "ניתנה פקודה: {0} לתפקיד {1}, בסיום התור"
cabinet.legislature: "אחראית בפני {0} · {1} חברים"
+cabinet.legislature_advisory: "מתייעצת עם {0} · {1} חברים · הצבעותיו אינן מחייבות"
cabinet.opposition: "אופוזיציה: {0} מנדטים"
cabinet.majority: "רוב: {0} מנדטים"
cabinet.largest: "המפלגה הגדולה: {0}, {1} מנדטים"