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.

CLI: the Briefing's option lines follow the player's appointments (Refs #3031) (#3036)

Eyal Golanf78941362b0d
diff --git a/changelog.d/3031-cli-option-lines.md b/changelog.d/3031-cli-option-lines.md
new file mode 100644
index 000000000..b4ecf5e80
--- /dev/null
+++ b/changelog.d/3031-cli-option-lines.md
@@ -0,0 +1,4 @@
+### Fixed
+
+- Developer CLI (#3031): the Briefing's option lines name office holders as the game does, following the player's
+ appointments. They named the historical holder for the date.
diff --git a/sim/Statecraft.Cli/Briefing.cs b/sim/Statecraft.Cli/Briefing.cs
index 5bf77a5a9..389131457 100644
--- a/sim/Statecraft.Cli/Briefing.cs
+++ b/sim/Statecraft.Cli/Briefing.cs
@@ -4,7 +4,8 @@ namespace Statecraft.Cli
{
/// <summary>The turn's briefing in the text front end: the date, government and security level, then each pending
/// card with its options. A card's title and text are the game's (#3022): EventSystem.Title and EventSystem.Render with
- /// the state, so a road variant's, else the early or late text, with names following the player's appointments.</summary>
+ /// the state, so a road variant's, else the early or late text, with names following the player's appointments.
+ /// Its options are filled as the game fills them (#3031): Cabinet.Fill with the state, so they name the player's appointees too.</summary>
public static class Briefing
{
public static void Write(Content c, GameState s, TextWriter output)
@@ -17,7 +18,7 @@ namespace Statecraft.Cli
var e = c.Events.First(x => x.Id == id);
var fillDate = EventSystem.FillDate(e, s.Date); // after the window ends, name the last in-window holder
output.WriteLine($" EVENT {e.Id}: {EventSystem.Title(c, s, e)} - {EventSystem.Render(c, s, e)}");
- foreach (var o in e.Options) output.WriteLine($" {o.Id}: {Offices.Fill(c, o.Text, fillDate)}");
+ foreach (var o in e.Options) output.WriteLine($" {o.Id}: {Cabinet.Fill(c, s, o.Text, fillDate)}");
}
}
}
diff --git a/sim/Statecraft.Sim.Tests/BriefingCliTests.cs b/sim/Statecraft.Sim.Tests/BriefingCliTests.cs
index 4f508028f..1de8459bc 100644
--- a/sim/Statecraft.Sim.Tests/BriefingCliTests.cs
+++ b/sim/Statecraft.Sim.Tests/BriefingCliTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using Statecraft.Cli;
@@ -16,6 +17,30 @@ public class BriefingCliTests
return output.ToString().Replace("\r\n", "\n").Split('\n').Single(x => x.StartsWith($" EVENT {id}: ", StringComparison.Ordinal));
}
+ static string OptionLine(Content c, GameState s, string optionId)
+ {
+ var output = new StringWriter();
+ Briefing.Write(c, s, output);
+ return output.ToString().Replace("\r\n", "\n").Split('\n').Single(x => x.StartsWith($" {optionId}: ", StringComparison.Ordinal));
+ }
+
+ // #3031: an option line names an office's holder as the game does (Cabinet.Fill with the state, EventCardPresenter),
+ // so the player's appointee and not the historical holder. CabinetTests' fixture: Loy Alist replaces Def Two.
+ // Red without it: the option line named Def Two.
+ [Fact]
+ public void AnOptionLineNamesThePlayersAppointee()
+ {
+ var c = CabinetTests.Load(new Dictionary<string, string>
+ {
+ ["drought.yaml"] = ValidationTests.Event.Replace("text: Wait for rain", "text: Ask {finance_minister} to wait for rain")
+ });
+ var s = Simulation.NewGame(c, 42, Mode.Historical);
+ s.Date = new DateTime(1948, 6, 1);
+ Assert.Null(Cabinet.Appoint(c, s, "finance_minister", "loyalist", new List<Cause>()));
+ s.PendingEvents.Add("drought");
+ Assert.Equal(" wait: Ask Loy Alist to wait for rain", OptionLine(c, s, "wait"));
+ }
+
// R-ENEMY-007: a card shown after its window prints its late text. Real content, rhodes_talks on its `to`.
// Red without it: the Briefing printed the ordinary text.
[Fact]
diff --git a/sim/Statecraft.Sim.Tests/CabinetTests.cs b/sim/Statecraft.Sim.Tests/CabinetTests.cs
index 9e692d5d3..6f1d75e96 100644
--- a/sim/Statecraft.Sim.Tests/CabinetTests.cs
+++ b/sim/Statecraft.Sim.Tests/CabinetTests.cs
@@ -45,7 +45,7 @@ public class CabinetTests
offices: []
";
- static Content Load(Dictionary<string, string>? events = null) =>
+ internal static Content Load(Dictionary<string, string>? events = null) =>
ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["people.yaml"] = Fixture.Files["people.yaml"] + ExtraPeople }, events));
static readonly Content C = Load();