feat(progression): Profile aggregate (slice 4)
best times only improve; achievement unlock announces on the transition only, so popup/Steam subscribers cannot double-fire; statistics are increase-only (IncrementStat took any int). RelockAchievement is console-only and documented as not reaching Steam - a Steam achievement cannot be un-earned, so the disagreement is permanent and deliberate. refactor: extract EventLog, composed by both aggregates now that the duplication actually exists. 34 tests.
This commit is contained in:
21
progression/AchievementId.cs
Normal file
21
progression/AchievementId.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace Mr.BrickAdventures.Progression;
|
||||
|
||||
/// <summary>
|
||||
/// Stable identity of an Achievement, matching the authored <c>AchievementResource</c> id that Steam
|
||||
/// also keys on.
|
||||
/// </summary>
|
||||
public readonly struct AchievementId : IEquatable<AchievementId>
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
private AchievementId(string value) => Value = value;
|
||||
|
||||
public static AchievementId Of(string value) => string.IsNullOrWhiteSpace(value)
|
||||
? throw new ArgumentException("An achievement id cannot be blank.", nameof(value))
|
||||
: new AchievementId(value);
|
||||
|
||||
public bool Equals(AchievementId other) => string.Equals(Value, other.Value, StringComparison.Ordinal);
|
||||
public override bool Equals(object? obj) => obj is AchievementId 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