Files
przygody-pana-cegly/progression/AchievementId.cs
Gabriel Kaszewski 05149bb4a9 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.
2026-07-28 18:56:58 +02:00

22 lines
916 B
C#

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;
}