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:
21
progression/SkillId.cs
Normal file
21
progression/SkillId.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace Mr.BrickAdventures.Progression;
|
||||
|
||||
/// <summary>
|
||||
/// Stable identity of a Skill, matching the authored <c>SkillData</c> name that saves already
|
||||
/// reference. Identity only — the upgrade table and presentation stay in the authored asset.
|
||||
/// </summary>
|
||||
public readonly struct SkillId : IEquatable<SkillId>
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
private SkillId(string value) => Value = value;
|
||||
|
||||
public static SkillId Of(string value) => string.IsNullOrWhiteSpace(value)
|
||||
? throw new ArgumentException("A skill id cannot be blank.", nameof(value))
|
||||
: new SkillId(value);
|
||||
|
||||
public bool Equals(SkillId other) => string.Equals(Value, other.Value, StringComparison.Ordinal);
|
||||
public override bool Equals(object? obj) => obj is SkillId other && Equals(other);
|
||||
public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(Value ?? string.Empty);
|
||||
public override string ToString() => Value;
|
||||
}
|
||||
Reference in New Issue
Block a user