PlayerProgressionService constructor

PlayerProgressionService({
  1. required StorageService storage,
  2. required List<LevelDefinition> levelCurve,
  3. RewardTransactionPipeline? pipeline,
  4. AsyncActionGuard? guard,
  5. String? storageKey,
  6. int capacity = 200,
})

Implementation

PlayerProgressionService({
  required this.storage,
  required List<LevelDefinition> levelCurve,
  this.pipeline,
  AsyncActionGuard? guard,
  String? storageKey,
  this.capacity = 200,
}) : _curve = List.unmodifiable(
       [...levelCurve]..sort((a, b) => a.level.compareTo(b.level)),
     ),
     _guard = guard ?? AsyncActionGuard(),
     _key = storageKey ?? StorageKeys.playerProgressionV1 {
  if (capacity <= 0) {
    throw ArgumentError.value(capacity, 'capacity', 'must be > 0');
  }
  final error = validateLevelCurve(_curve);
  if (error != null) {
    throw ArgumentError(error.message);
  }
  // BUG-40: see EconomyWallet's constructor for why this can't wait for
  // onInit() alone.
  _hydrate();
  _recompute();
}