feat(progression): Profile aggregate (slice 4)
best times only improve; achievement unlock announces on the transition only, so popup/Steam subscribers cannot double-fire; statistics are increase-only (IncrementStat took any int). RelockAchievement is console-only and documented as not reaching Steam - a Steam achievement cannot be un-earned, so the disagreement is permanent and deliberate. refactor: extract EventLog, composed by both aggregates now that the duplication actually exists. 34 tests.
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Mr.BrickAdventures.Progression;
|
||||
/// </remarks>
|
||||
public sealed class Playthrough
|
||||
{
|
||||
private readonly List<ProgressionEvent> _events = new();
|
||||
private readonly EventLog _events = new();
|
||||
|
||||
private Playthrough(PlaythroughId id, LevelId currentLevel, Lives lives)
|
||||
{
|
||||
@@ -114,17 +114,12 @@ public sealed class Playthrough
|
||||
Lives = Lives.Decrement();
|
||||
|
||||
if (Lives.IsExhausted)
|
||||
_events.Add(new RunEnded());
|
||||
_events.Raise(new RunEnded());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes the events raised since the last drain, clearing them. The composition root drains
|
||||
/// once after each use case and republishes.
|
||||
/// </summary>
|
||||
public IReadOnlyList<ProgressionEvent> DrainEvents()
|
||||
{
|
||||
var drained = _events.ToList();
|
||||
_events.Clear();
|
||||
return drained;
|
||||
}
|
||||
public IReadOnlyList<ProgressionEvent> DrainEvents() => _events.Drain();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user