SagaProgress class

Aggregate progression model for all known levels.

Available extensions

Constructors

SagaProgress({required int currentMaxUnlockedLevelId, required Map<int, LevelProgress> levels, Map<String, dynamic> extra = const {}, int spentStars = 0})
Defensively copies levels and extra as unmodifiable maps, so a caller mutating a returned map cannot silently rewrite "persisted" state — it throws instead. This mirrors the inventory repository's List.unmodifiable guarantee. The cost is that the constructor is no longer const.
SagaProgress.initial()
Creates the baseline progress with level 0 unlocked. Note that level 0 is the first level.
factory

Properties

availableStars int

Available on SagaProgress, provided by the SagaProgressStars extension

Stars earned and not yet spent: totalStars minus SagaProgress.spentStars.
no setter
currentMaxUnlockedLevelId int
final
extra Map<String, dynamic>
Host-owned data the package stores but never interprets.
final
hashCode int
Deliberately shallow: hashing every record would make the cheap half of a diff as expensive as the expensive half. Equal objects still agree, which is all hashCode must guarantee.
no setteroverride
levels Map<int, LevelProgress>
Per-level records, keyed by level id. Unmodifiable.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
spentStars int
Stars the player has spent. Never exceeds SagaProgressStars.totalStars.
final
totalStars int

Available on SagaProgress, provided by the SagaProgressStars extension

Total stars from all completed levels.
no setter

Methods

completedCountInRange(int startLevelId, int count) int

Available on SagaProgress, provided by the SagaProgressStars extension

Calculates how many levels are completed in [startLevelId, startLevelId + count).
copyWith({int? currentMaxUnlockedLevelId, Map<int, LevelProgress>? levels, Map<String, dynamic>? extra, int? spentStars}) SagaProgress
Returns a copy with selective field overrides.
isRangePerfect(int startLevelId, int count, {int perLevel = kMaxLevelStars}) bool

Available on SagaProgress, provided by the SagaProgressStars extension

Checks if every level in [startLevelId, startLevelId + count) is completed and has perLevel stars. If the range is empty (count == 0), returns true.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
spendStars(int amount) SagaProgress?
Spends amount stars, or returns null when fewer than amount are available.
starsInRange(int startLevelId, int count) int

Available on SagaProgress, provided by the SagaProgressStars extension

Calculates the sum of stars in the interval [startLevelId, startLevelId + count).
toJson() Map<String, dynamic>
Serializes the progress tree for repository storage.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
Compared by value.
override

Static Methods

fromJson(Map<String, dynamic> json, {void onClamp(SagaProgressClamp clamp)?}) SagaProgress
Restores progress from a serialized payload.
migrateFrom1x(Map<String, dynamic> json, {int maxBackfill = 10000}) SagaProgress
Loads a save written by 1.x without clamping its unlock pointer.