import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../data/streak.dart';
import 'providers.dart';

/// Daily streak state; advanced once per stage attempt (win or lose).
class StreakNotifier extends Notifier<StreakState> {
  @override
  StreakState build() => ref.read(saveRepositoryProvider).streak;

  Future<void> onStagePlayed(DateTime now) async {
    final next = advanceStreak(state, now);
    await ref.read(saveRepositoryProvider).saveStreak(next);
    state = next;
  }
}
