import 'package:block_seasons/game/daily/daily_reward.dart';
import 'package:block_seasons/game/models/booster.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  final cal = DailyRewardCalendar();

  DateTime d(int day) => DateTime(2026, 6, day);

  test('first ever claim is day 1', () {
    final r = cal.resolve(lastClaimedYmd: null, storedDay: 0, today: d(18));
    expect(r.claimable, isTrue);
    expect(r.day, 1);
  });

  test('claiming again the same day is not claimable', () {
    final r = cal.resolve(
        lastClaimedYmd: '2026-06-18', storedDay: 1, today: d(18));
    expect(r.claimable, isFalse);
  });

  test('a consecutive day advances the calendar', () {
    final r = cal.resolve(
        lastClaimedYmd: '2026-06-18', storedDay: 3, today: d(19));
    expect(r.claimable, isTrue);
    expect(r.day, 4);
  });

  test('day 7 wraps back to day 1', () {
    final r = cal.resolve(
        lastClaimedYmd: '2026-06-18', storedDay: 7, today: d(19));
    expect(r.day, 1);
  });

  test('a missed day resets to day 1', () {
    final r = cal.resolve(
        lastClaimedYmd: '2026-06-18', storedDay: 4, today: d(20));
    expect(r.claimable, isTrue);
    expect(r.day, 1);
  });

  test('reward table covers days 1..7 and day 7 is the jackpot', () {
    expect(cal.rewardFor(1), {BoosterType.hammer: 1});
    expect(cal.rewardFor(7),
        {BoosterType.hammer: 2, BoosterType.shuffle: 2, BoosterType.lineBomb: 2});
  });

  test('ymd formats a date as YYYY-MM-DD', () {
    expect(cal.ymd(DateTime(2026, 6, 7)), '2026-06-07');
  });
}
