feat(progression): remaining slice 1 value objects

Lives (floors at zero, exhaustion observable), LevelId, SkillId,
PlaythroughId (never self-generates, keeps tests deterministic),
StatName enum, LevelTime rejects NaN/infinity.

14 tests. Arithmetic/comparison members deferred to the slices whose
behaviour needs them rather than added speculatively.
This commit is contained in:
2026-07-28 18:27:26 +02:00
parent 313a5315b1
commit 9767941c65
12 changed files with 196 additions and 3 deletions

View File

@@ -0,0 +1,25 @@
namespace Mr.BrickAdventures.Progression;
/// <summary>
/// Identity of one Playthrough. Several Playthroughs exist at once and the player picks between
/// them; "slot" is the word the UI uses for the same thing.
/// </summary>
/// <remarks>
/// Deliberately has no factory that generates a value. Ids are created by an adapter and passed in,
/// so nothing in the domain depends on a source of randomness.
/// </remarks>
public readonly struct PlaythroughId : IEquatable<PlaythroughId>
{
public Guid Value { get; }
private PlaythroughId(Guid value) => Value = value;
public static PlaythroughId Of(Guid value) => value == Guid.Empty
? throw new ArgumentException("A playthrough id cannot be the empty guid.", nameof(value))
: new PlaythroughId(value);
public bool Equals(PlaythroughId other) => Value.Equals(other.Value);
public override bool Equals(object? obj) => obj is PlaythroughId other && Equals(other);
public override int GetHashCode() => Value.GetHashCode();
public override string ToString() => Value.ToString();
}