Files
przygody-pana-cegly/progression/PlaythroughSnapshot.cs
Gabriel Kaszewski 003ec4b010 feat(progression): snapshots, ports, in-memory adapters (slice 5)
flat snapshot record per aggregate - separate files mean saving a run
doesn't rewrite the Profile, deleting a slot is deleting a file, and a
corrupt slot doesn't cost achievements or best times.

snapshots hold primitives so Restore re-runs the value-object factories;
a serialiser building LevelId directly would bypass every guard.

LoadResult has three outcomes: Absent != Corrupt. Collapsing them is the
bug where a version bump made ContinueGame overwrite the save.

Profile.Restore writes collections directly - replaying UnlockAchievement
would re-fire popups and Steam pushes on every load. 44 tests.
2026-07-28 19:02:41 +02:00

20 lines
829 B
C#

namespace Mr.BrickAdventures.Progression;
/// <summary>
/// A Playthrough's state as plain data, for crossing the persistence seam.
/// </summary>
/// <remarks>
/// Deliberately primitives rather than value objects. A serialiser constructing <see cref="LevelId"/>
/// or <see cref="Coins"/> directly would bypass their factories and every guard in them, so instead
/// <see cref="Playthrough.Restore"/> re-runs those factories and a corrupt file fails at the domain
/// edge. Carries no version field — versioning and migration belong to the store adapter, so the
/// domain only ever knows the current shape.
/// </remarks>
public sealed record PlaythroughSnapshot(
Guid Id,
int Lives,
int Bank,
string CurrentLevel,
IReadOnlyDictionary<string, int> OwnedSkills,
IReadOnlyList<string> ClearedLevels);