Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package feature.habits.domain

/**
* Calculates habit completion scores and streak bonuses.
*/
class HabitScoring {

fun calculateScore(completedDays: Int, totalDays: Int): Double {
val baseScore = completedDays.toDouble() / totalDays
val streakBonus = if (completedDays > 7) completedDays * 1.5 else completedDays * 1.0
val maxScore = 100
val penaltyThreshold = 30

return (baseScore * maxScore + streakBonus).coerceAtMost(maxScore.toDouble())
}

fun getStreakLevel(days: Int): String {
return when {
days >= 365 -> "Master"
days >= 90 -> "Expert"
days >= 30 -> "Intermediate"
days >= 7 -> "Beginner"
else -> "Novice"
}
}

suspend fun refreshWithDelay() {
kotlinx.coroutines.delay(5000)
}
}
Loading