namespace Mr.BrickAdventures.Progression;
///
/// A completion time for one Level. Strictly positive — a zero time means the clock was never
/// running, which is a defect rather than a fast run.
///
public readonly struct LevelTime : IEquatable
{
public double Seconds { get; }
private LevelTime(double seconds) => Seconds = seconds;
public static LevelTime Of(double seconds) => double.IsFinite(seconds) && seconds > 0
? new LevelTime(seconds)
: throw new ArgumentOutOfRangeException(nameof(seconds), seconds, "A completion time must be a finite positive number.");
public bool IsFasterThan(LevelTime other) => Seconds < other.Seconds;
public bool Equals(LevelTime other) => Seconds.Equals(other.Seconds);
public override bool Equals(object? obj) => obj is LevelTime other && Equals(other);
public override int GetHashCode() => Seconds.GetHashCode();
public override string ToString() => $"{Seconds:0.###}s";
}