Average time calculated with just the victories
This commit is contained in:
parent
6a9da20c20
commit
f2cf102917
2 changed files with 14 additions and 2 deletions
|
@ -6,6 +6,7 @@ data class StatsModel(
|
||||||
@StringRes val title: Int,
|
@StringRes val title: Int,
|
||||||
val totalGames: Int,
|
val totalGames: Int,
|
||||||
val totalTime: Long,
|
val totalTime: Long,
|
||||||
|
val victoryTime: Long,
|
||||||
val averageTime: Long,
|
val averageTime: Long,
|
||||||
val shortestTime: Long,
|
val shortestTime: Long,
|
||||||
val mines: Int,
|
val mines: Int,
|
||||||
|
|
|
@ -79,6 +79,7 @@ class StatsViewModel(
|
||||||
title = 0,
|
title = 0,
|
||||||
totalGames = size,
|
totalGames = size,
|
||||||
totalTime = 0,
|
totalTime = 0,
|
||||||
|
victoryTime = 0,
|
||||||
averageTime = 0,
|
averageTime = 0,
|
||||||
shortestTime = 0,
|
shortestTime = 0,
|
||||||
mines = 0,
|
mines = 0,
|
||||||
|
@ -90,7 +91,16 @@ class StatsViewModel(
|
||||||
0,
|
0,
|
||||||
acc.totalGames,
|
acc.totalGames,
|
||||||
acc.totalTime + value.duration,
|
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) {
|
shortestTime = if (value.victory != 0) {
|
||||||
if (acc.shortestTime == 0L) {
|
if (acc.shortestTime == 0L) {
|
||||||
value.duration
|
value.duration
|
||||||
|
@ -105,12 +115,13 @@ class StatsViewModel(
|
||||||
acc.openArea + value.openArea,
|
acc.openArea + value.openArea,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
result.copy(averageTime = result.totalTime / result.totalGames)
|
result.copy(averageTime = result.victoryTime / result.victory)
|
||||||
} else {
|
} else {
|
||||||
StatsModel(
|
StatsModel(
|
||||||
title = 0,
|
title = 0,
|
||||||
totalGames = 0,
|
totalGames = 0,
|
||||||
totalTime = 0,
|
totalTime = 0,
|
||||||
|
victoryTime = 0,
|
||||||
averageTime = 0,
|
averageTime = 0,
|
||||||
shortestTime = 0,
|
shortestTime = 0,
|
||||||
mines = 0,
|
mines = 0,
|
||||||
|
|
Loading…
Reference in a new issue