A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Sim: the end report carries the score's parts (Refs #812) (#1964)
Beri2fc0e6900e21
diff --git a/changelog.d/laneMF-812.md b/changelog.d/laneMF-812.mdnew file mode 100644index 000000000..f1561f589--- /dev/null+++ b/changelog.d/laneMF-812.md@@ -0,0 +1 @@+- The end report carries the score's parts (objective points, timing bonuses, prisoner points) beside the total, read from the final state; no screen shows them yet (Refs #812).diff --git a/sim/Statecraft.Sim.Tests/EndReportTests.cs b/sim/Statecraft.Sim.Tests/EndReportTests.csindex a77ada6cd..f3dc2069b 100644--- a/sim/Statecraft.Sim.Tests/EndReportTests.cs+++ b/sim/Statecraft.Sim.Tests/EndReportTests.cs@@ -5,7 +5,7 @@ using Statecraft.Sim;/// <summary>The end report (GDD Phase 7 PR 7, D-H4; #810): a pure reading of the final state. It carries the outcome code, the/// state's score, each objective with the player's date beside the historical date, the national parameters and the one-/// comparison with history Q-END-2 allows, the population against its CBS anchor. The score's parts wait for #809.</summary>+/// comparison with history Q-END-2 allows, the population against its CBS anchor. The score's parts are #809's (ScoreParts).</summary>public class EndReportTests{static readonly Content Real = ContentLoader.Load(RealContentTests.ContentRoot());@@ -31,6 +31,11 @@ public class EndReportTestsAssert.Equal(s.Date, r.Date);Assert.True(s.Score > 0);Assert.Equal(s.Score, r.Score); // the state's own total: no part is recomputed here (#809)+ // The parts are ScoreParts.For's reading of the same state (R-SCORE-001), so they sum to the score.+ Assert.Equal(ScoreParts.For(s).ObjectivePoints, r.ScoreParts.ObjectivePoints);+ Assert.Equal(ScoreParts.For(s).TimingBonuses, r.ScoreParts.TimingBonuses);+ Assert.Equal(ScoreParts.For(s).PrisonerPoints, r.ScoreParts.PrisonerPoints);+ Assert.Equal(r.Score, r.ScoreParts.ObjectivePoints + r.ScoreParts.TimingBonuses + r.ScoreParts.PrisonerPoints);// Every objective in content order, done or not, with its historical date; the player's date only when completed.Assert.Equal(Real.Objectives.Select(o => o.Id), r.Objectives.Select(o => o.Id));var first = Real.Objectives[0];@@ -45,6 +50,23 @@ public class EndReportTestsAssert.Equal(s.Indicators["intl_standing"], r.InternationalSupport);}+ /// <summary>The fixture above has no prisoner points; here a real exchange (Prisoners.Return, the producer) scores some and the+ /// report carries that part.</summary>+ // R-END-005+ [Fact]+ public void ThePrisonerPartCarriesAScoreFromARealExchange()+ {+ var s = Ended();+ s.PrisonersHeld["egypt"] = 2;+ Prisoners.Return(Real, s, "egypt", new List<Cause>());+ var expected = 2 * Real.RulesAt(s.Date).Mvp!.PointsPerPrisonerUnitReturned!.Value;+ Assert.True(expected > 0);+ var r = EndReport.For(Real, s);+ Assert.Equal(expected, r.ScoreParts.PrisonerPoints);+ Assert.Equal(s.Score, r.Score);+ Assert.Equal(r.Score, r.ScoreParts.ObjectivePoints + r.ScoreParts.TimingBonuses + r.ScoreParts.PrisonerPoints);+ }+// R-END-005[Fact]public void ADefeatReportsItsCause()diff --git a/sim/Statecraft.Sim/EndReport.cs b/sim/Statecraft.Sim/EndReport.csindex 8a3a13889..93e82ab5b 100644--- a/sim/Statecraft.Sim/EndReport.cs+++ b/sim/Statecraft.Sim/EndReport.cs@@ -7,8 +7,9 @@ namespace Statecraft.Sim/// <summary>The end report (D-H4; GDD Phase 7 PR 7, #810), folding in #19's legacy report: what the end screen reads once/// <see cref="GameState.GameOver"/> is set. A pure reading of the final state and content (R-END-005): it computes no/// rule and writes nothing, so calling it twice gives the same report and leaves the hash as it was. The score is the- /// state's own total; its parts wait for #809, because <see cref="Objectives.Record"/> scores with the turn-start rules,- /// which a later reading cannot always recover across an era boundary.</summary>+ /// state's own total and its parts are <see cref="Sim.ScoreParts.For"/>'s reading of what the state recorded as it scored+ /// (#809, R-SCORE-001): <see cref="Objectives.Record"/> scores with the turn-start rules, which a later reading cannot+ /// always recover across an era boundary, so nothing is recomputed here.</summary>public sealed class EndReport{/// <summary>Why the game ended, one of the <see cref="GameOverCodes"/> (PlayerText.GameOver words it).</summary>@@ -17,6 +18,8 @@ namespace Statecraft.Simpublic DateTime Date { get; }/// <summary><see cref="GameState.Score"/> as the game left it.</summary>public int Score { get; }+ /// <summary>The parts of <see cref="Score"/> (R-SCORE-001); they sum to it.</summary>+ public ScoreParts ScoreParts { get; }/// <summary>Every objective, in objectives.yaml's order (Q-CARD-2), completed or not.</summary>public IReadOnlyList<EndObjective> Objectives { get; }/// <summary>The GDD's two national parameters (0 to 1: morale shown as Social cohesion, intl_standing as International@@ -29,10 +32,10 @@ namespace Statecraft.Sim/// before <see cref="Date"/>, with its sources; null when the game ended before the first anchor.</summary>public PopulationAnchor? PopulationHistory { get; }- EndReport(string outcome, DateTime date, int score, IReadOnlyList<EndObjective> objectives, double cohesion, double support,+ EndReport(string outcome, DateTime date, int score, ScoreParts scoreParts, IReadOnlyList<EndObjective> objectives, double cohesion, double support,double population, PopulationAnchor? history){- Outcome = outcome; Date = date; Score = score; Objectives = objectives; SocialCohesion = cohesion;+ Outcome = outcome; Date = date; Score = score; ScoreParts = scoreParts; Objectives = objectives; SocialCohesion = cohesion;InternationalSupport = support; Population = population; PopulationHistory = history;}@@ -47,7 +50,7 @@ namespace Statecraft.Sim: new EndObjective(o.Id, o.Card, o.ReferenceDate, null, null)).ToList();// 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, objectives, s.Indicators["morale"], s.Indicators["intl_standing"],+ return new EndReport(s.GameOver, s.Date, s.Score, Sim.ScoreParts.For(s), objectives, s.Indicators["morale"], s.Indicators["intl_standing"],s.TotalPopulation, history);}}