StreakManager API

final class StreakManager {
    static let shared: StreakManager

    func recordPlay()  // ゲーム開始時に呼出
    func refreshStreakOnLaunch()  // 起動時 & scenePhase(.active)
    func currentStreak() -> Int
}

UserDefaults キー

キー用途
lastPlayedDate最終プレイ日(YYYY-MM-DD 形式)
streakCount連続プレイ日数

処理フロー

  1. recordPlay(): 日付が変わっていれば前日プレイ済みなら +1、なければリセット
  2. refreshStreakOnLaunch(): 最終プレイから2日以上経過していればリセット(途切れ)
  3. HomeView の onAppear と scenePhase 変化で呼出

変更履歴

バージョン日付変更内容
1.02026-05-09初版作成