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.

End screen: the prisoners returned (Refs #812) (#1969)

Beria53b57d7beec
diff --git a/changelog.d/laneMH-812.md b/changelog.d/laneMH-812.md
new file mode 100644
index 000000000..f6ce89ed4
--- /dev/null
+++ b/changelog.d/laneMH-812.md
@@ -0,0 +1,2 @@
+- The end screen shows the prisoners returned (Q-END-3): one line, "Prisoners returned:" and the count in people as the
+ Defence screen counts them, only when some prisoners went home. The end report carries the count (#812).
diff --git a/sim/Statecraft.Sim.Tests/EndReportTests.cs b/sim/Statecraft.Sim.Tests/EndReportTests.cs
index f3dc2069b..12a2a8585 100644
--- a/sim/Statecraft.Sim.Tests/EndReportTests.cs
+++ b/sim/Statecraft.Sim.Tests/EndReportTests.cs
@@ -122,6 +122,18 @@ public class EndReportTests
Assert.Null(EndReport.For(Real, early).PopulationHistory);
}
+ // R-POW-004, Q-END-3: the prisoners returned, in people as Defence shows them, over every front's exchange.
+ [Fact]
+ public void TheReportCarriesThePrisonersReturned()
+ {
+ var s = Ended();
+ Assert.Equal(0, EndReport.For(Real, s).PrisonersReturned);
+ s.PrisonersReturned["lebanon"] = 4; s.PrisonersReturned["egypt"] = 2;
+ // What the Defence screen shows for these six units (DefencePresenter: units times rules.yaml's 1,000 people a unit).
+ Assert.Equal(1000, Real.RulesAt(s.Date).Mvp!.PeoplePerUnit);
+ Assert.Equal(6000, EndReport.For(Real, s).PrisonersReturned);
+ }
+
[Fact]
public void AGameStillOnHasNoReport()
{
diff --git a/sim/Statecraft.Sim/EndReport.cs b/sim/Statecraft.Sim/EndReport.cs
index 93e82ab5b..17bbcd79b 100644
--- a/sim/Statecraft.Sim/EndReport.cs
+++ b/sim/Statecraft.Sim/EndReport.cs
@@ -31,12 +31,16 @@ namespace Statecraft.Sim
/// <summary>The one comparison with history (Q-END-2, R-END-006): the latest CBS anchor (population.yaml) dated on or
/// before <see cref="Date"/>, with its sources; null when the game ended before the first anchor.</summary>
public PopulationAnchor? PopulationHistory { get; }
+ /// <summary>The prisoners returned in the exchanges (Q-END-3, R-POW-004), in people as Defence shows them
+ /// (<see cref="GameState.PrisonersReturned"/> units times the people per unit); 0 when none went home.</summary>
+ public int PrisonersReturned { get; }
EndReport(string outcome, DateTime date, int score, ScoreParts scoreParts, IReadOnlyList<EndObjective> objectives, double cohesion, double support,
- double population, PopulationAnchor? history)
+ double population, PopulationAnchor? history, int prisonersReturned)
{
Outcome = outcome; Date = date; Score = score; ScoreParts = scoreParts; Objectives = objectives; SocialCohesion = cohesion;
InternationalSupport = support; Population = population; PopulationHistory = history;
+ PrisonersReturned = prisonersReturned;
}
/// <summary>The report of a game that has ended; a game still on has none.</summary>
@@ -51,7 +55,7 @@ namespace Statecraft.Sim
// The anchors are few and dated; the latest one not after the end is the comparison (ties cannot happen: dates are unique).
var history = c.PopulationAnchors.Where(a => a.Date <= s.Date).OrderBy(a => a.Date).LastOrDefault();
return new EndReport(s.GameOver, s.Date, s.Score, Sim.ScoreParts.For(s), objectives, s.Indicators["morale"], s.Indicators["intl_standing"],
- s.TotalPopulation, history);
+ s.TotalPopulation, history, s.PrisonersReturned.Values.Sum() * (c.RulesAt(s.Date).Mvp?.PeoplePerUnit ?? 0)); // no prisoners without the GDD rules
}
}
diff --git a/unity/Assets/Scripts/UI/EndScreenPresenter.cs b/unity/Assets/Scripts/UI/EndScreenPresenter.cs
index 1093ee91a..285cc2ad8 100644
--- a/unity/Assets/Scripts/UI/EndScreenPresenter.cs
+++ b/unity/Assets/Scripts/UI/EndScreenPresenter.cs
@@ -69,7 +69,8 @@ namespace Statecraft.Game.UI
public bool ClosedThisFrame => closedAt == UnityEngine.Time.frameCount;
/// <summary>The screen's lines for an ended game, in order: the outcome, the score, one per objective, Social cohesion,
- /// International Support and the population with its CBS anchor. Every value is the report's.</summary>
+ /// International Support, the population with its CBS anchor and, when some went home, the prisoners returned. Every
+ /// value is the report's.</summary>
public static IReadOnlyList<(string Name, string Text)> Lines(Content c, GameState s, UiText t)
{
var r = EndReport.For(c, s);
@@ -94,6 +95,7 @@ namespace Statecraft.Game.UI
lines.Add(("population", r.PopulationHistory is PopulationAnchor a
? t.Format("end.population_history", People(r.Population), Date(a.Date), People(a.Jews))
: t.Format("end.population", People(r.Population))));
+ if (r.PrisonersReturned > 0) lines.Add(("prisoners", t.Format("defence.prisoners_returned", r.PrisonersReturned))); // Q-END-3; Defence's own string
return lines;
}
diff --git a/unity/Assets/Tests/EditMode/EndScreenTests.cs b/unity/Assets/Tests/EditMode/EndScreenTests.cs
index a902b9226..42647568e 100644
--- a/unity/Assets/Tests/EditMode/EndScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/EndScreenTests.cs
@@ -132,6 +132,21 @@ public class EndScreenTests
Date(anchor.Date), anchor.Jews.ToString("N0", System.Globalization.CultureInfo.InvariantCulture)), k.Line("population"));
}
+ // Q-END-3: the prisoners returned, worded as Defence words them, only when some went home (no zero row).
+ [Test]
+ public void ShowsThePrisonersReturnedOnlyWhenSomeWentHome()
+ {
+ using (var none = new Kit(En, Ended))
+ CollectionAssert.DoesNotContain(none.Ui.Q<ScrollView>("end-screen-rows").Children().Select(x => x.name), "end-screen-prisoners");
+ using var k = new Kit(En, s => { Ended(s); s.PrisonersReturned["lebanon"] = 4; });
+ Assert.AreEqual("Prisoners returned: 4,000", k.Line("prisoners"));
+ Assert.AreEqual("שבויים שהוחזרו: \u200e4,000\u200e", EndScreenPresenter.Lines(C, k.Bridge.State, He).Single(l => l.Name == "prisoners").Text);
+ // The same count as the Defence screen shows over the same state.
+ k.Q("screen-defence").style.display = DisplayStyle.Flex; // open, as ScreenNav opens it (a hidden screen does not re-render)
+ using (new DefencePresenter(k.Ui.Root, k.Bridge, En))
+ Assert.AreEqual(k.Ui.Q<Label>("prisoners-returned").text, k.Line("prisoners"));
+ }
+
[Test]
public void CloseRebuildAndTheFirstNewGamePressKeepTheStateAndTheSave()
{