package club.clubk.ktag.apps.sentry

import android.content.Context
import androidx.preference.PreferenceManager

data class SentryConfig(
    val team: String,
    val cooldownMs: Long,
    val playDetectionTone: Boolean
) {
    companion object {
        fun fromPreferences(context: Context): SentryConfig {
            val prefs = PreferenceManager.getDefaultSharedPreferences(context)
            val team = prefs.getString(SentryPreferenceKeys.TEAM, "asblue") ?: "asblue"
            val cooldownS = prefs.getString(SentryPreferenceKeys.COOLDOWN_S, "5")?.toLongOrNull() ?: 5L
            val playDetectionTone = prefs.getBoolean(SentryPreferenceKeys.PLAY_DETECTION_TONE, true)
            return SentryConfig(team = team, cooldownMs = cooldownS * 1000L, playDetectionTone = playDetectionTone)
        }
    }
}
