Average time calculated with just the victories

This commit is contained in:
OsirisInferi 2020-12-27 22:05:23 +01:00 committed by Lucas Nunes
parent 6a9da20c20
commit f2cf102917
2 changed files with 14 additions and 2 deletions

View file

@ -6,6 +6,7 @@ data class StatsModel(
@StringRes val title: Int,
val totalGames: Int,
val totalTime: Long,
val victoryTime: Long,
val averageTime: Long,
val shortestTime: Long,
val mines: Int,

View file

@ -79,6 +79,7 @@ class StatsViewModel(
title = 0,
totalGames = size,
totalTime = 0,
victoryTime = 0,
averageTime = 0,
shortestTime = 0,
mines = 0,
@ -90,7 +91,16 @@ class StatsViewModel(
0,
acc.totalGames,
acc.totalTime + value.duration,
0,
victoryTime = if (value.victory != 0){
if (acc.victoryTime == 0L) {
value.duration
} else {
acc.victoryTime + value.duration
}
} else {
acc.victoryTime
},
averageTime = 0,
shortestTime = if (value.victory != 0) {
if (acc.shortestTime == 0L) {
value.duration
@ -105,12 +115,13 @@ class StatsViewModel(
acc.openArea + value.openArea,
)
}
result.copy(averageTime = result.totalTime / result.totalGames)
result.copy(averageTime = result.victoryTime / result.victory)
} else {
StatsModel(
title = 0,
totalGames = 0,
totalTime = 0,
victoryTime = 0,
averageTime = 0,
shortestTime = 0,
mines = 0,