Files
przygody-pana-cegly/progression/Lives.cs
Gabriel Kaszewski 9767941c65 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.
2026-07-28 18:27:26 +02:00

25 lines
847 B
C#

namespace Mr.BrickAdventures.Progression;
/// <summary>
/// Lives remaining in a Playthrough. Never negative.
/// </summary>
/// <remarks>
/// Decrementing at zero floors rather than failing — unlike <see cref="Coins"/>, where a shortfall
/// is a game rule the caller must handle. Flooring here is purely defensive; the invariant that one
/// death costs exactly one life is enforced by the Attempt's outcome, not by this type.
/// </remarks>
public readonly struct Lives
{
public int Value { get; }
private Lives(int value) => Value = value;
public static Lives Of(int value) => value < 0
? throw new ArgumentOutOfRangeException(nameof(value), value, "Lives cannot be negative.")
: new Lives(value);
public bool IsExhausted => Value == 0;
public Lives Decrement() => new(Value == 0 ? 0 : Value - 1);
}