feat(progression): Attempt ledger with terminal-outcome guard (slice 2)
Attempt carries its LevelId so settlement decides First Clear vs Replay without trusting the caller. Outcome is terminal and refuses to change: one death costs one life, one completion banks once. Coins.Zero/Add driven out by the ledger rather than added up front. 21 tests. ADR-0005: Playthrough settles Attempts, has no LoseLife.
This commit is contained in:
@@ -10,10 +10,14 @@ public readonly struct Coins : IEquatable<Coins>
|
||||
|
||||
private Coins(int value) => Value = value;
|
||||
|
||||
public static readonly Coins Zero = new(0);
|
||||
|
||||
public static Coins Of(int value) => value < 0
|
||||
? throw new ArgumentOutOfRangeException(nameof(value), value, "Coins cannot be negative.")
|
||||
: new Coins(value);
|
||||
|
||||
public Coins Add(Coins other) => new(Value + other.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts <paramref name="amount"/>. Returns false when the amount exceeds what is held,
|
||||
/// leaving <paramref name="remaining"/> untouched rather than clamping to zero.
|
||||
|
||||
Reference in New Issue
Block a user