feat(progression): Coins, LevelTime, SkillLevel core invariants (slice 1)
three bug-encoding invariants, one red/green cycle each: - Coins.TrySubtract fails instead of clamping - LevelTime rejects zero (continued-run zero best-times) - SkillLevel has no zero (unowned is absence, not Level=1) plan: drop signed NetCoins; add Attempt outcome as idempotency guard
This commit is contained in:
16
progression/SkillLevel.cs
Normal file
16
progression/SkillLevel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Mr.BrickAdventures.Progression;
|
||||
|
||||
/// <summary>
|
||||
/// How far a Skill has been upgraded. Starts at one; there is no zero, because a Playthrough
|
||||
/// records only the Skills it owns and absence from that record is what "unowned" means.
|
||||
/// </summary>
|
||||
public readonly struct SkillLevel
|
||||
{
|
||||
public int Value { get; }
|
||||
|
||||
private SkillLevel(int value) => Value = value;
|
||||
|
||||
public static SkillLevel Of(int value) => value < 1
|
||||
? throw new ArgumentOutOfRangeException(nameof(value), value, "A skill level starts at 1; unowned is absence, not level 0.")
|
||||
: new SkillLevel(value);
|
||||
}
|
||||
Reference in New Issue
Block a user