namespace Mr.BrickAdventures.Progression; /// /// The authored ordering of Levels that defines progression. Shared by every Playthrough — it is /// authored data, not per-Playthrough state, and carries no scene or presentation detail. /// public sealed class Campaign { private readonly List _levels; private Campaign(List levels) => _levels = levels; public static Campaign Of(IEnumerable levels) { var ordered = levels.ToList(); if (ordered.Count == 0) throw new ArgumentException("A campaign needs at least one level.", nameof(levels)); if (ordered.Distinct().Count() != ordered.Count) throw new ArgumentException("A campaign cannot list the same level twice.", nameof(levels)); return new Campaign(ordered); } public LevelId First => _levels[0]; /// /// The Level after , or null if it is the last one or not in this /// Campaign at all. /// public LevelId? Next(LevelId level) { var at = _levels.IndexOf(level); return at >= 0 && at + 1 < _levels.Count ? _levels[at + 1] : null; } }